From 198f0099e92d3c60207b9e244dcba24dc5f42201 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 28 Jun 2018 20:32:10 +0200 Subject: demos: Update changedisplay demo to using GtkGesture --- demos/gtk-demo/changedisplay.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/demos/gtk-demo/changedisplay.c b/demos/gtk-demo/changedisplay.c index f9c273297d..caa1995340 100644 --- a/demos/gtk-demo/changedisplay.c +++ b/demos/gtk-demo/changedisplay.c @@ -87,14 +87,14 @@ find_toplevel_at_pointer (GdkDisplay *display) return widget ? gtk_widget_get_toplevel (widget) : NULL; } -static gboolean -release_event_cb (GtkWidget *widget, - GdkEvent *event, - gboolean *clicked) +static void +released_cb (GtkGestureMultiPress *gesture, + guint n_press, + gdouble x, + gdouble y, + gboolean *clicked) { - if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE) - *clicked = TRUE; - return TRUE; + *clicked = TRUE; } /* Asks the user to click on a window, then waits for them click @@ -132,10 +132,12 @@ query_for_toplevel (GdkDisplay *display, GDK_SEAT_CAPABILITY_ALL_POINTING, FALSE, cursor, NULL, NULL, NULL) == GDK_GRAB_SUCCESS) { + GtkGesture *gesture = gtk_gesture_multi_press_new (); gboolean clicked = FALSE; - g_signal_connect (popup, "event", - G_CALLBACK (release_event_cb), &clicked); + g_signal_connect (gesture, "released", + G_CALLBACK (released_cb), &clicked); + gtk_widget_add_controller (popup, GTK_EVENT_CONTROLLER (gesture)); /* Process events until clicked is set by our button release event handler. * We pass in may_block=TRUE since we want to wait if there @@ -144,6 +146,8 @@ query_for_toplevel (GdkDisplay *display, while (!clicked) g_main_context_iteration (NULL, TRUE); + gdk_seat_ungrab (gdk_device_get_seat (device)); + toplevel = find_toplevel_at_pointer (display); if (toplevel == popup) toplevel = NULL; -- cgit v1.2.1