diff options
-rw-r--r-- | docs/reference/gtk/gtk3-sections.txt | 2 | ||||
-rw-r--r-- | gtk/gtkgesturesingle.c | 81 | ||||
-rw-r--r-- | 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 b8727b9681..630f58ac81 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 8d8f1188bd..ef95bd39cf 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 fb4bce9cd5..3dde8d7280 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 |