[gtk+/gestures] gesturesingle: Add an "exclusive" boolean property
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gestures] gesturesingle: Add an "exclusive" boolean property
- Date: Mon, 12 May 2014 17:59:48 +0000 (UTC)
commit 0b1eed658bf96b6bdc3df5ac9f0aa6d4f33ec556
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon May 12 19:50:26 2014 +0200
gesturesingle: Add an "exclusive" boolean property
All "exclusive" gestures listen for either pointer events, or
"pointer emulating" touch events, so only a single sequence at
a time can make these run.
docs/reference/gtk/gtk3-sections.txt | 2 +
gtk/gtkgesturesingle.c | 81 ++++++++++++++++++++++++++++++++++
gtk/gtkgesturesingle.h | 7 +++
3 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index dcb7ca5..e00e433 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -7963,6 +7963,8 @@ gtk_gesture_get_type
<FILE>gtkgesturesingle</FILE>
<TITLE>GtkGestureSingle</TITLE>
GtkGestureSingle
+gtk_gesture_single_get_exclusive
+gtk_gesture_single_set_exclusive
gtk_gesture_single_get_touch_only
gtk_gesture_single_set_touch_only
gtk_gesture_single_get_button
diff --git a/gtk/gtkgesturesingle.c b/gtk/gtkgesturesingle.c
index 8d8f118..ef95bd3 100644
--- a/gtk/gtkgesturesingle.c
+++ b/gtk/gtkgesturesingle.c
@@ -48,10 +48,12 @@ struct _GtkGestureSinglePrivate
guint button;
guint current_button;
guint touch_only : 1;
+ guint exclusive : 1;
};
enum {
PROP_TOUCH_ONLY = 1,
+ PROP_EXCLUSIVE,
PROP_BUTTON
};
@@ -73,6 +75,9 @@ gtk_gesture_single_get_property (GObject *object,
case PROP_TOUCH_ONLY:
g_value_set_boolean (value, priv->touch_only);
break;
+ case PROP_EXCLUSIVE:
+ g_value_set_boolean (value, priv->exclusive);
+ break;
case PROP_BUTTON:
g_value_set_uint (value, priv->button);
break;
@@ -93,6 +98,10 @@ gtk_gesture_single_set_property (GObject *object,
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (object),
g_value_get_boolean (value));
break;
+ case PROP_EXCLUSIVE:
+ gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (object),
+ g_value_get_boolean (value));
+ break;
case PROP_BUTTON:
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (object),
g_value_get_uint (value));
@@ -136,6 +145,9 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_END:
case GDK_TOUCH_UPDATE:
+ if (priv->exclusive && !event->touch.emulating_pointer)
+ return FALSE;
+
sequence = event->touch.sequence;
button = 1;
break;
@@ -227,6 +239,21 @@ gtk_gesture_single_class_init (GtkGestureSingleClass *klass)
TRUE,
GTK_PARAM_READWRITE));
/**
+ * GtkGestureSingle:exclusive:
+ *
+ * Whether the gesture is exclusive. Exclusive gestures only listen to pointer
+ * and pointer emulated events.
+ *
+ * Since: 3.14
+ */
+ g_object_class_install_property (object_class,
+ PROP_EXCLUSIVE,
+ g_param_spec_boolean ("exclusive",
+ P_("Whether the gesture is exclusive"),
+ P_("Whether the gesture is exclusive"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+ /**
* GtkGestureSingle:button:
*
* Mouse button number to listen to, or 0 to listen for any button.
@@ -326,6 +353,60 @@ gtk_gesture_single_set_touch_only (GtkGestureSingle *gesture,
}
/**
+ * gtk_gesture_single_get_exclusive:
+ * @gesture: a #GtkGestureSingle
+ *
+ * Gets whether a gesture is exclusive. For more information, see
+ * gtk_gesture_single_set_exclusive().
+ *
+ * Returns: Whether the gesture is exclusive
+ *
+ * Since: 3.14
+ **/
+gboolean
+gtk_gesture_single_get_exclusive (GtkGestureSingle *gesture)
+{
+ GtkGestureSinglePrivate *priv;
+
+ g_return_val_if_fail (GTK_IS_GESTURE_SINGLE (gesture), FALSE);
+
+ priv = gtk_gesture_single_get_instance_private (gesture);
+
+ return priv->exclusive;
+}
+
+/**
+ * gtk_gesture_single_set_exclusive:
+ * @gesture: a #GtkGestureSingle
+ * @exclusive: #TRUE to make @gesture exclusive
+ *
+ * Sets whether @gesture is exclusive. An exclusive gesture will
+ * only handle pointer and "pointer emulated" touch events, so at
+ * any given time, there is only one sequence able to interact with
+ * those.
+ *
+ * Since: 3.14
+ **/
+void
+gtk_gesture_single_set_exclusive (GtkGestureSingle *gesture,
+ gboolean exclusive)
+{
+ GtkGestureSinglePrivate *priv;
+
+ g_return_if_fail (GTK_IS_GESTURE_SINGLE (gesture));
+
+ exclusive = exclusive != FALSE;
+ priv = gtk_gesture_single_get_instance_private (gesture);
+
+ if (priv->exclusive == exclusive)
+ return;
+
+ priv->exclusive = exclusive;
+ _gtk_gesture_single_update_evmask (gesture);
+ g_object_notify (G_OBJECT (gesture), "exclusive");
+}
+
+/**
* gtk_gesture_single_get_button:
* @gesture: a #GtkGestureSingle
*
diff --git a/gtk/gtkgesturesingle.h b/gtk/gtkgesturesingle.h
index fb4bce9..3dde8d7 100644
--- a/gtk/gtkgesturesingle.h
+++ b/gtk/gtkgesturesingle.h
@@ -49,6 +49,13 @@ GDK_AVAILABLE_IN_3_14
void gtk_gesture_single_set_touch_only (GtkGestureSingle *gesture,
gboolean touch_only);
GDK_AVAILABLE_IN_3_14
+gboolean gtk_gesture_single_get_exclusive (GtkGestureSingle *gesture);
+
+GDK_AVAILABLE_IN_3_14
+void gtk_gesture_single_set_exclusive (GtkGestureSingle *gesture,
+ gboolean exclusive);
+
+GDK_AVAILABLE_IN_3_14
guint gtk_gesture_single_get_button (GtkGestureSingle *gesture);
GDK_AVAILABLE_IN_3_14
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]