2014-02-27 14:26:48 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* 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:28:03 +00:00
|
|
|
/**
|
2019-05-29 17:10:46 +00:00
|
|
|
* SECTION:gtkgestureclick
|
2014-04-09 16:28:03 +00:00
|
|
|
* @Short_description: Multipress gesture
|
2019-05-29 17:10:46 +00:00
|
|
|
* @Title: GtkGestureClick
|
2014-04-09 16:28:03 +00:00
|
|
|
*
|
2019-05-29 17:10:46 +00:00
|
|
|
* #GtkGestureClick is a #GtkGesture implementation able to recognize
|
|
|
|
* multiple clicks on a nearby zone, which can be listened for through
|
|
|
|
* the #GtkGestureClick::pressed signal. Whenever time or distance
|
|
|
|
* between clicks exceed the GTK+ defaults, #GtkGestureClick::stopped
|
|
|
|
* is emitted, and the click counter is reset.
|
2014-04-09 16:28:03 +00:00
|
|
|
*
|
|
|
|
* Callers may also restrict the area that is considered valid for a >1
|
2019-05-29 17:10:46 +00:00
|
|
|
* touch/button press through gtk_gesture_click_set_area(), so any
|
|
|
|
* click happening outside that area is considered to be a first click
|
|
|
|
* of its own.
|
2014-04-09 16:28:03 +00:00
|
|
|
*/
|
|
|
|
|
2014-02-27 14:26:48 +00:00
|
|
|
#include "config.h"
|
2014-05-06 16:04:25 +00:00
|
|
|
#include "gtkgestureprivate.h"
|
2019-05-29 17:10:46 +00:00
|
|
|
#include "gtkgestureclick.h"
|
|
|
|
#include "gtkgestureclickprivate.h"
|
2014-02-27 14:26:48 +00:00
|
|
|
#include "gtkprivate.h"
|
|
|
|
#include "gtkintl.h"
|
2019-06-02 21:07:27 +00:00
|
|
|
#include "gtkmarshalers.h"
|
2014-02-27 14:26:48 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
typedef struct _GtkGestureClickPrivate GtkGestureClickPrivate;
|
2014-02-27 14:26:48 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
struct _GtkGestureClickPrivate
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2016-02-22 21:38:56 +00:00
|
|
|
GdkDevice *current_device;
|
2020-07-24 20:32:16 +00:00
|
|
|
double initial_press_x;
|
|
|
|
double initial_press_y;
|
2014-02-27 14:26:48 +00:00
|
|
|
guint double_click_timeout_id;
|
|
|
|
guint n_presses;
|
2014-05-12 15:02:03 +00:00
|
|
|
guint n_release;
|
2014-02-27 14:26:48 +00:00
|
|
|
guint current_button;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PRESSED,
|
2014-05-12 15:02:03 +00:00
|
|
|
RELEASED,
|
2014-02-27 14:26:48 +00:00
|
|
|
STOPPED,
|
2017-11-21 19:14:52 +00:00
|
|
|
UNPAIRED_RELEASE,
|
2014-02-27 14:26:48 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkGestureClick, gtk_gesture_click, GTK_TYPE_GESTURE_SINGLE)
|
2014-02-27 14:26:48 +00:00
|
|
|
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_finalize (GObject *object)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClickPrivate *priv;
|
|
|
|
GtkGestureClick *gesture;
|
2014-02-27 14:26:48 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
gesture = GTK_GESTURE_CLICK (object);
|
|
|
|
priv = gtk_gesture_click_get_instance_private (gesture);
|
2014-02-27 14:26:48 +00:00
|
|
|
|
|
|
|
if (priv->double_click_timeout_id)
|
|
|
|
{
|
|
|
|
g_source_remove (priv->double_click_timeout_id);
|
|
|
|
priv->double_click_timeout_id = 0;
|
|
|
|
}
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
G_OBJECT_CLASS (gtk_gesture_click_parent_class)->finalize (object);
|
2014-02-27 14:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_check (GtkGesture *gesture)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClick *click;
|
|
|
|
GtkGestureClickPrivate *priv;
|
2014-02-27 14:26:48 +00:00
|
|
|
GList *sequences;
|
|
|
|
gboolean active;
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
click = GTK_GESTURE_CLICK (gesture);
|
|
|
|
priv = gtk_gesture_click_get_instance_private (click);
|
2014-02-27 14:26:48 +00:00
|
|
|
sequences = gtk_gesture_get_sequences (gesture);
|
|
|
|
|
2014-03-21 18:21:56 +00:00
|
|
|
active = g_list_length (sequences) == 1 || priv->double_click_timeout_id;
|
2014-02-27 14:26:48 +00:00
|
|
|
g_list_free (sequences);
|
|
|
|
|
|
|
|
return active;
|
|
|
|
}
|
|
|
|
|
2014-03-21 18:21:56 +00:00
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_stop (GtkGestureClick *gesture)
|
2014-03-21 18:21:56 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClickPrivate *priv;
|
2014-03-21 18:21:56 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
priv = gtk_gesture_click_get_instance_private (gesture);
|
2014-03-21 18:21:56 +00:00
|
|
|
|
|
|
|
if (priv->n_presses == 0)
|
|
|
|
return;
|
|
|
|
|
2016-02-22 21:38:56 +00:00
|
|
|
priv->current_device = NULL;
|
2014-03-21 18:21:56 +00:00
|
|
|
priv->current_button = 0;
|
|
|
|
priv->n_presses = 0;
|
2014-04-08 19:09:44 +00:00
|
|
|
g_signal_emit (gesture, signals[STOPPED], 0);
|
2014-05-06 16:04:25 +00:00
|
|
|
_gtk_gesture_check (GTK_GESTURE (gesture));
|
2014-03-21 18:21:56 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 14:26:48 +00:00
|
|
|
static gboolean
|
|
|
|
_double_click_timeout_cb (gpointer user_data)
|
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClick *gesture = user_data;
|
|
|
|
GtkGestureClickPrivate *priv;
|
2014-02-27 14:26:48 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
priv = gtk_gesture_click_get_instance_private (gesture);
|
2014-02-27 14:26:48 +00:00
|
|
|
priv->double_click_timeout_id = 0;
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_stop (gesture);
|
2014-02-27 14:26:48 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_update_timeout (GtkGestureClick *gesture)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClickPrivate *priv;
|
2014-02-27 14:26:48 +00:00
|
|
|
guint double_click_time;
|
|
|
|
GtkSettings *settings;
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
priv = gtk_gesture_click_get_instance_private (gesture);
|
2014-02-27 14:26:48 +00:00
|
|
|
|
|
|
|
if (priv->double_click_timeout_id)
|
|
|
|
g_source_remove (priv->double_click_timeout_id);
|
|
|
|
|
|
|
|
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
|
|
|
settings = gtk_widget_get_settings (widget);
|
|
|
|
g_object_get (settings, "gtk-double-click-time", &double_click_time, NULL);
|
|
|
|
|
2018-02-02 14:51:47 +00:00
|
|
|
priv->double_click_timeout_id = g_timeout_add (double_click_time, _double_click_timeout_cb, gesture);
|
2019-02-05 10:26:20 +00:00
|
|
|
g_source_set_name_by_id (priv->double_click_timeout_id, "[gtk] _double_click_timeout_cb");
|
2014-02-27 14:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_check_within_threshold (GtkGestureClick *gesture,
|
|
|
|
double x,
|
|
|
|
double y)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClickPrivate *priv;
|
2014-02-27 14:26:48 +00:00
|
|
|
guint double_click_distance;
|
|
|
|
GtkSettings *settings;
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
priv = gtk_gesture_click_get_instance_private (gesture);
|
2014-02-27 14:26:48 +00:00
|
|
|
|
|
|
|
if (priv->n_presses == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
|
|
|
settings = gtk_widget_get_settings (widget);
|
|
|
|
g_object_get (settings,
|
|
|
|
"gtk-double-click-distance", &double_click_distance,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (ABS (priv->initial_press_x - x) < double_click_distance &&
|
|
|
|
ABS (priv->initial_press_y - y) < double_click_distance)
|
2020-05-06 18:19:50 +00:00
|
|
|
return TRUE;
|
2014-02-27 14:26:48 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_begin (GtkGesture *gesture,
|
|
|
|
GdkEventSequence *sequence)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClick *click;
|
|
|
|
GtkGestureClickPrivate *priv;
|
2014-02-27 14:26:48 +00:00
|
|
|
guint n_presses, button = 1;
|
2014-05-12 14:56:41 +00:00
|
|
|
GdkEventSequence *current;
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event;
|
2017-08-25 14:47:11 +00:00
|
|
|
GdkEventType event_type;
|
2016-02-22 21:38:56 +00:00
|
|
|
GdkDevice *device;
|
2020-07-24 20:32:16 +00:00
|
|
|
double x, y;
|
2014-02-27 14:26:48 +00:00
|
|
|
|
2014-05-12 14:56:41 +00:00
|
|
|
if (!gtk_gesture_handles_sequence (gesture, sequence))
|
|
|
|
return;
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
click = GTK_GESTURE_CLICK (gesture);
|
|
|
|
priv = gtk_gesture_click_get_instance_private (click);
|
2014-02-27 14:26:48 +00:00
|
|
|
event = gtk_gesture_get_last_event (gesture, sequence);
|
2014-05-12 14:56:41 +00:00
|
|
|
current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
2020-07-28 22:03:48 +00:00
|
|
|
device = gdk_event_get_device (event);
|
2017-08-25 14:47:11 +00:00
|
|
|
event_type = gdk_event_get_event_type (event);
|
2014-02-27 14:26:48 +00:00
|
|
|
|
2017-08-25 14:47:11 +00:00
|
|
|
if (event_type == GDK_BUTTON_PRESS)
|
2020-02-18 03:11:56 +00:00
|
|
|
button = gdk_button_event_get_button (event);
|
2017-08-25 14:47:11 +00:00
|
|
|
else if (event_type == GDK_TOUCH_BEGIN)
|
2014-05-12 14:56:41 +00:00
|
|
|
button = 1;
|
|
|
|
else
|
2014-03-21 18:21:56 +00:00
|
|
|
return;
|
|
|
|
|
2014-05-12 14:56:41 +00:00
|
|
|
/* Reset the gesture if the button number changes mid-recognition */
|
|
|
|
if (priv->n_presses > 0 &&
|
|
|
|
priv->current_button != button)
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_stop (click);
|
2014-05-12 14:56:41 +00:00
|
|
|
|
2016-02-22 21:38:56 +00:00
|
|
|
/* Reset also if the device changed */
|
|
|
|
if (priv->current_device && priv->current_device != device)
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_stop (click);
|
2016-02-22 21:38:56 +00:00
|
|
|
|
|
|
|
priv->current_device = device;
|
2014-05-12 14:56:41 +00:00
|
|
|
priv->current_button = button;
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_update_timeout (click);
|
2014-05-12 14:56:41 +00:00
|
|
|
gtk_gesture_get_point (gesture, current, &x, &y);
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
if (!_gtk_gesture_click_check_within_threshold (click, x, y))
|
|
|
|
_gtk_gesture_click_stop (click);
|
2014-05-12 14:56:41 +00:00
|
|
|
|
|
|
|
/* Increment later the real counter, just if the gesture is
|
|
|
|
* reset on the pressed handler */
|
2014-05-12 15:02:03 +00:00
|
|
|
n_presses = priv->n_release = priv->n_presses + 1;
|
2014-05-12 14:56:41 +00:00
|
|
|
|
|
|
|
g_signal_emit (gesture, signals[PRESSED], 0, n_presses, x, y);
|
|
|
|
|
|
|
|
if (priv->n_presses == 0)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2014-05-12 14:56:41 +00:00
|
|
|
priv->initial_press_x = x;
|
|
|
|
priv->initial_press_y = y;
|
2014-02-27 14:26:48 +00:00
|
|
|
}
|
2014-05-12 14:56:41 +00:00
|
|
|
|
|
|
|
priv->n_presses++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_update (GtkGesture *gesture,
|
|
|
|
GdkEventSequence *sequence)
|
2014-05-12 14:56:41 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClick *click;
|
2014-05-12 14:56:41 +00:00
|
|
|
GdkEventSequence *current;
|
2020-07-24 20:32:16 +00:00
|
|
|
double x, y;
|
2014-05-12 14:56:41 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
click = GTK_GESTURE_CLICK (gesture);
|
2014-05-12 14:56:41 +00:00
|
|
|
current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
gtk_gesture_get_point (gesture, current, &x, &y);
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
if (!_gtk_gesture_click_check_within_threshold (click, x, y))
|
|
|
|
_gtk_gesture_click_stop (click);
|
2014-05-12 14:56:41 +00:00
|
|
|
}
|
|
|
|
|
2014-05-12 15:02:03 +00:00
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_end (GtkGesture *gesture,
|
|
|
|
GdkEventSequence *sequence)
|
2014-05-12 15:02:03 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClick *click;
|
|
|
|
GtkGestureClickPrivate *priv;
|
2014-05-12 15:02:03 +00:00
|
|
|
GdkEventSequence *current;
|
2020-07-24 20:32:16 +00:00
|
|
|
double x, y;
|
2018-05-29 11:43:06 +00:00
|
|
|
gboolean interpreted;
|
|
|
|
GtkEventSequenceState state;
|
2014-05-12 14:56:41 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
click = GTK_GESTURE_CLICK (gesture);
|
|
|
|
priv = gtk_gesture_click_get_instance_private (click);
|
2014-05-12 15:02:03 +00:00
|
|
|
current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
2018-05-29 11:43:06 +00:00
|
|
|
interpreted = gtk_gesture_get_point (gesture, current, &x, &y);
|
|
|
|
state = gtk_gesture_get_sequence_state (gesture, current);
|
2014-05-12 15:02:03 +00:00
|
|
|
|
2018-05-29 11:43:06 +00:00
|
|
|
if (state != GTK_EVENT_SEQUENCE_DENIED && interpreted)
|
2018-01-22 14:20:14 +00:00
|
|
|
g_signal_emit (gesture, signals[RELEASED], 0, priv->n_release, x, y);
|
|
|
|
|
2014-05-12 15:02:03 +00:00
|
|
|
priv->n_release = 0;
|
2014-02-27 14:26:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-24 11:21:38 +00:00
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_cancel (GtkGesture *gesture,
|
|
|
|
GdkEventSequence *sequence)
|
2014-03-24 11:21:38 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_stop (GTK_GESTURE_CLICK (gesture));
|
|
|
|
GTK_GESTURE_CLASS (gtk_gesture_click_parent_class)->cancel (gesture, sequence);
|
2014-03-24 11:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_reset (GtkEventController *controller)
|
2014-03-24 11:21:38 +00:00
|
|
|
{
|
2019-05-29 17:10:46 +00:00
|
|
|
_gtk_gesture_click_stop (GTK_GESTURE_CLICK (controller));
|
|
|
|
GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_click_parent_class)->reset (controller);
|
2014-03-24 11:21:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-21 19:14:52 +00:00
|
|
|
static gboolean
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_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)
|
2017-11-21 19:14:52 +00:00
|
|
|
{
|
|
|
|
GtkEventControllerClass *parent_controller;
|
2019-05-29 17:10:46 +00:00
|
|
|
GtkGestureClickPrivate *priv;
|
2017-11-21 19:14:52 +00:00
|
|
|
GdkEventSequence *sequence;
|
|
|
|
guint button;
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
priv = gtk_gesture_click_get_instance_private (GTK_GESTURE_CLICK (controller));
|
|
|
|
parent_controller = GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_click_parent_class);
|
2017-11-21 19:14:52 +00:00
|
|
|
sequence = gdk_event_get_event_sequence (event);
|
|
|
|
|
|
|
|
if (priv->n_presses == 0 &&
|
|
|
|
!gtk_gesture_handles_sequence (GTK_GESTURE (controller), sequence) &&
|
|
|
|
(gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE ||
|
|
|
|
gdk_event_get_event_type (event) == GDK_TOUCH_END))
|
|
|
|
{
|
2020-02-18 03:11:56 +00:00
|
|
|
if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE)
|
|
|
|
button = gdk_button_event_get_button (event);
|
|
|
|
else
|
2017-11-21 19:14:52 +00:00
|
|
|
button = 0;
|
|
|
|
g_signal_emit (controller, signals[UNPAIRED_RELEASE], 0,
|
|
|
|
x, y, button, sequence);
|
|
|
|
}
|
|
|
|
|
2020-02-13 05:08:49 +00:00
|
|
|
return parent_controller->handle_event (controller, event, x, y);
|
2017-11-21 19:14:52 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 14:26:48 +00:00
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_class_init (GtkGestureClickClass *klass)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2014-03-24 11:21:38 +00:00
|
|
|
GtkEventControllerClass *controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
|
2014-02-27 14:26:48 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkGestureClass *gesture_class = GTK_GESTURE_CLASS (klass);
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
object_class->finalize = gtk_gesture_click_finalize;
|
2014-02-27 14:26:48 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
gesture_class->check = gtk_gesture_click_check;
|
|
|
|
gesture_class->begin = gtk_gesture_click_begin;
|
|
|
|
gesture_class->update = gtk_gesture_click_update;
|
|
|
|
gesture_class->end = gtk_gesture_click_end;
|
|
|
|
gesture_class->cancel = gtk_gesture_click_cancel;
|
2014-03-24 11:21:38 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
controller_class->reset = gtk_gesture_click_reset;
|
|
|
|
controller_class->handle_event = gtk_gesture_click_handle_event;
|
2014-02-27 14:26:48 +00:00
|
|
|
|
2014-04-09 16:28:03 +00:00
|
|
|
/**
|
2019-05-29 17:10:46 +00:00
|
|
|
* GtkGestureClick::pressed:
|
2014-04-09 16:28:03 +00:00
|
|
|
* @gesture: the object which received the signal
|
|
|
|
* @n_press: how many touch/button presses happened with this one
|
|
|
|
* @x: The X coordinate, in widget allocation coordinates
|
|
|
|
* @y: The Y coordinate, in widget allocation coordinates
|
|
|
|
*
|
|
|
|
* This signal is emitted whenever a button or touch press happens.
|
|
|
|
*/
|
2014-02-27 14:26:48 +00:00
|
|
|
signals[PRESSED] =
|
2015-09-12 13:13:00 +00:00
|
|
|
g_signal_new (I_("pressed"),
|
2014-02-27 14:26:48 +00:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2019-05-29 17:10:46 +00:00
|
|
|
G_STRUCT_OFFSET (GtkGestureClickClass, pressed),
|
2019-06-02 21:07:27 +00:00
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__INT_DOUBLE_DOUBLE,
|
2014-05-12 15:02:03 +00:00
|
|
|
G_TYPE_NONE, 3, G_TYPE_INT,
|
|
|
|
G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
2019-06-02 21:07:27 +00:00
|
|
|
g_signal_set_va_marshaller (signals[PRESSED],
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
_gtk_marshal_VOID__INT_DOUBLE_DOUBLEv);
|
2014-05-12 15:02:03 +00:00
|
|
|
|
|
|
|
/**
|
2019-05-29 17:10:46 +00:00
|
|
|
* GtkGestureClick::released:
|
2014-05-12 15:02:03 +00:00
|
|
|
* @gesture: the object which received the signal
|
|
|
|
* @n_press: number of press that is paired with this release
|
|
|
|
* @x: The X coordinate, in widget allocation coordinates
|
|
|
|
* @y: The Y coordinate, in widget allocation coordinates
|
|
|
|
*
|
|
|
|
* This signal is emitted when a button or touch is released. @n_press
|
|
|
|
* will report the number of press that is paired to this event, note
|
2019-05-29 17:10:46 +00:00
|
|
|
* that #GtkGestureClick::stopped may have been emitted between the
|
2014-05-12 15:02:03 +00:00
|
|
|
* press and its release, @n_press will only start over at the next press.
|
|
|
|
*/
|
|
|
|
signals[RELEASED] =
|
2015-09-12 13:13:00 +00:00
|
|
|
g_signal_new (I_("released"),
|
2014-05-12 15:02:03 +00:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2019-05-29 17:10:46 +00:00
|
|
|
G_STRUCT_OFFSET (GtkGestureClickClass, released),
|
2019-06-02 21:07:27 +00:00
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__INT_DOUBLE_DOUBLE,
|
2014-03-24 11:21:38 +00:00
|
|
|
G_TYPE_NONE, 3, G_TYPE_INT,
|
2014-02-27 14:26:48 +00:00
|
|
|
G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
2019-06-02 21:07:27 +00:00
|
|
|
g_signal_set_va_marshaller (signals[RELEASED],
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
_gtk_marshal_VOID__INT_DOUBLE_DOUBLEv);
|
2014-04-09 16:28:03 +00:00
|
|
|
/**
|
2019-05-29 17:10:46 +00:00
|
|
|
* GtkGestureClick::stopped:
|
2014-04-09 16:28:03 +00:00
|
|
|
* @gesture: the object which received the signal
|
|
|
|
*
|
|
|
|
* This signal is emitted whenever any time/distance threshold has
|
|
|
|
* been exceeded.
|
|
|
|
*/
|
2014-02-27 14:26:48 +00:00
|
|
|
signals[STOPPED] =
|
2015-09-12 13:13:00 +00:00
|
|
|
g_signal_new (I_("stopped"),
|
2014-02-27 14:26:48 +00:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2019-05-29 17:10:46 +00:00
|
|
|
G_STRUCT_OFFSET (GtkGestureClickClass, stopped),
|
2014-02-27 14:26:48 +00:00
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
2017-11-21 19:14:52 +00:00
|
|
|
|
|
|
|
/**
|
2019-05-29 17:10:46 +00:00
|
|
|
* GtkGestureClick::unpaired-release
|
2017-11-21 19:14:52 +00:00
|
|
|
* @gesture: the object which received the signal
|
|
|
|
* @x: X coordinate of the event
|
|
|
|
* @y: Y coordinate of the event
|
|
|
|
* @button: Button being released
|
|
|
|
* @sequence: Sequence being released
|
|
|
|
*
|
|
|
|
* This signal is emitted whenever the gesture receives a release
|
|
|
|
* event that had no previous corresponding press. Due to implicit
|
|
|
|
* grabs, this can only happen on situations where input is grabbed
|
|
|
|
* elsewhere mid-press or the pressed widget voluntarily relinquishes
|
|
|
|
* its implicit grab.
|
|
|
|
*/
|
|
|
|
signals[UNPAIRED_RELEASE] =
|
|
|
|
g_signal_new (I_("unpaired-release"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2019-06-02 21:07:27 +00:00
|
|
|
0, NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLE_UINT_BOXED,
|
2017-11-21 19:14:52 +00:00
|
|
|
G_TYPE_NONE, 4,
|
|
|
|
G_TYPE_DOUBLE, G_TYPE_DOUBLE,
|
|
|
|
G_TYPE_UINT, GDK_TYPE_EVENT_SEQUENCE);
|
2019-06-02 21:07:27 +00:00
|
|
|
g_signal_set_va_marshaller (signals[UNPAIRED_RELEASE],
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLE_UINT_BOXEDv);
|
2014-02-27 14:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_init (GtkGestureClick *gesture)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-05-29 17:10:46 +00:00
|
|
|
* gtk_gesture_click_new:
|
2014-02-27 14:26:48 +00:00
|
|
|
*
|
|
|
|
* Returns a newly created #GtkGesture that recognizes single and multiple
|
|
|
|
* presses.
|
|
|
|
*
|
2019-05-29 17:10:46 +00:00
|
|
|
* Returns: a newly created #GtkGestureClick
|
2014-02-27 14:26:48 +00:00
|
|
|
**/
|
|
|
|
GtkGesture *
|
2019-05-29 17:10:46 +00:00
|
|
|
gtk_gesture_click_new (void)
|
2014-02-27 14:26:48 +00:00
|
|
|
{
|
2020-05-06 18:19:50 +00:00
|
|
|
return g_object_new (GTK_TYPE_GESTURE_CLICK, NULL);
|
2014-02-27 14:26:48 +00:00
|
|
|
}
|