• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionebef66cebe0fb7efda72c5b1f0ca80faba1ddac4 (tree)
Time2023-02-05 20:50:39
AuthorRuben Agin <phabrics@phab...>
CommiterRuben Agin

Log Message

Began the process of converting GTK 3 to 4.

Change Summary

Incremental Difference

--- a/configure.ac
+++ b/configure.ac
@@ -796,7 +796,9 @@ dnl Checks for GLIB.
796796 PKG_CHECK_MODULES([GLIB], [glib-2.0], [AC_DEFINE([HAVE_GLIB], [], [Defined if GLIB 2.0 is found.])], [])
797797
798798 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+])
800802 PKG_CHECK_MODULES([SDL], [sdl2], [have_sdl=$enable_sdl], [])
801803 AM_CONDITIONAL([HAVE_SDL], [test "x${have_sdl}" = xyes])
802804 PKG_CHECK_MODULES([RFB], [libvncclient libvncserver], [have_rfb=$enable_rfb], [])
--- a/host/display/display.c
+++ b/host/display/display.c
@@ -216,7 +216,7 @@ tme_display_update(void *disp) {
216216 (*display->tme_display_update)(display) :
217217 (TME_OK);
218218
219- if(rc != TME_OK) return rc;
219+ // if(rc != TME_OK) return rc;
220220
221221 /* lock the mutex: */
222222 tme_mutex_lock(&display->tme_display_mutex);
--- a/host/display/gtk/gtk-display.c
+++ b/host/display/gtk/gtk-display.c
@@ -39,6 +39,27 @@ _TME_RCSID("$Id: gtk-screen.c,v 1.11 2009/08/30 21:39:03 fredette Exp $");
3939 /* includes: */
4040 #include "gtk-display.h"
4141 #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
4263
4364 static void
4465 _tme_gtk_display_bell(struct tme_gdk_display *display) {
@@ -47,9 +68,13 @@ _tme_gtk_display_bell(struct tme_gdk_display *display) {
4768
4869 static int
4970 _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;
5378 }
5479
5580 /* this sets the screen scaling to that indicated by the Scale menu: */
@@ -196,7 +221,7 @@ _tme_gtk_screen_create_similar_image(GdkWindow *window,
196221 {
197222 cairo_surface_t *surface;
198223
199-#if GTK_MINOR_VERSION < 10
224+#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 10
200225 surface =
201226 cairo_image_surface_create(format,
202227 width,
@@ -449,42 +474,6 @@ _tme_gtk_screen_new(struct tme_gdk_display *display,
449474 return (screen);
450475 }
451476
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-
488477 /* this creates a menu of radio buttons: */
489478 GtkWidget *
490479 _tme_display_menu_radio(struct tme_gtk_screen *screen,
@@ -523,7 +512,15 @@ _tme_display_menu_radio(struct tme_gtk_screen *screen,
523512 TME_ELEMENT_SUB_NEW_DECL(tme_host_gtk,display) {
524513 struct tme_gdk_display *display;
525514 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+
527524 /* start our data structure: */
528525 display = tme_new0(struct tme_gdk_display, 1);
529526 tme_display_init(element, display);
@@ -531,8 +528,6 @@ TME_ELEMENT_SUB_NEW_DECL(tme_host_gtk,display) {
531528 /* recover our data structure: */
532529 display = element->tme_element_private;
533530
534- _tme_gtk_init();
535-
536531 display->tme_gdk_display = gdk_display_get_default();
537532
538533 display->tme_gdk_display_cursor
--- a/host/display/gtk/gtk-display.h
+++ b/host/display/gtk/gtk-display.h
@@ -95,7 +95,7 @@ struct tme_gtk_screen {
9595
9696 /* when mouse mode is on, this is the previous events mask
9797 for the framebuffer event box: */
98- GdkEventMask tme_gtk_screen_mouse_events_old;
98+ //GdkEventMask tme_gtk_screen_mouse_events_old;
9999
100100 };
101101
--- a/host/display/gtk/gtk-keyboard.c
+++ b/host/display/gtk/gtk-keyboard.c
@@ -56,7 +56,7 @@ _tme_gtk_keyboard_key_event(GtkWidget *widget,
5656 /* make a tme event from this gdk event: */
5757 gdk_event = &gdk_event_raw->key;
5858 tme_event.tme_keyboard_event_type
59- = (gdk_event->type == GDK_KEY_PRESS
59+ = (gdk_event_get_event_type(gdk_event) == GDK_KEY_PRESS
6060 ? TME_KEYBOARD_EVENT_PRESS
6161 : TME_KEYBOARD_EVENT_RELEASE);
6262 tme_event.tme_keyboard_event_modifiers
@@ -74,7 +74,7 @@ _tme_gtk_keyboard_key_event(GtkWidget *widget,
7474
7575 /* if this is a press of the mouse mode off key, turn mouse mode off
7676 and return now: */
77- if (gdk_event->type == GDK_KEY_PRESS
77+ if (gdk_event_get_event_type(gdk_event) == GDK_KEY_PRESS
7878 && (gdk_event->keyval
7979 == screen->tme_gtk_screen_mouse_keyval)) {
8080 _tme_gtk_mouse_mode_off(screen,
--- a/host/display/gtk/gtk-mouse.c
+++ b/host/display/gtk/gtk-mouse.c
@@ -66,14 +66,19 @@ _tme_gtk_mouse_mouse_event(GtkWidget *widget,
6666 gint y;
6767 int button=0;
6868
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
6974 /* if this is motion: */
7075 if (gdk_event_raw->type == GDK_MOTION_NOTIFY) {
7176
7277 /* if the pointer position hasn't changed either, return now.
7378 every time we warp the pointer we will get a motion event, and
7479 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;
7782
7883 }
7984
@@ -81,8 +86,8 @@ _tme_gtk_mouse_mouse_event(GtkWidget *widget,
8186 else {
8287
8388 /* 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;
8691
8792 /* make the buttons mask: */
8893 button = gdk_event_raw->button.button;
@@ -92,12 +97,12 @@ _tme_gtk_mouse_mouse_event(GtkWidget *widget,
9297
9398 /* otherwise, if this is a double- or triple-click: */
9499 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+ {
97103 /* we ignore double- and triple-click events, since normal button
98104 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);
101106
102107 _tme_mouse_button_press(button, x, y, display);
103108
@@ -121,13 +126,13 @@ _tme_gtk_mouse_ebox_event(GtkWidget *widget,
121126
122127 /* if this is an enter notify event, grab the focus and continue
123128 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) {
125130 gtk_widget_grab_focus(widget);
126131 return (FALSE);
127132 }
128133
129134 /* 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) {
131136 return (FALSE);
132137 }
133138