gestureclick: Don't use threshold for touch
authorMatthias Clasen <mclasen@redhat.com>
Thu, 6 Apr 2023 19:31:03 +0000 (15:31 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 21 Apr 2023 07:10:18 +0000 (09:10 +0200)
When determining double-clicks, don't use the distance
threshold for touch events. It is very hard to double
touch reliably within a few pixels of the same position.

Fixes: #5580
gtk/gtkgestureclick.c

index cc5fec25af9f042020d10930c66d2270258b3ff1..0b07b992ac0bbb08d0b6def6408cb8c0bb2b597e 100644 (file)
@@ -220,7 +220,8 @@ gtk_gesture_click_begin (GtkGesture       *gesture,
   _gtk_gesture_click_update_timeout (click);
   gtk_gesture_get_point (gesture, current, &x, &y);
 
-  if (!_gtk_gesture_click_check_within_threshold (click, x, y))
+  if (gdk_device_get_source (priv->current_device) == GDK_SOURCE_MOUSE &&
+      !_gtk_gesture_click_check_within_threshold (click, x, y))
     _gtk_gesture_click_stop (click);
 
   /* Increment later the real counter, just if the gesture is
@@ -243,14 +244,17 @@ gtk_gesture_click_update (GtkGesture       *gesture,
                           GdkEventSequence *sequence)
 {
   GtkGestureClick *click;
+  GtkGestureClickPrivate *priv;
   GdkEventSequence *current;
   double x, y;
 
   click = GTK_GESTURE_CLICK (gesture);
+  priv = gtk_gesture_click_get_instance_private (click);
   current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
   gtk_gesture_get_point (gesture, current, &x, &y);
 
-  if (!_gtk_gesture_click_check_within_threshold (click, x, y))
+  if (gdk_device_get_source (priv->current_device) == GDK_SOURCE_MOUSE &&
+      !_gtk_gesture_click_check_within_threshold (click, x, y))
     _gtk_gesture_click_stop (click);
 }