diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2017-03-02 18:18:31 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2017-03-02 18:25:04 +0100 |
commit | 8c707e29ff764e85054a709b5d2ae142e0b2c20a (patch) | |
tree | c732e10588eefc3be9365dd6993b43c679dd7d28 /demos | |
parent | ed34be8bb3ea983f78c23ea922d14f511f6a2409 (diff) | |
download | gtk+-8c707e29ff764e85054a709b5d2ae142e0b2c20a.tar.gz |
gtk-demo: Add 3fg touchpad swipe handling to gestures demo
We can handle those on wayland, so we should show it's possible.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/gtk-demo/gestures.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/demos/gtk-demo/gestures.c b/demos/gtk-demo/gestures.c index 8ef19b077e..1e49756050 100644 --- a/demos/gtk-demo/gestures.c +++ b/demos/gtk-demo/gestures.c @@ -13,6 +13,17 @@ static gdouble swipe_x = 0; static gdouble swipe_y = 0; static gboolean long_pressed = FALSE; +static gboolean +touchpad_swipe_gesture_begin (GtkGesture *gesture, + GdkEventSequence *sequence, + GtkWidget *widget) +{ + /* Disallow touchscreen events here */ + if (sequence != NULL) + gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED); + return sequence == NULL; +} + static void swipe_gesture_swept (GtkGestureSwipe *gesture, gdouble velocity_x, @@ -156,6 +167,19 @@ do_gestures (GtkWidget *do_widget) GTK_PHASE_BUBBLE); g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture); + /* 3fg swipe for touchpads */ + gesture = g_object_new (GTK_TYPE_GESTURE_SWIPE, + "widget", drawing_area, + "n-points", 3, + NULL); + g_signal_connect (gesture, "begin", + G_CALLBACK (touchpad_swipe_gesture_begin), drawing_area); + g_signal_connect (gesture, "swipe", + G_CALLBACK (swipe_gesture_swept), drawing_area); + gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), + GTK_PHASE_BUBBLE); + g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture); + /* Long press */ gesture = gtk_gesture_long_press_new (drawing_area); g_signal_connect (gesture, "pressed", |