From: Carlos Garnacho Date: Sun, 27 Nov 2022 19:22:33 +0000 (+0100) Subject: imcontextwayland: Set up OSK activation gesture on non text widgets X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~65^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=929a51addbf71b587bbd693071d9bbf966b78d3f;p=gtk4.git 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. --- 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; }