gtktext: Claim drag gesture after an actual selection change
authorCarlos Garnacho <carlosg@gnome.org>
Sun, 27 Nov 2022 12:06:40 +0000 (13:06 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 28 Nov 2022 14:46:41 +0000 (15:46 +0100)
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

index 39eda89baa431e69d98e2a227435fe757d9c67f2..e58355e4036f885adaff88e66849a73e7302c63e 100644 (file)
@@ -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 () ||