summaryrefslogtreecommitdiff
path: root/gtk/gtkdragsource.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-01-01 13:22:29 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-01-08 18:48:20 -0500
commit37b849b808d78b9f9b4da126e1b0990296243970 (patch)
tree58bdabbf2ab358d680b08c4ebd18cf10642dcdd4 /gtk/gtkdragsource.c
parente03bdbe307d82eb1be5480ff935703cfb3a0ff0b (diff)
downloadgtk+-37b849b808d78b9f9b4da126e1b0990296243970.tar.gz
Move the rest of the drag-source api over
Just reshuffling some source.
Diffstat (limited to 'gtk/gtkdragsource.c')
-rw-r--r--gtk/gtkdragsource.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index b0300df724..1f4930b3a9 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -39,6 +39,7 @@
#include "gtkdragiconprivate.h"
#include "gtkprivate.h"
#include "gtkmarshalers.h"
+#include "gtksettingsprivate.h"
/**
* SECTION:gtkdragsource
@@ -781,3 +782,34 @@ gtk_drag_source_drag_cancel (GtkDragSource *source)
gdk_drag_drop_done (source->drag, success);
}
}
+
+/**
+ * gtk_drag_check_threshold: (method)
+ * @widget: a #GtkWidget
+ * @start_x: X coordinate of start of drag
+ * @start_y: Y coordinate of start of drag
+ * @current_x: current X coordinate
+ * @current_y: current Y coordinate
+ *
+ * Checks to see if a mouse drag starting at (@start_x, @start_y) and ending
+ * at (@current_x, @current_y) has passed the GTK drag threshold, and thus
+ * should trigger the beginning of a drag-and-drop operation.
+ *
+ * Returns: %TRUE if the drag threshold has been passed.
+ */
+gboolean
+gtk_drag_check_threshold (GtkWidget *widget,
+ int start_x,
+ int start_y,
+ int current_x,
+ int current_y)
+{
+ gint drag_threshold;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ drag_threshold = gtk_settings_get_dnd_drag_threshold (gtk_widget_get_settings (widget));
+
+ return (ABS (current_x - start_x) > drag_threshold ||
+ ABS (current_y - start_y) > drag_threshold);
+}