From 929a51addbf71b587bbd693071d9bbf966b78d3f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 27 Nov 2022 20:22:33 +0100 Subject: [PATCH] imcontextwayland: Set up OSK activation gesture on non text widgets With GtkText and GtkTextView (and in extension, all their subclasses) handling OSK activation activation, this gesture is only useful for all text input widgets that are not subclasses of these 2 widgets, e.g. the VTEs and crosswords of the world. These still do need a hand in handling OSK activation, so only set up the gesture for such cases. --- gtk/gtkimcontextwayland.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c index f6c037313e..439c64bd3b 100644 --- a/gtk/gtkimcontextwayland.c +++ b/gtk/gtkimcontextwayland.c @@ -70,7 +70,6 @@ struct _GtkIMContextWayland { GtkIMContextSimple parent_instance; GtkWidget *widget; - GtkWidget *controller_widget; GtkGesture *gesture; double press_x; @@ -576,19 +575,19 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context, if (context_wayland->widget) gtk_im_context_wayland_focus_out (context); - if (context_wayland->controller_widget) + if (context_wayland->widget && context_wayland->gesture) { - gtk_widget_remove_controller (context_wayland->controller_widget, + gtk_widget_remove_controller (context_wayland->widget, GTK_EVENT_CONTROLLER (context_wayland->gesture)); context_wayland->gesture = NULL; - g_clear_object (&context_wayland->controller_widget); } g_set_object (&context_wayland->widget, widget); - if (widget) + if (widget && + !GTK_IS_TEXT (widget) && + !GTK_IS_TEXT_VIEW (widget)) { - GtkWidget *parent; GtkGesture *gesture; gesture = gtk_gesture_click_new (); @@ -600,16 +599,7 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context, g_signal_connect (gesture, "released", G_CALLBACK (released_cb), context); - parent = gtk_widget_get_parent (widget); - - if (parent && - GTK_IS_EDITABLE (widget) && - GTK_IS_EDITABLE (parent)) - g_set_object (&context_wayland->controller_widget, parent); - else - g_set_object (&context_wayland->controller_widget, widget); - - gtk_widget_add_controller (context_wayland->controller_widget, + gtk_widget_add_controller (context_wayland->widget, GTK_EVENT_CONTROLLER (gesture)); context_wayland->gesture = gesture; } -- 2.30.2