gtk-demo: Add 3fg touchpad swipe handling to gestures demo

We can handle those on wayland, so we should show it's possible.
This commit is contained in:
Carlos Garnacho 2017-03-02 18:18:31 +01:00
parent 76af1904db
commit 4b38a39c9d

View File

@ -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,
@ -161,6 +172,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",