summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-04-06 11:01:01 +0200
committerMatthias Clasen <mclasen@redhat.com>2022-04-21 19:23:48 -0400
commitb14bc4749ed260577cd5c71abd7c5c41b56ccc2f (patch)
tree9f0b1d03aa5586b78b7a7147d145b960340c1e8f
parentd56276f6d61cd87b1a41092f46b240c238e4c6ca (diff)
downloadgtk+-b14bc4749ed260577cd5c71abd7c5c41b56ccc2f.tar.gz
imwayland: Connect OSK activating gesture to parent widget on editables
The gesture as connected currently on the child GtkText is easily overridden by the parent editables (and gently done so in the attempt to consume all clicks). Connect this gesture to the parent editable widget in these cases, so the gesture can cohabit with the click-consuming one. It's not part of the same group, but it won't be abruptly cancelled. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4795
-rw-r--r--gtk/gtkimcontextwayland.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 486435f9e0..7e8d0e721c 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -71,6 +71,7 @@ struct _GtkIMContextWayland
{
GtkIMContextSimple parent_instance;
GtkWidget *widget;
+ GtkWidget *controller_widget;
GtkGesture *gesture;
double press_x;
@@ -555,16 +556,21 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
return;
if (context_wayland->widget)
+ gtk_im_context_wayland_focus_out (context);
+
+ if (context_wayland->controller_widget)
{
- gtk_im_context_wayland_focus_out (context);
- gtk_widget_remove_controller (context_wayland->widget, GTK_EVENT_CONTROLLER (context_wayland->gesture));
+ gtk_widget_remove_controller (context_wayland->controller_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)
{
+ GtkWidget *parent;
GtkGesture *gesture;
gesture = gtk_gesture_click_new ();
@@ -575,7 +581,18 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
G_CALLBACK (pressed_cb), context);
g_signal_connect (gesture, "released",
G_CALLBACK (released_cb), context);
- gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
+
+ 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_EVENT_CONTROLLER (gesture));
context_wayland->gesture = gesture;
}
}