[gtk+/gestures: 42/117] widget: Reset gestures on grab-notify
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gestures: 42/117] widget: Reset gestures on grab-notify
- Date: Thu, 10 Apr 2014 20:28:13 +0000 (UTC)
commit a0b5def4dec3e1588a9ed8129cd7fc89c3bf1442
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Mar 24 14:42:13 2014 +0100
widget: Reset gestures on grab-notify
If it is determined that the gesture will stop receiving
events, reset the gesture altogether.
gtk/gtkwidget.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index fb09263..6da5e38 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -400,6 +400,7 @@ typedef struct {
typedef struct {
GtkGesture *controller;
guint evmask_notify_id;
+ guint grab_notify_id;
guint propagation_phase : 2;
} EventControllerData;
@@ -16480,6 +16481,46 @@ gtk_widget_get_template_child (GtkWidget *widget,
}
static void
+event_controller_grab_notify (GtkWidget *widget,
+ gboolean was_grabbed,
+ EventControllerData *data)
+{
+ GtkWidget *grab_widget, *toplevel;
+ GtkWindowGroup *group;
+ GdkDevice *device;
+
+ device = gtk_gesture_get_device (data->controller);
+
+ if (!device)
+ return;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+
+ if (GTK_IS_WINDOW (toplevel))
+ group = gtk_window_get_group (GTK_WINDOW (toplevel));
+ else
+ group = gtk_window_get_group (NULL);
+
+ grab_widget = gtk_window_group_get_current_device_grab (group, device);
+
+ if (!grab_widget)
+ grab_widget = gtk_window_group_get_current_grab (group);
+
+ if (!grab_widget || grab_widget == widget)
+ return;
+
+ if (((data->propagation_phase == GTK_PHASE_NONE ||
+ data->propagation_phase == GTK_PHASE_BUBBLE) &&
+ !gtk_widget_is_ancestor (widget, grab_widget)) ||
+ (data->propagation_phase == GTK_PHASE_CAPTURE &&
+ !gtk_widget_is_ancestor (widget, grab_widget) &&
+ !gtk_widget_is_ancestor (grab_widget, widget)))
+ {
+ gtk_event_controller_reset (GTK_EVENT_CONTROLLER (data->controller));
+ }
+}
+
+static void
event_controller_notify_event_mask (GtkEventController *controller,
GParamSpec *pspec,
GtkWidget *widget)
@@ -16532,6 +16573,9 @@ gtk_widget_add_gesture (GtkWidget *widget,
data->evmask_notify_id =
g_signal_connect (gesture, "notify::event-mask",
G_CALLBACK (event_controller_notify_event_mask), widget);
+ data->grab_notify_id =
+ g_signal_connect (widget, "grab-notify",
+ G_CALLBACK (event_controller_grab_notify), data);
priv->event_controllers = g_list_prepend (priv->event_controllers, data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]