[gtk+/touchscreens: 14/69] gtk: connect to grab-notify for press and hold
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touchscreens: 14/69] gtk: connect to grab-notify for press and hold
- Date: Thu, 5 Jan 2012 11:41:00 +0000 (UTC)
commit cdd97bbff79f6d003964c54b7c68e18c9a8f3d0a
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Oct 24 11:24:23 2011 +0200
gtk: connect to grab-notify for press and hold
This is so press and hold is cancelled if a click actually
causes an inner widget to do a GTK+ grab.
gtk/gtkwidget.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b80b670..3602068 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -549,11 +549,14 @@ typedef struct
guint motion_id;
guint button_release_id;
guint drag_begin_id;
+ guint grab_notify_id;
gint start_x;
gint start_y;
gint current_x;
gint current_y;
+
+ GdkDevice *device;
} PressAndHoldData;
/* --- prototypes --- */
@@ -3097,9 +3100,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
* The trigger action is emitted by setting @action to be
* %GTK_PRESS_AND_HOLD_TRIGGER, the @x and @y coordinates are set to the
* cursor's current location (this includes any movements made between
- * the original query and this trigger) and @keyboard_mode is set to
- * %TRUE if the trigger was initiated by a keyboard action, %FALSE
- * otherwise. In this case the return value is ignored.
+ * the original query and this trigger). In this case the return value
+ * is ignored.
*
* When @action is %GTK_WIDGET_PRESS_AND_HOLD_CANCEL, @x and @y are both
* undefined. The return value is ignored too as
@@ -6966,6 +6968,16 @@ gtk_widget_press_and_hold_button_release (GtkWidget *widget,
return FALSE;
}
+static void
+gtk_widget_press_and_hold_grab_notify (GtkWidget *widget,
+ gboolean was_grabbed,
+ PressAndHoldData *data)
+{
+ if (data->device &&
+ gtk_widget_device_is_shadowed (widget, data->device))
+ gtk_widget_press_and_hold_cancel (widget, NULL, data);
+}
+
static gboolean
gtk_widget_press_and_hold_motion_notify (GtkWidget *widget,
GdkEvent *_event,
@@ -7211,10 +7223,16 @@ gtk_widget_press_and_hold_button_press_event (GtkWidget *widget,
G_CALLBACK (gtk_widget_press_and_hold_cancel),
data);
+ data->grab_notify_id =
+ g_signal_connect (widget, "grab-notify",
+ G_CALLBACK (gtk_widget_press_and_hold_grab_notify),
+ data);
+
data->press_and_hold_id =
gdk_threads_add_timeout (timeout,
gtk_widget_press_and_hold_timeout,
widget);
+ data->device = gdk_event_get_device ((GdkEvent *) event);
}
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]