diff options
Diffstat (limited to 'demos/gtk-demo/gestures.c')
-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", |