summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-04-06 15:44:43 +0000
committerMatthias Clasen <mclasen@redhat.com>2022-04-06 15:44:43 +0000
commit38362c28037ea02a82b75e5e9d9335b6025f09ea (patch)
tree40bcc2e05711b1d6c8a77b060524243e2224cdc9
parent21cba193adf150f522c1bd89faa136ba8d9531cd (diff)
parenteb7c78aa4896b1d36fa09a3e68c942730b233f74 (diff)
downloadgtk+-38362c28037ea02a82b75e5e9d9335b6025f09ea.tar.gz
Merge branch 'wip/carlosg/osk-activation' into 'main'
imwayland: Connect OSK activating gesture to parent widget on editables Closes #4795 See merge request GNOME/gtk!4624
-rw-r--r--gtk/gtkimcontextwayland.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 486435f9e0..ea9ed00cfc 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;
}
}
@@ -893,17 +910,20 @@ gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
+ if (context_wayland->surrounding.text && text &&
+ (len < 0 || len == strlen (context_wayland->surrounding.text)) &&
+ strncmp (context_wayland->surrounding.text, text, len) == 0 &&
+ context_wayland->surrounding.cursor_idx == cursor_index &&
+ context_wayland->surrounding.anchor_idx == selection_bound)
+ return;
+
g_free (context_wayland->surrounding.text);
context_wayland->surrounding.text = g_strndup (text, len);
context_wayland->surrounding.cursor_idx = cursor_index;
context_wayland->surrounding.anchor_idx = selection_bound;
notify_surrounding_text (context_wayland);
- /* State changes coming from reset don't have any other opportunity to get
- * committed. */
- if (context_wayland->surrounding_change !=
- ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD)
- commit_state (context_wayland);
+ commit_state (context_wayland);
}
static gboolean