summaryrefslogtreecommitdiff
path: root/gtk/gtkgesturedrag.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2015-07-24 13:05:31 +0200
committerCarlos Garnacho <carlosg@gnome.org>2015-08-12 23:20:25 +0200
commit8e5be43e02a11499ff8b218632b646d0220ddd42 (patch)
tree2892bc9e3a22d7034227770a16660276669636ee /gtk/gtkgesturedrag.c
parent5d17338b4d158f6b460c73b064e1c2f363007d9c (diff)
downloadgtk+-8e5be43e02a11499ff8b218632b646d0220ddd42.tar.gz
gtkgesturedrag: Handle touchpad swipe events
These will only trigger the gesture if it's been created with the same GtkGesture::n-points than n_fingers in the event.
Diffstat (limited to 'gtk/gtkgesturedrag.c')
-rw-r--r--gtk/gtkgesturedrag.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gtk/gtkgesturedrag.c b/gtk/gtkgesturedrag.c
index bee5596be5..7d80cef07f 100644
--- a/gtk/gtkgesturedrag.c
+++ b/gtk/gtkgesturedrag.c
@@ -56,6 +56,26 @@ static guint signals[N_SIGNALS] = { 0 };
G_DEFINE_TYPE_WITH_PRIVATE (GtkGestureDrag, gtk_gesture_drag, GTK_TYPE_GESTURE_SINGLE)
+static gboolean
+gtk_gesture_drag_filter_event (GtkEventController *controller,
+ const GdkEvent *event)
+{
+ /* Let touchpad swipe events go through, only if they match n-points */
+ if (event->type == GDK_TOUCHPAD_SWIPE)
+ {
+ guint n_points;
+
+ g_object_get (G_OBJECT (controller), "n-points", &n_points, NULL);
+
+ if (event->touchpad_swipe.n_fingers == n_points)
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_drag_parent_class)->filter_event (controller, event);
+}
+
static void
gtk_gesture_drag_begin (GtkGesture *gesture,
GdkEventSequence *sequence)
@@ -110,6 +130,9 @@ static void
gtk_gesture_drag_class_init (GtkGestureDragClass *klass)
{
GtkGestureClass *gesture_class = GTK_GESTURE_CLASS (klass);
+ GtkEventControllerClass *event_controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
+
+ event_controller_class->filter_event = gtk_gesture_drag_filter_event;
gesture_class->begin = gtk_gesture_drag_begin;
gesture_class->update = gtk_gesture_drag_update;