From 76d80f75444d95540da0d472c7e5aea8a74bf218 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 27 Nov 2022 13:06:40 +0100 Subject: [PATCH] gtktext: Claim drag gesture after an actual selection change This way, the drag gesture lets the click gesture ::release handler happen if there was no actual changes to the selected text (i.e. too short drags). This matches the ::release handler behavior match the situations in which the OSK was being invoked by the wayland GtkIMContext. --- gtk/gtktext.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gtk/gtktext.c b/gtk/gtktext.c index 39eda89baa..e58355e403 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -3051,8 +3051,7 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture, GdkDevice *source; guint length; int tmp_pos; - - gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); + int pos, bound; length = gtk_entry_buffer_get_length (get_buffer (self)); @@ -3070,7 +3069,6 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture, { int min, max; int old_min, old_max; - int pos, bound; min = gtk_text_move_backward_word (self, tmp_pos, TRUE); max = gtk_text_move_forward_word (self, tmp_pos, TRUE); @@ -3101,11 +3099,17 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture, if (priv->current_pos != max) pos = min; } - - gtk_text_set_positions (self, pos, bound); } else - gtk_text_set_positions (self, tmp_pos, -1); + { + pos = tmp_pos; + bound = -1; + } + + if (pos != priv->current_pos) + gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); + + gtk_text_set_positions (self, pos, bound); /* Update touch handles' position */ if (gtk_simulate_touchscreen () || -- 2.30.2