2014-03-21 14:05:29 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 2012, One Laptop Per Child.
|
|
|
|
* Copyright (C) 2014, Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author(s): Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*/
|
2014-04-09 16:27:50 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* GtkGestureSingle:
|
2014-04-09 16:27:50 +00:00
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* `GtkGestureSingle` is a `GtkGestures` subclass optimized for singe-touch
|
|
|
|
* and mouse gestures.
|
2014-04-09 16:27:50 +00:00
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* Under interaction, these gestures stick to the first interacting sequence,
|
|
|
|
* which is accessible through [method@Gtk.GestureSingle.get_current_sequence]
|
|
|
|
* while the gesture is being interacted with.
|
|
|
|
*
|
|
|
|
* By default gestures react to both %GDK_BUTTON_PRIMARY and touch events.
|
|
|
|
* [method@Gtk.GestureSingle.set_touch_only] can be used to change the
|
2014-08-11 19:43:58 +00:00
|
|
|
* touch behavior. Callers may also specify a different mouse button number
|
2021-03-01 06:46:48 +00:00
|
|
|
* to interact with through [method@Gtk.GestureSingle.set_button], or react
|
|
|
|
* to any mouse button by setting it to 0. While the gesture is active, the
|
|
|
|
* button being currently pressed can be known through
|
|
|
|
* [method@Gtk.GestureSingle.get_current_button].
|
2014-04-09 16:27:50 +00:00
|
|
|
*/
|
|
|
|
|
2014-03-21 14:05:29 +00:00
|
|
|
#include "config.h"
|
2014-05-06 02:40:18 +00:00
|
|
|
#include "gtkgesturesingle.h"
|
|
|
|
#include "gtkgesturesingleprivate.h"
|
2014-03-21 14:05:29 +00:00
|
|
|
#include "gtkprivate.h"
|
|
|
|
#include "gtkintl.h"
|
2014-07-10 14:10:11 +00:00
|
|
|
#include "gtkdebug.h"
|
2014-03-21 14:05:29 +00:00
|
|
|
|
|
|
|
typedef struct _GtkGestureSinglePrivate GtkGestureSinglePrivate;
|
|
|
|
|
|
|
|
struct _GtkGestureSinglePrivate
|
|
|
|
{
|
|
|
|
GdkEventSequence *current_sequence;
|
|
|
|
guint button;
|
|
|
|
guint current_button;
|
|
|
|
guint touch_only : 1;
|
2014-05-12 17:50:26 +00:00
|
|
|
guint exclusive : 1;
|
2014-03-21 14:05:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_TOUCH_ONLY = 1,
|
2014-05-12 17:50:26 +00:00
|
|
|
PROP_EXCLUSIVE,
|
2015-09-06 14:46:38 +00:00
|
|
|
PROP_BUTTON,
|
|
|
|
LAST_PROP
|
2014-03-21 14:05:29 +00:00
|
|
|
};
|
|
|
|
|
2015-09-06 14:46:38 +00:00
|
|
|
static GParamSpec *properties[LAST_PROP] = { NULL, };
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkGestureSingle, gtk_gesture_single, GTK_TYPE_GESTURE)
|
2014-03-21 14:05:29 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gesture_single_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
|
|
|
|
priv = gtk_gesture_single_get_instance_private (GTK_GESTURE_SINGLE (object));
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_TOUCH_ONLY:
|
|
|
|
g_value_set_boolean (value, priv->touch_only);
|
|
|
|
break;
|
2014-05-12 17:50:26 +00:00
|
|
|
case PROP_EXCLUSIVE:
|
|
|
|
g_value_set_boolean (value, priv->exclusive);
|
|
|
|
break;
|
2014-03-21 14:05:29 +00:00
|
|
|
case PROP_BUTTON:
|
|
|
|
g_value_set_uint (value, priv->button);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gesture_single_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_TOUCH_ONLY:
|
|
|
|
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (object),
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
2014-05-12 17:50:26 +00:00
|
|
|
case PROP_EXCLUSIVE:
|
|
|
|
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (object),
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
2014-03-21 14:05:29 +00:00
|
|
|
case PROP_BUTTON:
|
|
|
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (object),
|
|
|
|
g_value_get_uint (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-12 23:08:16 +00:00
|
|
|
gtk_gesture_single_cancel (GtkGesture *gesture,
|
|
|
|
GdkEventSequence *sequence)
|
2014-03-21 14:05:29 +00:00
|
|
|
{
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
|
2014-06-12 23:08:16 +00:00
|
|
|
priv = gtk_gesture_single_get_instance_private (GTK_GESTURE_SINGLE (gesture));
|
2014-03-21 14:05:29 +00:00
|
|
|
|
2014-06-12 23:08:16 +00:00
|
|
|
if (sequence == priv->current_sequence)
|
|
|
|
priv->current_button = 0;
|
2014-03-21 14:05:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_gesture_single_handle_event (GtkEventController *controller,
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event,
|
2020-02-13 05:08:49 +00:00
|
|
|
double x,
|
|
|
|
double y)
|
2014-03-21 14:05:29 +00:00
|
|
|
{
|
|
|
|
GdkEventSequence *sequence = NULL;
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
GdkDevice *source_device;
|
|
|
|
GdkInputSource source;
|
2017-08-25 14:47:11 +00:00
|
|
|
guint button = 0, state, i;
|
2014-08-11 19:43:58 +00:00
|
|
|
gboolean retval, test_touchscreen = FALSE;
|
2017-08-25 14:47:11 +00:00
|
|
|
GdkEventType event_type;
|
2014-03-21 14:05:29 +00:00
|
|
|
|
2020-07-28 22:03:48 +00:00
|
|
|
source_device = gdk_event_get_device (event);
|
2014-03-21 14:05:29 +00:00
|
|
|
|
|
|
|
if (!source_device)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
priv = gtk_gesture_single_get_instance_private (GTK_GESTURE_SINGLE (controller));
|
|
|
|
source = gdk_device_get_source (source_device);
|
|
|
|
|
2014-08-11 19:43:58 +00:00
|
|
|
if (source != GDK_SOURCE_TOUCHSCREEN)
|
2015-07-31 17:45:17 +00:00
|
|
|
test_touchscreen = gtk_simulate_touchscreen ();
|
2014-08-11 19:43:58 +00:00
|
|
|
|
2017-08-25 14:47:11 +00:00
|
|
|
event_type = gdk_event_get_event_type (event);
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
switch ((guint) event_type)
|
2014-03-21 14:05:29 +00:00
|
|
|
{
|
|
|
|
case GDK_TOUCH_BEGIN:
|
|
|
|
case GDK_TOUCH_END:
|
|
|
|
case GDK_TOUCH_UPDATE:
|
2020-02-18 03:11:56 +00:00
|
|
|
if (priv->exclusive && !gdk_touch_event_get_emulating_pointer (event))
|
2014-05-12 17:50:26 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2017-08-25 14:47:11 +00:00
|
|
|
sequence = gdk_event_get_event_sequence (event);
|
2014-03-21 14:05:29 +00:00
|
|
|
button = 1;
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2014-08-11 19:43:58 +00:00
|
|
|
if (priv->touch_only && !test_touchscreen && source != GDK_SOURCE_TOUCHSCREEN)
|
2014-03-21 14:05:29 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
button = gdk_button_event_get_button (event);
|
2014-03-21 14:05:29 +00:00
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2015-04-13 14:15:11 +00:00
|
|
|
if (!gtk_gesture_handles_sequence (GTK_GESTURE (controller), sequence))
|
|
|
|
return FALSE;
|
2014-08-11 19:43:58 +00:00
|
|
|
if (priv->touch_only && !test_touchscreen && source != GDK_SOURCE_TOUCHSCREEN)
|
2014-03-21 14:05:29 +00:00
|
|
|
return FALSE;
|
2020-02-18 03:11:56 +00:00
|
|
|
state = gdk_event_get_modifier_state (event);
|
2014-03-21 14:05:29 +00:00
|
|
|
|
|
|
|
if (priv->current_button > 0 && priv->current_button <= 5 &&
|
2017-08-25 14:47:11 +00:00
|
|
|
(state & (GDK_BUTTON1_MASK << (priv->current_button - 1))))
|
2014-03-21 14:05:29 +00:00
|
|
|
button = priv->current_button;
|
|
|
|
else if (priv->current_button == 0)
|
|
|
|
{
|
|
|
|
/* No current button, find out from the mask */
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
2017-08-25 14:47:11 +00:00
|
|
|
if ((state & (GDK_BUTTON1_MASK << i)) == 0)
|
2014-03-21 14:05:29 +00:00
|
|
|
continue;
|
|
|
|
button = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2021-06-28 15:51:17 +00:00
|
|
|
case GDK_TOUCHPAD_HOLD:
|
|
|
|
if (gdk_touchpad_event_get_n_fingers (event) == 1)
|
|
|
|
return FALSE;
|
2022-01-27 15:06:56 +00:00
|
|
|
G_GNUC_FALLTHROUGH;
|
2014-05-10 18:46:47 +00:00
|
|
|
case GDK_TOUCH_CANCEL:
|
|
|
|
case GDK_GRAB_BROKEN:
|
2017-03-02 17:14:00 +00:00
|
|
|
case GDK_TOUCHPAD_SWIPE:
|
2020-02-13 05:08:49 +00:00
|
|
|
return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_single_parent_class)->handle_event (controller, event, x, y);
|
2014-05-10 18:46:47 +00:00
|
|
|
break;
|
2014-03-21 14:05:29 +00:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button == 0 ||
|
|
|
|
(priv->button != 0 && priv->button != button) ||
|
|
|
|
(priv->current_button != 0 && priv->current_button != button))
|
|
|
|
{
|
|
|
|
if (gtk_gesture_is_active (GTK_GESTURE (controller)))
|
|
|
|
gtk_event_controller_reset (controller);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-08-25 14:47:11 +00:00
|
|
|
if (event_type == GDK_BUTTON_PRESS || event_type == GDK_TOUCH_BEGIN ||
|
|
|
|
event_type == GDK_MOTION_NOTIFY || event_type == GDK_TOUCH_UPDATE)
|
2014-03-21 14:05:29 +00:00
|
|
|
{
|
|
|
|
if (!gtk_gesture_is_active (GTK_GESTURE (controller)))
|
|
|
|
priv->current_sequence = sequence;
|
|
|
|
|
|
|
|
priv->current_button = button;
|
|
|
|
}
|
2014-06-11 15:34:23 +00:00
|
|
|
|
2020-02-13 05:08:49 +00:00
|
|
|
retval = GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_single_parent_class)->handle_event (controller, event, x, y);
|
2014-06-11 15:34:23 +00:00
|
|
|
|
|
|
|
if (sequence == priv->current_sequence &&
|
2017-08-25 14:47:11 +00:00
|
|
|
(event_type == GDK_BUTTON_RELEASE || event_type == GDK_TOUCH_END))
|
2014-03-21 14:05:29 +00:00
|
|
|
priv->current_button = 0;
|
2014-11-20 12:25:40 +00:00
|
|
|
else if (priv->current_sequence == sequence &&
|
|
|
|
!gtk_gesture_handles_sequence (GTK_GESTURE (controller), sequence))
|
2014-10-17 19:12:44 +00:00
|
|
|
{
|
2017-08-25 14:47:11 +00:00
|
|
|
if (button == priv->current_button && event_type == GDK_BUTTON_PRESS)
|
2014-10-17 19:12:44 +00:00
|
|
|
priv->current_button = 0;
|
2017-08-25 14:47:11 +00:00
|
|
|
else if (sequence == priv->current_sequence && event_type == GDK_TOUCH_BEGIN)
|
2014-10-17 19:12:44 +00:00
|
|
|
priv->current_sequence = NULL;
|
|
|
|
}
|
2014-03-21 14:05:29 +00:00
|
|
|
|
2014-06-11 15:34:23 +00:00
|
|
|
return retval;
|
2014-03-21 14:05:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gesture_single_class_init (GtkGestureSingleClass *klass)
|
|
|
|
{
|
|
|
|
GtkEventControllerClass *controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
|
2014-06-12 23:08:16 +00:00
|
|
|
GtkGestureClass *gesture_class = GTK_GESTURE_CLASS (klass);
|
2014-03-21 14:05:29 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->get_property = gtk_gesture_single_get_property;
|
|
|
|
object_class->set_property = gtk_gesture_single_set_property;
|
|
|
|
|
|
|
|
controller_class->handle_event = gtk_gesture_single_handle_event;
|
|
|
|
|
2014-06-12 23:08:16 +00:00
|
|
|
gesture_class->cancel = gtk_gesture_single_cancel;
|
|
|
|
|
2014-04-09 16:27:50 +00:00
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* GtkGestureSingle:touch-only: (attributes org.gtk.Property.get=gtk_gesture_single_get_touch_only org.gtk.Property.set=gtk_gesture_single_set_touch_only)
|
2014-04-09 16:27:50 +00:00
|
|
|
*
|
2014-05-20 02:16:03 +00:00
|
|
|
* Whether the gesture handles only touch events.
|
2014-04-09 16:27:50 +00:00
|
|
|
*/
|
2015-09-06 14:46:38 +00:00
|
|
|
properties[PROP_TOUCH_ONLY] =
|
|
|
|
g_param_spec_boolean ("touch-only",
|
|
|
|
P_("Handle only touch events"),
|
|
|
|
P_("Whether the gesture handles only touch events"),
|
|
|
|
FALSE,
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2014-06-09 12:57:10 +00:00
|
|
|
|
2014-05-12 17:50:26 +00:00
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* GtkGestureSingle:exclusive: (attributes org.gtk.Property.get=gtk_gesture_single_get_exclusive org.gtk.Property.set=gtk_gesture_single_set_exclusive)
|
|
|
|
*
|
|
|
|
* Whether the gesture is exclusive.
|
2014-05-12 17:50:26 +00:00
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* Exclusive gestures only listen to pointer and pointer emulated events.
|
2014-05-12 17:50:26 +00:00
|
|
|
*/
|
2015-09-06 14:46:38 +00:00
|
|
|
properties[PROP_EXCLUSIVE] =
|
|
|
|
g_param_spec_boolean ("exclusive",
|
|
|
|
P_("Whether the gesture is exclusive"),
|
|
|
|
P_("Whether the gesture is exclusive"),
|
|
|
|
FALSE,
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2014-06-09 12:57:10 +00:00
|
|
|
|
2014-04-09 16:27:50 +00:00
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* GtkGestureSingle:button: (attributes org.gtk.Property.get=gtk_gesture_single_get_button org.gtk.Property.set=gtk_gesture_single_set_button)
|
2014-04-09 16:27:50 +00:00
|
|
|
*
|
|
|
|
* Mouse button number to listen to, or 0 to listen for any button.
|
|
|
|
*/
|
2015-09-06 14:46:38 +00:00
|
|
|
properties[PROP_BUTTON] =
|
|
|
|
g_param_spec_uint ("button",
|
|
|
|
P_("Button number"),
|
|
|
|
P_("Button number to listen to"),
|
|
|
|
0, G_MAXUINT,
|
|
|
|
GDK_BUTTON_PRIMARY,
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
2014-03-21 14:05:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gesture_single_init (GtkGestureSingle *gesture)
|
|
|
|
{
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
|
|
|
|
priv = gtk_gesture_single_get_instance_private (gesture);
|
2014-08-11 19:43:58 +00:00
|
|
|
priv->touch_only = FALSE;
|
|
|
|
priv->button = GDK_BUTTON_PRIMARY;
|
2014-03-21 14:05:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* gtk_gesture_single_get_touch_only: (attributes org.gtk.Method.get_property=touch-only)
|
|
|
|
* @gesture: a `GtkGestureSingle`
|
2014-03-21 14:05:29 +00:00
|
|
|
*
|
2014-05-20 02:16:03 +00:00
|
|
|
* Returns %TRUE if the gesture is only triggered by touch events.
|
2014-03-21 14:05:29 +00:00
|
|
|
*
|
2014-05-20 02:16:03 +00:00
|
|
|
* Returns: %TRUE if the gesture only handles touch events
|
2021-03-01 06:46:48 +00:00
|
|
|
*/
|
2014-03-21 14:05:29 +00:00
|
|
|
gboolean
|
|
|
|
gtk_gesture_single_get_touch_only (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->touch_only;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* gtk_gesture_single_set_touch_only: (attributes org.gtk.Method.set_property=touch-only)
|
|
|
|
* @gesture: a `GtkGestureSingle`
|
2014-03-21 14:05:29 +00:00
|
|
|
* @touch_only: whether @gesture handles only touch events
|
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* Sets whether to handle only touch events.
|
|
|
|
*
|
2014-05-20 02:16:03 +00:00
|
|
|
* If @touch_only is %TRUE, @gesture will only handle events of type
|
2021-03-01 06:46:48 +00:00
|
|
|
* %GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE or %GDK_TOUCH_END. If %FALSE,
|
2014-03-21 14:05:29 +00:00
|
|
|
* mouse events will be handled too.
|
2021-03-01 06:46:48 +00:00
|
|
|
*/
|
2014-03-21 14:05:29 +00:00
|
|
|
void
|
|
|
|
gtk_gesture_single_set_touch_only (GtkGestureSingle *gesture,
|
|
|
|
gboolean touch_only)
|
|
|
|
{
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GESTURE_SINGLE (gesture));
|
|
|
|
|
|
|
|
touch_only = touch_only != FALSE;
|
|
|
|
priv = gtk_gesture_single_get_instance_private (gesture);
|
|
|
|
|
|
|
|
if (priv->touch_only == touch_only)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv->touch_only = touch_only;
|
2015-09-06 14:46:38 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (gesture), properties[PROP_TOUCH_ONLY]);
|
2014-03-21 14:05:29 +00:00
|
|
|
}
|
|
|
|
|
2014-05-12 17:50:26 +00:00
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* gtk_gesture_single_get_exclusive: (attributes org.gtk.Method.get_property=exclusive)
|
|
|
|
* @gesture: a `GtkGestureSingle`
|
|
|
|
*
|
|
|
|
* Gets whether a gesture is exclusive.
|
2014-05-12 17:50:26 +00:00
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* For more information, see [method@Gtk.GestureSingle.set_exclusive].
|
2014-05-12 17:50:26 +00:00
|
|
|
*
|
|
|
|
* Returns: Whether the gesture is exclusive
|
2021-03-01 06:46:48 +00:00
|
|
|
*/
|
2014-05-12 17:50:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* gtk_gesture_single_set_exclusive: (attributes org.gtk.Method.set_property=exclusive)
|
|
|
|
* @gesture: a `GtkGestureSingle`
|
2014-05-20 02:16:03 +00:00
|
|
|
* @exclusive: %TRUE to make @gesture exclusive
|
2014-05-12 17:50:26 +00:00
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2014-05-12 17:50:26 +00:00
|
|
|
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;
|
2015-09-06 14:46:38 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (gesture), properties[PROP_EXCLUSIVE]);
|
2014-05-12 17:50:26 +00:00
|
|
|
}
|
|
|
|
|
2014-03-21 14:05:29 +00:00
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* gtk_gesture_single_get_button: (attributes org.gtk.Method.get_property=button)
|
|
|
|
* @gesture: a `GtkGestureSingle`
|
|
|
|
*
|
|
|
|
* Returns the button number @gesture listens for.
|
2014-03-21 14:05:29 +00:00
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* If this is 0, the gesture reacts to any button press.
|
2014-03-21 14:05:29 +00:00
|
|
|
*
|
2014-05-20 02:16:03 +00:00
|
|
|
* Returns: The button number, or 0 for any button
|
2021-03-01 06:46:48 +00:00
|
|
|
*/
|
2014-03-21 14:05:29 +00:00
|
|
|
guint
|
|
|
|
gtk_gesture_single_get_button (GtkGestureSingle *gesture)
|
|
|
|
{
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GESTURE_SINGLE (gesture), 0);
|
|
|
|
|
|
|
|
priv = gtk_gesture_single_get_instance_private (gesture);
|
|
|
|
|
|
|
|
return priv->button;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-01 06:46:48 +00:00
|
|
|
* gtk_gesture_single_set_button: (attributes org.gtk.Method.set_property=button)
|
|
|
|
* @gesture: a `GtkGestureSingle`
|
2014-03-21 14:05:29 +00:00
|
|
|
* @button: button number to listen to, or 0 for any button
|
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* Sets the button number @gesture listens to.
|
|
|
|
*
|
|
|
|
* If non-0, every button press from a different button
|
|
|
|
* number will be ignored. Touch events implicitly match
|
|
|
|
* with button 1.
|
|
|
|
*/
|
2014-03-21 14:05:29 +00:00
|
|
|
void
|
|
|
|
gtk_gesture_single_set_button (GtkGestureSingle *gesture,
|
|
|
|
guint button)
|
|
|
|
{
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GESTURE_SINGLE (gesture));
|
|
|
|
|
|
|
|
priv = gtk_gesture_single_get_instance_private (gesture);
|
|
|
|
|
|
|
|
if (priv->button == button)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv->button = button;
|
2015-09-06 14:46:38 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (gesture), properties[PROP_BUTTON]);
|
2014-03-21 14:05:29 +00:00
|
|
|
}
|
|
|
|
|
2014-04-09 16:27:50 +00:00
|
|
|
/**
|
|
|
|
* gtk_gesture_single_get_current_button:
|
2021-03-01 06:46:48 +00:00
|
|
|
* @gesture: a `GtkGestureSingle`
|
2014-04-09 16:27:50 +00:00
|
|
|
*
|
2021-03-01 06:46:48 +00:00
|
|
|
* Returns the button number currently interacting
|
|
|
|
* with @gesture, or 0 if there is none.
|
2014-04-09 16:27:50 +00:00
|
|
|
*
|
|
|
|
* Returns: The current button number
|
2021-03-01 06:46:48 +00:00
|
|
|
*/
|
2014-03-21 14:05:29 +00:00
|
|
|
guint
|
|
|
|
gtk_gesture_single_get_current_button (GtkGestureSingle *gesture)
|
|
|
|
{
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GESTURE_SINGLE (gesture), 0);
|
|
|
|
|
|
|
|
priv = gtk_gesture_single_get_instance_private (gesture);
|
|
|
|
|
|
|
|
return priv->current_button;
|
|
|
|
}
|
|
|
|
|
2014-04-09 16:27:50 +00:00
|
|
|
/**
|
|
|
|
* gtk_gesture_single_get_current_sequence:
|
2021-03-01 06:46:48 +00:00
|
|
|
* @gesture: a `GtkGestureSingle`
|
2014-04-09 16:27:50 +00:00
|
|
|
*
|
2014-05-20 02:16:03 +00:00
|
|
|
* Returns the event sequence currently interacting with @gesture.
|
2021-03-01 06:46:48 +00:00
|
|
|
*
|
|
|
|
* This is only meaningful if [method@Gtk.Gesture.is_active]
|
|
|
|
* returns %TRUE.
|
2014-04-09 16:27:50 +00:00
|
|
|
*
|
2015-12-11 09:05:37 +00:00
|
|
|
* Returns: (nullable): the current sequence
|
2021-03-01 06:46:48 +00:00
|
|
|
*/
|
2014-03-21 14:05:29 +00:00
|
|
|
GdkEventSequence *
|
|
|
|
gtk_gesture_single_get_current_sequence (GtkGestureSingle *gesture)
|
|
|
|
{
|
|
|
|
GtkGestureSinglePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GESTURE_SINGLE (gesture), NULL);
|
|
|
|
|
|
|
|
priv = gtk_gesture_single_get_instance_private (gesture);
|
|
|
|
|
|
|
|
return priv->current_sequence;
|
|
|
|
}
|