summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2018-06-28 20:32:10 +0200
committerCarlos Garnacho <carlosg@gnome.org>2018-06-28 20:32:10 +0200
commit198f0099e92d3c60207b9e244dcba24dc5f42201 (patch)
tree0d3d45aa9f0f56439b519e9b1f442f1756bb77ce
parenta23d3605671613d865a96f0b9a81a13f160a8ef2 (diff)
downloadgtk+-wip/carlosg/event-final-cleanup.tar.gz
demos: Update changedisplay demo to using GtkGesturewip/carlosg/event-final-cleanup
-rw-r--r--demos/gtk-demo/changedisplay.c22
1 files 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;