2018-02-01 16:52:40 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 2017-2018, 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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-03-01 06:48:22 +00:00
|
|
|
* GtkGestureStylus:
|
2018-02-01 16:52:40 +00:00
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* `GtkGestureStylus` is a `GtkGesture` specific to stylus input.
|
|
|
|
*
|
|
|
|
* The provided signals just relay the basic information of the
|
2020-12-16 15:29:41 +00:00
|
|
|
* stylus events.
|
2018-02-01 16:52:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "gtkgesturestylus.h"
|
|
|
|
#include "gtkgesturestylusprivate.h"
|
|
|
|
#include "gtkprivate.h"
|
2019-06-02 21:07:27 +00:00
|
|
|
#include "gtkmarshalers.h"
|
2018-02-01 16:52:40 +00:00
|
|
|
#include "gtkmain.h"
|
2020-12-24 18:55:39 +00:00
|
|
|
#include "gtknative.h"
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkGestureStylus, gtk_gesture_stylus, GTK_TYPE_GESTURE_SINGLE)
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROXIMITY,
|
|
|
|
DOWN,
|
|
|
|
MOTION,
|
|
|
|
UP,
|
|
|
|
N_SIGNALS
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[N_SIGNALS] = { 0, };
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_gesture_stylus_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)
|
2018-02-01 16:52:40 +00:00
|
|
|
{
|
|
|
|
GdkModifierType modifiers;
|
|
|
|
guint n_signal;
|
|
|
|
|
2020-02-13 05:08:49 +00:00
|
|
|
GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_stylus_parent_class)->handle_event (controller, event, x, y);
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
if (!gdk_event_get_device_tool (event))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch ((guint) gdk_event_get_event_type (event))
|
|
|
|
{
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
n_signal = DOWN;
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
n_signal = UP;
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2020-02-18 03:11:56 +00:00
|
|
|
modifiers = gdk_event_get_modifier_state (event);
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
if (modifiers & GDK_BUTTON1_MASK)
|
|
|
|
n_signal = MOTION;
|
|
|
|
else
|
|
|
|
n_signal = PROXIMITY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_emit (controller, signals[n_signal], 0, x, y);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gesture_stylus_class_init (GtkGestureStylusClass *klass)
|
|
|
|
{
|
|
|
|
GtkEventControllerClass *event_controller_class;
|
|
|
|
|
|
|
|
event_controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
|
|
|
|
event_controller_class->handle_event = gtk_gesture_stylus_handle_event;
|
|
|
|
|
2020-12-16 15:29:41 +00:00
|
|
|
/**
|
|
|
|
* GtkGestureStylus::proximity:
|
2021-03-01 06:48:22 +00:00
|
|
|
* @gesture: the `GtkGestureStylus` that emitted the signal
|
2020-12-16 15:29:41 +00:00
|
|
|
* @x: the X coordinate of the stylus event
|
|
|
|
* @y: the Y coordinate of the stylus event
|
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* Emitted when the stylus is in proximity of the device.
|
2020-12-16 15:29:41 +00:00
|
|
|
*/
|
2018-02-01 16:52:40 +00:00
|
|
|
signals[PROXIMITY] =
|
|
|
|
g_signal_new (I_("proximity"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkGestureStylusClass, proximity),
|
2019-06-02 21:07:27 +00:00
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLE,
|
2018-02-01 16:52:40 +00:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
2019-06-02 21:07:27 +00:00
|
|
|
g_signal_set_va_marshaller (signals[PROXIMITY],
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLEv);
|
|
|
|
|
2020-12-16 15:29:41 +00:00
|
|
|
/**
|
|
|
|
* GtkGestureStylus::down:
|
2021-03-01 06:48:22 +00:00
|
|
|
* @gesture: the `GtkGestureStylus` that emitted the signal
|
2020-12-16 15:29:41 +00:00
|
|
|
* @x: the X coordinate of the stylus event
|
|
|
|
* @y: the Y coordinate of the stylus event
|
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* Emitted when the stylus touches the device.
|
2020-12-16 15:29:41 +00:00
|
|
|
*/
|
2018-02-01 16:52:40 +00:00
|
|
|
signals[DOWN] =
|
|
|
|
g_signal_new (I_("down"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkGestureStylusClass, down),
|
2019-06-02 21:07:27 +00:00
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLE,
|
2018-02-01 16:52:40 +00:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
2019-06-02 21:07:27 +00:00
|
|
|
g_signal_set_va_marshaller (signals[DOWN],
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLEv);
|
|
|
|
|
2020-12-16 15:29:41 +00:00
|
|
|
/**
|
|
|
|
* GtkGestureStylus::motion:
|
2021-03-01 06:48:22 +00:00
|
|
|
* @gesture: the `GtkGestureStylus` that emitted the signal
|
2020-12-16 15:29:41 +00:00
|
|
|
* @x: the X coordinate of the stylus event
|
|
|
|
* @y: the Y coordinate of the stylus event
|
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* Emitted when the stylus moves while touching the device.
|
2020-12-16 15:29:41 +00:00
|
|
|
*/
|
2018-02-01 16:52:40 +00:00
|
|
|
signals[MOTION] =
|
|
|
|
g_signal_new (I_("motion"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkGestureStylusClass, motion),
|
2019-06-02 21:07:27 +00:00
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLE,
|
2018-02-01 16:52:40 +00:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
2019-06-02 21:07:27 +00:00
|
|
|
g_signal_set_va_marshaller (signals[MOTION],
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLEv);
|
|
|
|
|
2020-12-16 15:29:41 +00:00
|
|
|
/**
|
|
|
|
* GtkGestureStylus::up:
|
2021-03-01 06:48:22 +00:00
|
|
|
* @gesture: the `GtkGestureStylus` that emitted the signal
|
2020-12-16 15:29:41 +00:00
|
|
|
* @x: the X coordinate of the stylus event
|
|
|
|
* @y: the Y coordinate of the stylus event
|
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* Emitted when the stylus no longer touches the device.
|
2020-12-16 15:29:41 +00:00
|
|
|
*/
|
2018-02-01 16:52:40 +00:00
|
|
|
signals[UP] =
|
|
|
|
g_signal_new (I_("up"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkGestureStylusClass, up),
|
2019-06-02 21:07:27 +00:00
|
|
|
NULL, NULL,
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLE,
|
2018-02-01 16:52:40 +00:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
2019-06-02 21:07:27 +00:00
|
|
|
g_signal_set_va_marshaller (signals[UP],
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
_gtk_marshal_VOID__DOUBLE_DOUBLEv);
|
2018-02-01 16:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gesture_stylus_init (GtkGestureStylus *gesture)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_gesture_stylus_new:
|
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* Creates a new `GtkGestureStylus`.
|
2018-02-01 16:52:40 +00:00
|
|
|
*
|
|
|
|
* Returns: a newly created stylus gesture
|
|
|
|
**/
|
|
|
|
GtkGesture *
|
2018-04-26 15:32:43 +00:00
|
|
|
gtk_gesture_stylus_new (void)
|
2018-02-01 16:52:40 +00:00
|
|
|
{
|
|
|
|
return g_object_new (GTK_TYPE_GESTURE_STYLUS,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_gesture_stylus_get_axis:
|
2021-03-01 06:48:22 +00:00
|
|
|
* @gesture: a `GtkGestureStylus`
|
2018-02-01 16:52:40 +00:00
|
|
|
* @axis: requested device axis
|
|
|
|
* @value: (out): return location for the axis value
|
|
|
|
*
|
2020-12-16 15:29:41 +00:00
|
|
|
* Returns the current value for the requested @axis.
|
|
|
|
*
|
|
|
|
* This function must be called from the handler of one of the
|
2021-03-01 06:48:22 +00:00
|
|
|
* [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion],
|
|
|
|
* [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity]
|
|
|
|
* signals.
|
2018-02-01 16:52:40 +00:00
|
|
|
*
|
2020-12-16 15:29:41 +00:00
|
|
|
* Returns: %TRUE if there is a current value for the axis
|
2018-02-01 16:52:40 +00:00
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_gesture_stylus_get_axis (GtkGestureStylus *gesture,
|
|
|
|
GdkAxisUse axis,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *value)
|
2018-02-01 16:52:40 +00:00
|
|
|
{
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event;
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
|
|
|
|
g_return_val_if_fail (axis < GDK_AXIS_LAST, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
2021-12-02 16:00:10 +00:00
|
|
|
event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
|
2018-02-01 16:52:40 +00:00
|
|
|
if (!event)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return gdk_event_get_axis (event, axis, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_gesture_stylus_get_axes:
|
2021-03-01 06:48:22 +00:00
|
|
|
* @gesture: a `GtkGestureStylus`
|
|
|
|
* @axes: (array): array of requested axes, terminated with %GDK_AXIS_IGNORE
|
2018-08-20 14:57:54 +00:00
|
|
|
* @values: (out) (array): return location for the axis values
|
2018-02-01 16:52:40 +00:00
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* Returns the current values for the requested @axes.
|
|
|
|
*
|
|
|
|
* This function must be called from the handler of one of the
|
|
|
|
* [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion],
|
|
|
|
* [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity]
|
2018-02-01 16:52:40 +00:00
|
|
|
* signals.
|
|
|
|
*
|
2020-12-16 15:29:41 +00:00
|
|
|
* Returns: %TRUE if there is a current value for the axes
|
2021-03-01 06:48:22 +00:00
|
|
|
*/
|
2018-02-01 16:52:40 +00:00
|
|
|
gboolean
|
|
|
|
gtk_gesture_stylus_get_axes (GtkGestureStylus *gesture,
|
|
|
|
GdkAxisUse axes[],
|
2020-07-24 20:32:16 +00:00
|
|
|
double **values)
|
2018-02-01 16:52:40 +00:00
|
|
|
{
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event;
|
2018-02-01 16:52:40 +00:00
|
|
|
GArray *array;
|
2020-07-24 13:54:49 +00:00
|
|
|
int i = 0;
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
|
|
|
|
g_return_val_if_fail (values != NULL, FALSE);
|
|
|
|
|
2021-12-02 16:00:10 +00:00
|
|
|
event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
|
2018-02-01 16:52:40 +00:00
|
|
|
if (!event)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
array = g_array_new (TRUE, FALSE, sizeof (double));
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
while (axes[i] != GDK_AXIS_IGNORE)
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double value;
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
if (axes[i] >= GDK_AXIS_LAST)
|
|
|
|
{
|
|
|
|
g_warning ("Requesting unknown axis %d, did you "
|
|
|
|
"forget to add a last GDK_AXIS_IGNORE axis?",
|
|
|
|
axes[i]);
|
|
|
|
g_array_free (array, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_event_get_axis (event, axes[i], &value);
|
|
|
|
g_array_append_val (array, value);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
*values = (double *) g_array_free (array, FALSE);
|
2018-02-01 16:52:40 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_gesture_stylus_get_backlog:
|
2021-03-01 06:48:22 +00:00
|
|
|
* @gesture: a `GtkGestureStylus`
|
2018-04-06 14:20:48 +00:00
|
|
|
* @backlog: (out) (array length=n_elems): coordinates and times for the backlog events
|
2018-02-01 16:52:40 +00:00
|
|
|
* @n_elems: (out): return location for the number of elements
|
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* Returns the accumulated backlog of tracking information.
|
|
|
|
*
|
|
|
|
* By default, GTK will limit rate of input events. On stylus input
|
|
|
|
* where accuracy of strokes is paramount, this function returns the
|
|
|
|
* accumulated coordinate/timing state before the emission of the
|
|
|
|
* current [Gtk.GestureStylus::motion] signal.
|
2018-02-01 16:52:40 +00:00
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* This function may only be called within a [signal@Gtk.GestureStylus::motion]
|
2018-02-01 16:52:40 +00:00
|
|
|
* signal handler, the state given in this signal and obtainable through
|
2021-03-01 06:48:22 +00:00
|
|
|
* [method@Gtk.GestureStylus.get_axis] express the latest (most up-to-date)
|
2018-02-01 16:52:40 +00:00
|
|
|
* state in motion history.
|
|
|
|
*
|
2020-12-16 15:29:41 +00:00
|
|
|
* The @backlog is provided in chronological order.
|
2018-02-01 16:52:40 +00:00
|
|
|
*
|
2020-12-16 15:29:41 +00:00
|
|
|
* Returns: %TRUE if there is a backlog to unfold in the current state.
|
2021-03-01 06:48:22 +00:00
|
|
|
*/
|
2018-02-01 16:52:40 +00:00
|
|
|
gboolean
|
|
|
|
gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture,
|
2020-06-09 17:40:26 +00:00
|
|
|
GdkTimeCoord **backlog,
|
|
|
|
guint *n_elems)
|
2018-02-01 16:52:40 +00:00
|
|
|
{
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event;
|
2018-02-01 16:52:40 +00:00
|
|
|
GArray *backlog_array;
|
2020-04-25 15:50:11 +00:00
|
|
|
GdkTimeCoord *history = NULL;
|
|
|
|
guint n_coords = 0, i;
|
2020-12-24 18:55:39 +00:00
|
|
|
double surf_x, surf_y;
|
|
|
|
GtkNative *native;
|
2020-12-25 08:58:04 +00:00
|
|
|
GtkWidget *event_widget;
|
|
|
|
GtkWidget *controller_widget;
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
|
|
|
|
g_return_val_if_fail (backlog != NULL && n_elems != NULL, FALSE);
|
|
|
|
|
2021-12-02 16:00:10 +00:00
|
|
|
event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
|
2018-02-01 16:52:40 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
if (event && GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY))
|
2020-06-09 17:40:26 +00:00
|
|
|
history = gdk_event_get_history (event, &n_coords);
|
2020-04-25 15:50:11 +00:00
|
|
|
|
2018-02-01 16:52:40 +00:00
|
|
|
if (!history)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-12-24 18:55:39 +00:00
|
|
|
native = gtk_widget_get_native (gtk_get_event_widget (event));
|
|
|
|
gtk_native_get_surface_transform (native, &surf_x, &surf_y);
|
|
|
|
|
2018-02-01 16:52:40 +00:00
|
|
|
backlog_array = g_array_new (FALSE, FALSE, sizeof (GdkTimeCoord));
|
2020-12-25 08:58:04 +00:00
|
|
|
event_widget = gtk_get_event_widget (event);
|
|
|
|
controller_widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
2020-04-25 15:50:11 +00:00
|
|
|
for (i = 0; i < n_coords; i++)
|
2018-02-01 16:52:40 +00:00
|
|
|
{
|
2020-12-25 09:07:43 +00:00
|
|
|
const GdkTimeCoord *time_coord = &history[i];
|
2019-02-19 18:15:16 +00:00
|
|
|
graphene_point_t p;
|
2018-02-01 16:52:40 +00:00
|
|
|
|
2020-12-25 08:58:04 +00:00
|
|
|
if (gtk_widget_compute_point (event_widget, controller_widget,
|
2020-12-24 18:55:39 +00:00
|
|
|
&GRAPHENE_POINT_INIT (time_coord->axes[GDK_AXIS_X] - surf_x,
|
|
|
|
time_coord->axes[GDK_AXIS_Y] - surf_y),
|
2019-02-20 03:53:47 +00:00
|
|
|
&p))
|
|
|
|
{
|
2020-12-25 09:07:43 +00:00
|
|
|
GdkTimeCoord translated_coord = *time_coord;
|
|
|
|
|
|
|
|
translated_coord.axes[GDK_AXIS_X] = p.x;
|
|
|
|
translated_coord.axes[GDK_AXIS_Y] = p.y;
|
|
|
|
|
|
|
|
g_array_append_val (backlog_array, translated_coord);
|
2019-02-20 03:53:47 +00:00
|
|
|
}
|
2020-12-25 09:07:43 +00:00
|
|
|
}
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
*n_elems = backlog_array->len;
|
|
|
|
*backlog = (GdkTimeCoord *) g_array_free (backlog_array, FALSE);
|
2020-04-25 15:50:11 +00:00
|
|
|
g_free (history);
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_gesture_stylus_get_device_tool:
|
2021-03-01 06:48:22 +00:00
|
|
|
* @gesture: a `GtkGestureStylus`
|
2018-02-01 16:52:40 +00:00
|
|
|
*
|
2021-03-01 06:48:22 +00:00
|
|
|
* Returns the `GdkDeviceTool` currently driving input through this gesture.
|
|
|
|
*
|
|
|
|
* This function must be called from the handler of one of the
|
|
|
|
* [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion],
|
|
|
|
* [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity]
|
|
|
|
* signals.
|
2018-02-01 16:52:40 +00:00
|
|
|
*
|
|
|
|
* Returns: (nullable) (transfer none): The current stylus tool
|
2021-03-01 06:48:22 +00:00
|
|
|
*/
|
2018-02-01 16:52:40 +00:00
|
|
|
GdkDeviceTool *
|
|
|
|
gtk_gesture_stylus_get_device_tool (GtkGestureStylus *gesture)
|
|
|
|
{
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event;
|
2018-02-01 16:52:40 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
|
|
|
|
|
2021-12-02 16:00:10 +00:00
|
|
|
event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
|
2018-02-01 16:52:40 +00:00
|
|
|
if (!event)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return gdk_event_get_device_tool (event);
|
|
|
|
}
|