diff options
author | Alexander Mikhaylenko <alexm@gnome.org> | 2020-12-25 22:57:48 +0500 |
---|---|---|
committer | Alexander Mikhaylenko <alexm@gnome.org> | 2021-01-29 12:01:34 +0500 |
commit | f63e6394ac32c9cbc85a344e1b22cbbd3188d7ee (patch) | |
tree | f5d4289c94e0a324e2e4578e4ea1c230aa9ae365 /gtk/gtktextview.c | |
parent | bbca4c38dfef37cabd2c0d0c37ad63a99bed4125 (diff) | |
download | gtk+-f63e6394ac32c9cbc85a344e1b22cbbd3188d7ee.tar.gz |
dragsource: Use double coordinates for checking drag threshold
If multiple nested widgets have drag sources on them, both using bubble
phase, we need to reliably pick the inner one. Both of them will try to
start dragging, and we need to make sure there are no situations where the
outer widget starts drag earlier and cancels the inner one.
Currently, this can easily happen via integer rounding: start and current
coordinates passed into gtk_drag_check_threshold() are initially doubles
(other than in GtkNotebook and GtkIconView), and are casted to ints. Then
those rounded values are used to calculate deltas to compare to the drag
threshold, losing quite a lot of precision along the way, and often
resulting in the outer widget getting larger deltas.
To avoid it, just don't round it. Introduce a variant of the function that
operates on doubles: gtk_drag_check_threshold_double() and use it instead
of the original everywhere.
Diffstat (limited to 'gtk/gtktextview.c')
-rw-r--r-- | gtk/gtktextview.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 6f0bdb18bc..bece4d5839 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -32,6 +32,7 @@ #include "gtkadjustmentprivate.h" #include "gtkcsscolorvalueprivate.h" #include "gtkdebug.h" +#include "gtkdragsourceprivate.h" #include "gtkdropcontrollermotion.h" #include "gtkintl.h" #include "gtkmain.h" @@ -7232,7 +7233,7 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture, /* If no data is attached, the initial press happened within the current * text selection, check for drag and drop to be initiated. */ - if (gtk_drag_check_threshold (GTK_WIDGET (text_view), start_x, start_y, x, y)) + if (gtk_drag_check_threshold_double (GTK_WIDGET (text_view), 0, 0, offset_x, offset_y)) { if (!is_touchscreen) { @@ -7366,7 +7367,7 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture, gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN; if ((is_touchscreen || clicked_in_selection) && - !gtk_drag_check_threshold (GTK_WIDGET (text_view), start_x, start_y, x, y)) + !gtk_drag_check_threshold_double (GTK_WIDGET (text_view), 0, 0, offset_x, offset_y)) { GtkTextIter iter; |