summaryrefslogtreecommitdiff
path: root/gtk/gtkscrolledwindow.c
diff options
context:
space:
mode:
authorAlexander Mikhaylenko <alexm@gnome.org>2020-12-25 22:57:48 +0500
committerAlexander Mikhaylenko <alexm@gnome.org>2021-01-29 12:01:34 +0500
commitf63e6394ac32c9cbc85a344e1b22cbbd3188d7ee (patch)
treef5d4289c94e0a324e2e4578e4ea1c230aa9ae365 /gtk/gtkscrolledwindow.c
parentbbca4c38dfef37cabd2c0d0c37ad63a99bed4125 (diff)
downloadgtk+-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/gtkscrolledwindow.c')
-rw-r--r--gtk/gtkscrolledwindow.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 53136833c8..e0454e108d 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -29,7 +29,7 @@
#include "gtkadjustment.h"
#include "gtkadjustmentprivate.h"
#include "gtkbuildable.h"
-#include "gtkdragsource.h"
+#include "gtkdragsourceprivate.h"
#include "gtkeventcontrollermotion.h"
#include "gtkeventcontrollerscroll.h"
#include "gtkeventcontrollerprivate.h"
@@ -953,8 +953,8 @@ scrolled_window_drag_update_cb (GtkScrolledWindow *scrolled_window,
GtkAdjustment *vadjustment;
double dx, dy;
- if (!gtk_drag_check_threshold (GTK_WIDGET (scrolled_window),
- 0, 0, offset_x, offset_y))
+ if (!gtk_drag_check_threshold_double (GTK_WIDGET (scrolled_window),
+ 0, 0, offset_x, offset_y))
return;
gtk_scrolled_window_invalidate_overshoot (scrolled_window);