summaryrefslogtreecommitdiff
path: root/gtk/gtkgestureswipe.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2015-07-24 13:03:09 +0200
committerCarlos Garnacho <carlosg@gnome.org>2015-08-12 23:20:25 +0200
commit5d17338b4d158f6b460c73b064e1c2f363007d9c (patch)
tree33705c6eaa24bb8b89e2a53c26942171c68ad958 /gtk/gtkgestureswipe.c
parent5f68a2877df13d25b17299c497cddf7de1096faa (diff)
downloadgtk+-5d17338b4d158f6b460c73b064e1c2f363007d9c.tar.gz
gtkgestureswipe: 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/gtkgestureswipe.c')
-rw-r--r--gtk/gtkgestureswipe.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gtk/gtkgestureswipe.c b/gtk/gtkgestureswipe.c
index 0ca5bb35dc..82bfba0eaa 100644
--- a/gtk/gtkgestureswipe.c
+++ b/gtk/gtkgestureswipe.c
@@ -77,6 +77,26 @@ gtk_gesture_swipe_finalize (GObject *object)
G_OBJECT_CLASS (gtk_gesture_swipe_parent_class)->finalize (object);
}
+static gboolean
+gtk_gesture_swipe_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_swipe_parent_class)->filter_event (controller, event);
+}
+
static void
_gtk_gesture_swipe_clear_backlog (GtkGestureSwipe *gesture,
guint32 evtime)
@@ -188,10 +208,13 @@ static void
gtk_gesture_swipe_class_init (GtkGestureSwipeClass *klass)
{
GtkGestureClass *gesture_class = GTK_GESTURE_CLASS (klass);
+ GtkEventControllerClass *event_controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_gesture_swipe_finalize;
+ event_controller_class->filter_event = gtk_gesture_swipe_filter_event;
+
gesture_class->update = gtk_gesture_swipe_update;
gesture_class->end = gtk_gesture_swipe_end;