diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2022-11-27 20:22:33 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2022-11-28 15:46:41 +0100 |
commit | 929a51addbf71b587bbd693071d9bbf966b78d3f (patch) | |
tree | a19fa704235cead79a328539ec208a5588b9170c | |
parent | 6cbb7b848a16f10e4dec39cd6c43ce0fa854b103 (diff) | |
download | gtk+-929a51addbf71b587bbd693071d9bbf966b78d3f.tar.gz |
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.
-rw-r--r-- | gtk/gtkimcontextwayland.c | 22 |
1 files 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; } |