Revision | ebef66cebe0fb7efda72c5b1f0ca80faba1ddac4 (tree) |
---|---|
Time | 2023-02-05 20:50:39 |
Author | Ruben Agin <phabrics@phab...> |
Commiter | Ruben Agin |
Began the process of converting GTK 3 to 4.
@@ -796,7 +796,9 @@ dnl Checks for GLIB. | ||
796 | 796 | PKG_CHECK_MODULES([GLIB], [glib-2.0], [AC_DEFINE([HAVE_GLIB], [], [Defined if GLIB 2.0 is found.])], []) |
797 | 797 | |
798 | 798 | dnl Checks for display type support |
799 | -PKG_CHECK_MODULES([GTK], [gtk+-3.0], [have_gtk=$enable_gtk], []) | |
799 | +PKG_CHECK_MODULES([GTK], [gtk4], [have_gtk=$enable_gtk], [ | |
800 | + PKG_CHECK_MODULES([GTK], [gtk+-3.0], [have_gtk=$enable_gtk], []) | |
801 | +]) | |
800 | 802 | PKG_CHECK_MODULES([SDL], [sdl2], [have_sdl=$enable_sdl], []) |
801 | 803 | AM_CONDITIONAL([HAVE_SDL], [test "x${have_sdl}" = xyes]) |
802 | 804 | PKG_CHECK_MODULES([RFB], [libvncclient libvncserver], [have_rfb=$enable_rfb], []) |
@@ -216,7 +216,7 @@ tme_display_update(void *disp) { | ||
216 | 216 | (*display->tme_display_update)(display) : |
217 | 217 | (TME_OK); |
218 | 218 | |
219 | - if(rc != TME_OK) return rc; | |
219 | + // if(rc != TME_OK) return rc; | |
220 | 220 | |
221 | 221 | /* lock the mutex: */ |
222 | 222 | tme_mutex_lock(&display->tme_display_mutex); |
@@ -39,6 +39,27 @@ _TME_RCSID("$Id: gtk-screen.c,v 1.11 2009/08/30 21:39:03 fredette Exp $"); | ||
39 | 39 | /* includes: */ |
40 | 40 | #include "gtk-display.h" |
41 | 41 | #include <stdlib.h> |
42 | +#if GTK_MAJOR_VERSION == 4 | |
43 | +#define _tme_gtk_window_toplevels gtk_window_get_toplevels | |
44 | +#define _tme_gtk_init gtk_init_check | |
45 | +#else | |
46 | +#define _tme_gtk_window_toplevels gtk_window_list_toplevels | |
47 | +static void _tme_gtk_init(void) { | |
48 | + char **argv; | |
49 | + char *argv_buffer[3]; | |
50 | + int argc; | |
51 | + | |
52 | + /* conjure up an argv. this is pretty bad: */ | |
53 | + argv = argv_buffer; | |
54 | + argc = 0; | |
55 | + argv[argc++] = "tmesh"; | |
56 | +#if 1 | |
57 | + argv[argc++] = "--gtk-debug=signals"; | |
58 | +#endif | |
59 | + argv[argc] = NULL; | |
60 | + gtk_init_check(&argc, &argv); | |
61 | +} | |
62 | +#endif | |
42 | 63 | |
43 | 64 | static void |
44 | 65 | _tme_gtk_display_bell(struct tme_gdk_display *display) { |
@@ -47,9 +68,13 @@ _tme_gtk_display_bell(struct tme_gdk_display *display) { | ||
47 | 68 | |
48 | 69 | static int |
49 | 70 | _tme_gtk_display_update(struct tme_display *display) { |
50 | - while (gtk_events_pending ()) | |
51 | - gtk_main_iteration (); | |
52 | - return TME_OK; | |
71 | + int rc; | |
72 | + | |
73 | + for(rc=TRUE;rc && g_main_context_pending(NULL); | |
74 | + rc = g_main_context_iteration(NULL, TRUE)); | |
75 | + | |
76 | + if(rc) rc = g_list_model_get_n_items(_tme_gtk_window_toplevels()); | |
77 | + return !rc; | |
53 | 78 | } |
54 | 79 | |
55 | 80 | /* this sets the screen scaling to that indicated by the Scale menu: */ |
@@ -196,7 +221,7 @@ _tme_gtk_screen_create_similar_image(GdkWindow *window, | ||
196 | 221 | { |
197 | 222 | cairo_surface_t *surface; |
198 | 223 | |
199 | -#if GTK_MINOR_VERSION < 10 | |
224 | +#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 10 | |
200 | 225 | surface = |
201 | 226 | cairo_image_surface_create(format, |
202 | 227 | width, |
@@ -449,42 +474,6 @@ _tme_gtk_screen_new(struct tme_gdk_display *display, | ||
449 | 474 | return (screen); |
450 | 475 | } |
451 | 476 | |
452 | -static void _tme_gtk_init(void) { | |
453 | - char **argv; | |
454 | - char *argv_buffer[3]; | |
455 | - int argc; | |
456 | - | |
457 | - /* GTK requires program to be running non-setuid */ | |
458 | -#ifdef HAVE_SETUID | |
459 | - setuid(getuid()); | |
460 | -#endif | |
461 | - | |
462 | - /* conjure up an argv. this is pretty bad: */ | |
463 | - argv = argv_buffer; | |
464 | - argc = 0; | |
465 | - argv[argc++] = "tmesh"; | |
466 | -#if 1 | |
467 | - argv[argc++] = "--gtk-debug=signals"; | |
468 | -#endif | |
469 | - argv[argc] = NULL; | |
470 | - gtk_init(&argc, &argv); | |
471 | -} | |
472 | - | |
473 | -/* this is a GTK callback for an enter notify event, that has the | |
474 | - widget grab focus and then continue normal event processing: */ | |
475 | -gint | |
476 | -_tme_display_enter_focus(GtkWidget *widget, | |
477 | - GdkEvent *gdk_event_raw, | |
478 | - gpointer junk) | |
479 | -{ | |
480 | - | |
481 | - /* grab the focus: */ | |
482 | - gtk_widget_grab_focus(widget); | |
483 | - | |
484 | - /* continue normal event processing: */ | |
485 | - return (FALSE); | |
486 | -} | |
487 | - | |
488 | 477 | /* this creates a menu of radio buttons: */ |
489 | 478 | GtkWidget * |
490 | 479 | _tme_display_menu_radio(struct tme_gtk_screen *screen, |
@@ -523,7 +512,15 @@ _tme_display_menu_radio(struct tme_gtk_screen *screen, | ||
523 | 512 | TME_ELEMENT_SUB_NEW_DECL(tme_host_gtk,display) { |
524 | 513 | struct tme_gdk_display *display; |
525 | 514 | GdkRectangle workarea; |
526 | - | |
515 | + int rc; | |
516 | + | |
517 | + /* GTK requires program to be running non-setuid */ | |
518 | +#ifdef HAVE_SETUID | |
519 | + setuid(getuid()); | |
520 | +#endif | |
521 | + | |
522 | + if(!(rc = _tme_gtk_init())) return rc; | |
523 | + | |
527 | 524 | /* start our data structure: */ |
528 | 525 | display = tme_new0(struct tme_gdk_display, 1); |
529 | 526 | tme_display_init(element, display); |
@@ -531,8 +528,6 @@ TME_ELEMENT_SUB_NEW_DECL(tme_host_gtk,display) { | ||
531 | 528 | /* recover our data structure: */ |
532 | 529 | display = element->tme_element_private; |
533 | 530 | |
534 | - _tme_gtk_init(); | |
535 | - | |
536 | 531 | display->tme_gdk_display = gdk_display_get_default(); |
537 | 532 | |
538 | 533 | display->tme_gdk_display_cursor |
@@ -95,7 +95,7 @@ struct tme_gtk_screen { | ||
95 | 95 | |
96 | 96 | /* when mouse mode is on, this is the previous events mask |
97 | 97 | for the framebuffer event box: */ |
98 | - GdkEventMask tme_gtk_screen_mouse_events_old; | |
98 | + //GdkEventMask tme_gtk_screen_mouse_events_old; | |
99 | 99 | |
100 | 100 | }; |
101 | 101 |
@@ -56,7 +56,7 @@ _tme_gtk_keyboard_key_event(GtkWidget *widget, | ||
56 | 56 | /* make a tme event from this gdk event: */ |
57 | 57 | gdk_event = &gdk_event_raw->key; |
58 | 58 | tme_event.tme_keyboard_event_type |
59 | - = (gdk_event->type == GDK_KEY_PRESS | |
59 | + = (gdk_event_get_event_type(gdk_event) == GDK_KEY_PRESS | |
60 | 60 | ? TME_KEYBOARD_EVENT_PRESS |
61 | 61 | : TME_KEYBOARD_EVENT_RELEASE); |
62 | 62 | tme_event.tme_keyboard_event_modifiers |
@@ -74,7 +74,7 @@ _tme_gtk_keyboard_key_event(GtkWidget *widget, | ||
74 | 74 | |
75 | 75 | /* if this is a press of the mouse mode off key, turn mouse mode off |
76 | 76 | and return now: */ |
77 | - if (gdk_event->type == GDK_KEY_PRESS | |
77 | + if (gdk_event_get_event_type(gdk_event) == GDK_KEY_PRESS | |
78 | 78 | && (gdk_event->keyval |
79 | 79 | == screen->tme_gtk_screen_mouse_keyval)) { |
80 | 80 | _tme_gtk_mouse_mode_off(screen, |
@@ -66,14 +66,19 @@ _tme_gtk_mouse_mouse_event(GtkWidget *widget, | ||
66 | 66 | gint y; |
67 | 67 | int button=0; |
68 | 68 | |
69 | +#if GTK_MAJOR_VERSION == 4 | |
70 | + gdk_event_get_position(gdk_event_raw, &x, &y); | |
71 | + button = gdk_button_event_get_button(gdk_event_raw); | |
72 | + | |
73 | +#elif GTK_MAJOR_VERSION == 3 | |
69 | 74 | /* if this is motion: */ |
70 | 75 | if (gdk_event_raw->type == GDK_MOTION_NOTIFY) { |
71 | 76 | |
72 | 77 | /* if the pointer position hasn't changed either, return now. |
73 | 78 | every time we warp the pointer we will get a motion event, and |
74 | 79 | this should ignore those events: */ |
75 | - x = gdk_event_raw->motion.x_root; | |
76 | - y = gdk_event_raw->motion.y_root; | |
80 | + x = gdk_event_raw->motion.x; | |
81 | + y = gdk_event_raw->motion.y; | |
77 | 82 | |
78 | 83 | } |
79 | 84 |
@@ -81,8 +86,8 @@ _tme_gtk_mouse_mouse_event(GtkWidget *widget, | ||
81 | 86 | else { |
82 | 87 | |
83 | 88 | /* get the pointer position: */ |
84 | - x = gdk_event_raw->button.x_root; | |
85 | - y = gdk_event_raw->button.y_root; | |
89 | + x = gdk_event_raw->button.x; | |
90 | + y = gdk_event_raw->button.y; | |
86 | 91 | |
87 | 92 | /* make the buttons mask: */ |
88 | 93 | button = gdk_event_raw->button.button; |
@@ -92,12 +97,12 @@ _tme_gtk_mouse_mouse_event(GtkWidget *widget, | ||
92 | 97 | |
93 | 98 | /* otherwise, if this is a double- or triple-click: */ |
94 | 99 | if (gdk_event_raw->type != GDK_2BUTTON_PRESS |
95 | - && gdk_event_raw->type != GDK_3BUTTON_PRESS) { | |
96 | - | |
100 | + && gdk_event_raw->type != GDK_3BUTTON_PRESS) | |
101 | +#endif | |
102 | + { | |
97 | 103 | /* we ignore double- and triple-click events, since normal button |
98 | 104 | press and release events are always generated also: */ |
99 | - assert (gdk_event_raw->type == GDK_BUTTON_PRESS | |
100 | - || gdk_event_raw->type == GDK_BUTTON_RELEASE); | |
105 | + // assert (gdk_event_raw->type == GDK_BUTTON_PRESS || gdk_event_raw->type == GDK_BUTTON_RELEASE); | |
101 | 106 | |
102 | 107 | _tme_mouse_button_press(button, x, y, display); |
103 | 108 |
@@ -121,13 +126,13 @@ _tme_gtk_mouse_ebox_event(GtkWidget *widget, | ||
121 | 126 | |
122 | 127 | /* if this is an enter notify event, grab the focus and continue |
123 | 128 | propagating the event: */ |
124 | - if (gdk_event_raw->type == GDK_ENTER_NOTIFY) { | |
129 | + if (gdk_event_get_event_type(gdk_event_raw) == GDK_ENTER_NOTIFY) { | |
125 | 130 | gtk_widget_grab_focus(widget); |
126 | 131 | return (FALSE); |
127 | 132 | } |
128 | 133 | |
129 | 134 | /* if this is not a key press event, continue propagating it now: */ |
130 | - if (gdk_event_raw->type != GDK_KEY_PRESS) { | |
135 | + if (gdk_event_get_event_type(gdk_event_raw) != GDK_KEY_PRESS) { | |
131 | 136 | return (FALSE); |
132 | 137 | } |
133 | 138 |