From 93c7da7ef08df0b59e93280ea65887eab2cd8700 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 3 Oct 2021 08:28:54 +0300 Subject: [PATCH 46/48] gtk4: Drop gtk_widget_event() using functions gtk-3.98 does not have gtk_widget_event(). Just drop the functions built around it from gtk3x-client See osdn #42977 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/gui_main.c | 44 ----------------------------------- 1 file changed, 44 deletions(-) diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index 8309449c28..8b18673f21 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -362,36 +362,6 @@ gboolean map_canvas_focus(void) return TRUE; } -/**********************************************************************//** - In GTK keyboard events are recursively propagated from the hierarchy - parent down to its children. Sometimes this is not what we want. - E.g. The inputline is active, the user presses the 's' key, we want it - to be sent to the inputline, but because the main menu is further up - the hierarchy, it wins and the inputline never gets anything! - This function ensures an entry widget (like the inputline) always gets - first dibs at handling a keyboard event. -**************************************************************************/ -static gboolean toplevel_handler(GtkWidget *w, GdkEventKey *ev, gpointer data) -{ - GtkWidget *focus; - - focus = gtk_window_get_focus(GTK_WINDOW(toplevel)); - if (focus) { - if (GTK_IS_ENTRY(focus) - || (GTK_IS_TEXT_VIEW(focus) - && gtk_text_view_get_editable(GTK_TEXT_VIEW(focus)))) { - /* Propagate event to currently focused entry widget. */ - if (gtk_widget_event(focus, (GdkEvent *) ev)) { - /* Do not propagate event to our children. */ - return TRUE; - } - } - } - - /* Continue propagating event to our children. */ - return FALSE; -} - /**********************************************************************//** Handle keypress events when map canvas is in focus **************************************************************************/ @@ -773,16 +743,6 @@ static void tearoff_destroy(GtkWidget *w, gpointer data) g_object_unref(box); } -/**********************************************************************//** - Propagates a keypress in a tearoff back to the toplevel window. -**************************************************************************/ -static gboolean propagate_keypress(GtkWidget *w, GdkEventKey *ev) -{ - gtk_widget_event(toplevel, (GdkEvent *)ev); - - return FALSE; -} - /**********************************************************************//** Callback for the toggle button in the detachable widget: causes the widget to detach or reattach. @@ -802,8 +762,6 @@ static void tearoff_callback(GtkWidget *b, gpointer data) gtk_widget_set_name(w, "Freeciv"); gtk_window_set_title(GTK_WINDOW(w), _("Freeciv")); g_signal_connect(w, "destroy", G_CALLBACK(tearoff_destroy), box); - g_signal_connect(w, "key_press_event", - G_CALLBACK(propagate_keypress), NULL); g_object_set_data(G_OBJECT(w), "parent", gtk_widget_get_parent(box)); g_object_set_data(G_OBJECT(w), "toggle", b); @@ -1838,8 +1796,6 @@ static void activate_gui(GtkApplication *app, gpointer data) if (vmode.width > 0 && vmode.height > 0) { gtk_window_resize(GTK_WINDOW(toplevel), vmode.width, vmode.height); } - g_signal_connect(toplevel, "key_press_event", - G_CALLBACK(toplevel_handler), NULL); gtk_widget_realize(toplevel); gtk_widget_set_name(toplevel, "Freeciv"); -- 2.33.0