2010-05-25 22:38:44 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-25 22:38:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2010-12-21 06:32:01 +00:00
|
|
|
#include "gdkx11device-xi2.h"
|
2010-12-21 15:37:21 +00:00
|
|
|
#include "gdkdeviceprivate.h"
|
2010-10-15 02:05:51 +00:00
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
#include "gdkintl.h"
|
2010-12-10 17:13:25 +00:00
|
|
|
#include "gdkasync.h"
|
2010-12-16 03:09:35 +00:00
|
|
|
#include "gdkprivate-x11.h"
|
2018-02-07 05:00:01 +00:00
|
|
|
#include "gdkdisplay-x11.h"
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2011-01-30 04:26:34 +00:00
|
|
|
#include <stdlib.h>
|
2010-12-21 19:17:02 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
|
2013-07-03 09:52:58 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2012-01-23 23:49:52 +00:00
|
|
|
typedef struct _ScrollValuator ScrollValuator;
|
|
|
|
|
|
|
|
struct _ScrollValuator
|
|
|
|
{
|
|
|
|
guint n_valuator : 4;
|
|
|
|
guint direction : 4;
|
2015-07-15 19:19:25 +00:00
|
|
|
guint last_value_valid : 1;
|
2020-07-24 20:32:16 +00:00
|
|
|
double last_value;
|
|
|
|
double increment;
|
2012-01-23 23:49:52 +00:00
|
|
|
};
|
|
|
|
|
2010-12-21 15:37:21 +00:00
|
|
|
struct _GdkX11DeviceXI2
|
|
|
|
{
|
|
|
|
GdkDevice parent_instance;
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
int device_id;
|
2012-01-23 23:49:52 +00:00
|
|
|
GArray *scroll_valuators;
|
2020-07-24 20:32:16 +00:00
|
|
|
double *last_axes;
|
2010-12-21 15:37:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GdkX11DeviceXI2Class
|
|
|
|
{
|
|
|
|
GdkDeviceClass parent_class;
|
|
|
|
};
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2011-02-12 00:27:40 +00:00
|
|
|
G_DEFINE_TYPE (GdkX11DeviceXI2, gdk_x11_device_xi2, GDK_TYPE_DEVICE)
|
|
|
|
|
|
|
|
|
2012-01-23 23:49:52 +00:00
|
|
|
static void gdk_x11_device_xi2_finalize (GObject *object);
|
2010-12-21 06:32:01 +00:00
|
|
|
static void gdk_x11_device_xi2_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gdk_x11_device_xi2_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
static void gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface,
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkCursor *cursor);
|
2012-03-09 12:20:41 +00:00
|
|
|
static void gdk_x11_device_xi2_query_state (GdkDevice *device,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface,
|
|
|
|
GdkSurface **child_surface,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *win_x,
|
|
|
|
double *win_y,
|
2012-03-09 12:20:41 +00:00
|
|
|
GdkModifierType *mask);
|
2010-12-21 06:32:01 +00:00
|
|
|
|
|
|
|
static GdkGrabStatus gdk_x11_device_xi2_grab (GdkDevice *device,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface,
|
2010-12-21 06:32:01 +00:00
|
|
|
gboolean owner_events,
|
|
|
|
GdkEventMask event_mask,
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *confine_to,
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkCursor *cursor,
|
|
|
|
guint32 time_);
|
|
|
|
static void gdk_x11_device_xi2_ungrab (GdkDevice *device,
|
|
|
|
guint32 time_);
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
static GdkSurface * gdk_x11_device_xi2_surface_at_position (GdkDevice *device,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *win_x,
|
|
|
|
double *win_y,
|
2020-05-19 19:00:32 +00:00
|
|
|
GdkModifierType *mask);
|
2010-12-21 06:32:01 +00:00
|
|
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_DEVICE_ID
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2010-12-21 06:32:01 +00:00
|
|
|
gdk_x11_device_xi2_class_init (GdkX11DeviceXI2Class *klass)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
|
|
|
|
|
2012-01-23 23:49:52 +00:00
|
|
|
object_class->finalize = gdk_x11_device_xi2_finalize;
|
2010-12-21 06:32:01 +00:00
|
|
|
object_class->get_property = gdk_x11_device_xi2_get_property;
|
|
|
|
object_class->set_property = gdk_x11_device_xi2_set_property;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
device_class->set_surface_cursor = gdk_x11_device_xi2_set_surface_cursor;
|
2010-12-21 06:32:01 +00:00
|
|
|
device_class->query_state = gdk_x11_device_xi2_query_state;
|
|
|
|
device_class->grab = gdk_x11_device_xi2_grab;
|
|
|
|
device_class->ungrab = gdk_x11_device_xi2_ungrab;
|
2018-03-20 11:05:26 +00:00
|
|
|
device_class->surface_at_position = gdk_x11_device_xi2_surface_at_position;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
2010-12-21 06:32:01 +00:00
|
|
|
PROP_DEVICE_ID,
|
|
|
|
g_param_spec_int ("device-id",
|
2010-05-25 22:38:44 +00:00
|
|
|
P_("Device ID"),
|
|
|
|
P_("Device identifier"),
|
|
|
|
0, G_MAXINT, 0,
|
2017-11-18 02:38:08 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2010-05-25 22:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-21 06:32:01 +00:00
|
|
|
gdk_x11_device_xi2_init (GdkX11DeviceXI2 *device)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2012-01-23 23:49:52 +00:00
|
|
|
device->scroll_valuators = g_array_new (FALSE, FALSE, sizeof (ScrollValuator));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_x11_device_xi2_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GdkX11DeviceXI2 *device = GDK_X11_DEVICE_XI2 (object);
|
|
|
|
|
|
|
|
g_array_free (device->scroll_valuators, TRUE);
|
2015-03-02 17:19:16 +00:00
|
|
|
g_free (device->last_axes);
|
2012-01-23 23:49:52 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_x11_device_xi2_parent_class)->finalize (object);
|
2010-05-25 22:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-21 06:32:01 +00:00
|
|
|
gdk_x11_device_xi2_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (object);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_DEVICE_ID:
|
2010-12-21 06:32:01 +00:00
|
|
|
g_value_set_int (value, device_xi2->device_id);
|
2010-05-25 22:38:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-21 06:32:01 +00:00
|
|
|
gdk_x11_device_xi2_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (object);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_DEVICE_ID:
|
2010-12-21 06:32:01 +00:00
|
|
|
device_xi2->device_id = g_value_get_int (value);
|
2010-05-25 22:38:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface,
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkCursor *cursor)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
/* Non-logical devices don't have a cursor */
|
|
|
|
if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_LOGICAL)
|
2010-05-25 22:38:44 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (cursor)
|
2018-03-20 14:14:10 +00:00
|
|
|
XIDefineCursor (GDK_SURFACE_XDISPLAY (surface),
|
2010-12-21 06:32:01 +00:00
|
|
|
device_xi2->device_id,
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_SURFACE_XID (surface),
|
|
|
|
gdk_x11_display_get_xcursor (GDK_SURFACE_DISPLAY (surface), cursor));
|
2010-05-25 22:38:44 +00:00
|
|
|
else
|
2018-03-20 14:14:10 +00:00
|
|
|
XIUndefineCursor (GDK_SURFACE_XDISPLAY (surface),
|
2010-12-21 06:32:01 +00:00
|
|
|
device_xi2->device_id,
|
2018-03-20 14:14:10 +00:00
|
|
|
GDK_SURFACE_XID (surface));
|
2010-05-25 22:38:44 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 12:20:41 +00:00
|
|
|
static void
|
2010-12-21 06:32:01 +00:00
|
|
|
gdk_x11_device_xi2_query_state (GdkDevice *device,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface,
|
|
|
|
GdkSurface **child_surface,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *win_x,
|
|
|
|
double *win_y,
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkModifierType *mask)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDisplay *display;
|
2017-11-17 15:37:52 +00:00
|
|
|
GdkX11Screen *default_screen;
|
2017-11-09 23:40:16 +00:00
|
|
|
Window xroot_window, xchild_window, xwindow;
|
2020-07-24 20:32:16 +00:00
|
|
|
double xroot_x, xroot_y, xwin_x, xwin_y;
|
2010-05-25 22:38:44 +00:00
|
|
|
XIButtonState button_state;
|
|
|
|
XIModifierState mod_state;
|
|
|
|
XIGroupState group_state;
|
2017-11-09 23:40:16 +00:00
|
|
|
int scale;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2017-08-08 23:45:09 +00:00
|
|
|
display = gdk_device_get_display (device);
|
2017-11-01 22:06:24 +00:00
|
|
|
default_screen = GDK_X11_DISPLAY (display)->screen;
|
2018-03-20 14:14:10 +00:00
|
|
|
if (surface == NULL)
|
2017-11-09 23:40:16 +00:00
|
|
|
{
|
|
|
|
xwindow = GDK_DISPLAY_XROOTWIN (display);
|
2018-03-20 11:05:26 +00:00
|
|
|
scale = default_screen->surface_scale;
|
2017-11-09 23:40:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
xwindow = GDK_SURFACE_XID (surface);
|
2019-04-22 01:14:46 +00:00
|
|
|
scale = GDK_X11_SURFACE (surface)->surface_scale;
|
2017-11-09 23:40:16 +00:00
|
|
|
}
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_PHYSICAL)
|
2013-05-17 12:28:04 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
GdkDevice *logical = gdk_device_get_associated_device (device);
|
2013-05-17 12:28:04 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (logical != NULL)
|
|
|
|
_gdk_device_query_state (logical, surface, child_surface,
|
2020-03-09 19:16:01 +00:00
|
|
|
win_x, win_y, mask);
|
2013-05-17 12:28:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-09 17:36:11 +00:00
|
|
|
if (!GDK_X11_DISPLAY (display)->trusted_client ||
|
2017-11-11 17:07:11 +00:00
|
|
|
!XIQueryPointer (GDK_DISPLAY_XDISPLAY (display),
|
2012-03-09 17:36:11 +00:00
|
|
|
device_xi2->device_id,
|
2017-11-09 23:40:16 +00:00
|
|
|
xwindow,
|
2012-03-09 17:36:11 +00:00
|
|
|
&xroot_window,
|
|
|
|
&xchild_window,
|
|
|
|
&xroot_x, &xroot_y,
|
|
|
|
&xwin_x, &xwin_y,
|
|
|
|
&button_state,
|
|
|
|
&mod_state,
|
|
|
|
&group_state))
|
2010-12-13 22:43:10 +00:00
|
|
|
{
|
|
|
|
XSetWindowAttributes attributes;
|
|
|
|
Display *xdisplay;
|
2017-11-09 23:40:16 +00:00
|
|
|
Window w;
|
2010-12-13 22:43:10 +00:00
|
|
|
|
|
|
|
/* FIXME: untrusted clients not multidevice-safe */
|
|
|
|
xdisplay = GDK_SCREEN_XDISPLAY (default_screen);
|
|
|
|
xwindow = GDK_SCREEN_XROOTWIN (default_screen);
|
|
|
|
|
|
|
|
w = XCreateWindow (xdisplay, xwindow, 0, 0, 1, 1, 0,
|
|
|
|
CopyFromParent, InputOnly, CopyFromParent,
|
|
|
|
0, &attributes);
|
2010-12-21 06:32:01 +00:00
|
|
|
XIQueryPointer (xdisplay, device_xi2->device_id,
|
2010-12-13 22:43:10 +00:00
|
|
|
w,
|
|
|
|
&xroot_window,
|
|
|
|
&xchild_window,
|
2010-12-21 06:32:01 +00:00
|
|
|
&xroot_x, &xroot_y,
|
|
|
|
&xwin_x, &xwin_y,
|
2010-12-13 22:43:10 +00:00
|
|
|
&button_state,
|
|
|
|
&mod_state,
|
|
|
|
&group_state);
|
|
|
|
XDestroyWindow (xdisplay, w);
|
2010-05-25 22:38:44 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (child_surface)
|
|
|
|
*child_surface = gdk_x11_surface_lookup_for_display (display, xchild_window);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
if (win_x)
|
2017-11-09 23:40:16 +00:00
|
|
|
*win_x = xwin_x / scale;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
if (win_y)
|
2017-11-09 23:40:16 +00:00
|
|
|
*win_y = xwin_y / scale;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
if (mask)
|
2011-02-05 02:01:52 +00:00
|
|
|
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2011-01-30 04:26:34 +00:00
|
|
|
free (button_state.mask);
|
2010-05-25 22:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GdkGrabStatus
|
2010-12-21 06:32:01 +00:00
|
|
|
gdk_x11_device_xi2_grab (GdkDevice *device,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface,
|
2010-12-21 06:32:01 +00:00
|
|
|
gboolean owner_events,
|
|
|
|
GdkEventMask event_mask,
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *confine_to,
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkCursor *cursor,
|
|
|
|
guint32 time_)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
|
2012-03-01 05:56:51 +00:00
|
|
|
GdkX11DeviceManagerXI2 *device_manager_xi2;
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDisplay *display;
|
|
|
|
XIEventMask mask;
|
|
|
|
Window xwindow;
|
|
|
|
Cursor xcursor;
|
2020-07-24 13:54:49 +00:00
|
|
|
int status;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
display = gdk_device_get_display (device);
|
2017-11-24 14:14:17 +00:00
|
|
|
device_manager_xi2 = GDK_X11_DEVICE_MANAGER_XI2 (GDK_X11_DISPLAY (display)->device_manager);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
/* FIXME: confine_to is actually unused */
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
xwindow = GDK_SURFACE_XID (surface);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
if (!cursor)
|
|
|
|
xcursor = None;
|
|
|
|
else
|
|
|
|
{
|
2017-11-03 05:01:56 +00:00
|
|
|
xcursor = gdk_x11_display_get_xcursor (display, cursor);
|
2010-05-25 22:38:44 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 06:32:01 +00:00
|
|
|
mask.deviceid = device_xi2->device_id;
|
2012-03-01 05:56:51 +00:00
|
|
|
mask.mask = _gdk_x11_device_xi2_translate_event_mask (device_manager_xi2,
|
|
|
|
event_mask,
|
|
|
|
&mask.mask_len);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2018-04-21 17:18:20 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
2018-01-12 00:48:27 +00:00
|
|
|
if (GDK_DISPLAY_DEBUG_CHECK (display, NOGRABS))
|
2010-12-10 17:13:25 +00:00
|
|
|
status = GrabSuccess;
|
|
|
|
else
|
|
|
|
#endif
|
2018-01-12 00:48:27 +00:00
|
|
|
status = XIGrabDevice (GDK_DISPLAY_XDISPLAY (display),
|
|
|
|
device_xi2->device_id,
|
|
|
|
xwindow,
|
|
|
|
time_,
|
|
|
|
xcursor,
|
|
|
|
GrabModeAsync, GrabModeAsync,
|
|
|
|
owner_events,
|
|
|
|
&mask);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
g_free (mask.mask);
|
|
|
|
|
2010-12-10 17:13:25 +00:00
|
|
|
_gdk_x11_display_update_grab_info (display, device, status);
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
return _gdk_x11_convert_grab_status (status);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-21 06:32:01 +00:00
|
|
|
gdk_x11_device_xi2_ungrab (GdkDevice *device,
|
|
|
|
guint32 time_)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDisplay *display;
|
2010-12-10 17:13:25 +00:00
|
|
|
gulong serial;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
display = gdk_device_get_display (device);
|
2010-12-10 17:13:25 +00:00
|
|
|
serial = NextRequest (GDK_DISPLAY_XDISPLAY (display));
|
|
|
|
|
2010-12-21 06:32:01 +00:00
|
|
|
XIUngrabDevice (GDK_DISPLAY_XDISPLAY (display), device_xi2->device_id, time_);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2010-12-10 17:13:25 +00:00
|
|
|
_gdk_x11_display_update_grab_info_ungrab (display, device, time_, serial);
|
2010-05-25 22:38:44 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
static GdkSurface *
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_x11_device_xi2_surface_at_position (GdkDevice *device,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *win_x,
|
|
|
|
double *win_y,
|
2020-05-19 19:00:32 +00:00
|
|
|
GdkModifierType *mask)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2019-04-22 01:14:46 +00:00
|
|
|
GdkX11Surface *impl;
|
2010-12-21 06:32:01 +00:00
|
|
|
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
|
2010-05-25 22:38:44 +00:00
|
|
|
GdkDisplay *display;
|
2017-11-17 15:37:52 +00:00
|
|
|
GdkX11Screen *screen;
|
2010-05-25 22:38:44 +00:00
|
|
|
Display *xdisplay;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface;
|
2010-05-25 22:38:44 +00:00
|
|
|
Window xwindow, root, child, last = None;
|
2020-07-24 20:32:16 +00:00
|
|
|
double xroot_x, xroot_y, xwin_x, xwin_y;
|
2011-01-23 22:19:30 +00:00
|
|
|
XIButtonState button_state = { 0 };
|
2010-05-25 22:38:44 +00:00
|
|
|
XIModifierState mod_state;
|
|
|
|
XIGroupState group_state;
|
2015-06-30 17:04:13 +00:00
|
|
|
Bool retval;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
display = gdk_device_get_display (device);
|
2017-11-01 22:06:24 +00:00
|
|
|
screen = GDK_X11_DISPLAY (display)->screen;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2015-06-30 17:04:13 +00:00
|
|
|
gdk_x11_display_error_trap_push (display);
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
/* This function really only works if the mouse pointer is held still
|
|
|
|
* during its operation. If it moves from one leaf window to another
|
|
|
|
* than we'll end up with inaccurate values for win_x, win_y
|
|
|
|
* and the result.
|
|
|
|
*/
|
|
|
|
gdk_x11_display_grab (display);
|
|
|
|
|
|
|
|
xdisplay = GDK_SCREEN_XDISPLAY (screen);
|
|
|
|
xwindow = GDK_SCREEN_XROOTWIN (screen);
|
|
|
|
|
2010-12-20 18:20:10 +00:00
|
|
|
if (G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
|
2010-12-13 22:43:10 +00:00
|
|
|
{
|
|
|
|
XIQueryPointer (xdisplay,
|
2010-12-21 06:32:01 +00:00
|
|
|
device_xi2->device_id,
|
2010-12-13 22:43:10 +00:00
|
|
|
xwindow,
|
|
|
|
&root, &child,
|
|
|
|
&xroot_x, &xroot_y,
|
|
|
|
&xwin_x, &xwin_y,
|
|
|
|
&button_state,
|
|
|
|
&mod_state,
|
|
|
|
&group_state);
|
|
|
|
|
|
|
|
if (root == xwindow)
|
|
|
|
xwindow = child;
|
|
|
|
else
|
|
|
|
xwindow = root;
|
|
|
|
}
|
2010-05-25 22:38:44 +00:00
|
|
|
else
|
2010-12-13 22:43:10 +00:00
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int width, height;
|
2010-12-13 22:43:10 +00:00
|
|
|
GList *toplevels, *list;
|
2015-05-31 01:17:45 +00:00
|
|
|
Window pointer_window;
|
2010-12-13 22:43:10 +00:00
|
|
|
|
|
|
|
/* FIXME: untrusted clients case not multidevice-safe */
|
|
|
|
pointer_window = None;
|
|
|
|
|
2017-11-05 23:36:49 +00:00
|
|
|
toplevels = gdk_x11_display_get_toplevel_windows (display);
|
2015-10-20 00:31:57 +00:00
|
|
|
for (list = toplevels; list != NULL; list = list->next)
|
2010-12-13 22:43:10 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
surface = GDK_SURFACE (list->data);
|
|
|
|
xwindow = GDK_SURFACE_XID (surface);
|
2013-04-04 14:22:12 +00:00
|
|
|
|
|
|
|
/* Free previous button mask, if any */
|
|
|
|
g_free (button_state.mask);
|
|
|
|
|
2015-06-30 17:04:13 +00:00
|
|
|
retval = XIQueryPointer (xdisplay,
|
|
|
|
device_xi2->device_id,
|
|
|
|
xwindow,
|
|
|
|
&root, &child,
|
|
|
|
&xroot_x, &xroot_y,
|
|
|
|
&xwin_x, &xwin_y,
|
|
|
|
&button_state,
|
|
|
|
&mod_state,
|
|
|
|
&group_state);
|
|
|
|
if (!retval)
|
2013-04-04 14:22:12 +00:00
|
|
|
continue;
|
2015-06-30 17:04:13 +00:00
|
|
|
|
2013-04-04 14:22:12 +00:00
|
|
|
if (child != None)
|
|
|
|
{
|
|
|
|
pointer_window = child;
|
|
|
|
break;
|
|
|
|
}
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_surface_get_geometry (surface, NULL, NULL, &width, &height);
|
2013-04-04 14:22:12 +00:00
|
|
|
if (xwin_x >= 0 && xwin_y >= 0 && xwin_x < width && xwin_y < height)
|
2010-12-13 22:43:10 +00:00
|
|
|
{
|
2013-04-04 14:22:12 +00:00
|
|
|
/* A childless toplevel, or below another window? */
|
|
|
|
XSetWindowAttributes attributes;
|
|
|
|
Window w;
|
2011-01-23 22:19:30 +00:00
|
|
|
|
2013-04-04 14:22:12 +00:00
|
|
|
free (button_state.mask);
|
2011-01-23 22:19:30 +00:00
|
|
|
|
2013-04-04 14:22:12 +00:00
|
|
|
w = XCreateWindow (xdisplay, xwindow, (int)xwin_x, (int)xwin_y, 1, 1, 0,
|
|
|
|
CopyFromParent, InputOnly, CopyFromParent,
|
|
|
|
0, &attributes);
|
|
|
|
XMapWindow (xdisplay, w);
|
2010-12-13 22:43:10 +00:00
|
|
|
XIQueryPointer (xdisplay,
|
2010-12-21 06:32:01 +00:00
|
|
|
device_xi2->device_id,
|
2010-12-13 22:43:10 +00:00
|
|
|
xwindow,
|
|
|
|
&root, &child,
|
|
|
|
&xroot_x, &xroot_y,
|
|
|
|
&xwin_x, &xwin_y,
|
|
|
|
&button_state,
|
|
|
|
&mod_state,
|
|
|
|
&group_state);
|
2013-04-04 14:22:12 +00:00
|
|
|
XDestroyWindow (xdisplay, w);
|
|
|
|
if (child == w)
|
2010-12-13 22:43:10 +00:00
|
|
|
{
|
2013-04-04 14:22:12 +00:00
|
|
|
pointer_window = xwindow;
|
2010-12-13 22:43:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pointer_window != None)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
xwindow = pointer_window;
|
|
|
|
}
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
while (xwindow)
|
|
|
|
{
|
|
|
|
last = xwindow;
|
2011-01-30 04:26:34 +00:00
|
|
|
free (button_state.mask);
|
2011-01-23 22:19:30 +00:00
|
|
|
|
2015-06-30 17:04:13 +00:00
|
|
|
retval = XIQueryPointer (xdisplay,
|
|
|
|
device_xi2->device_id,
|
|
|
|
xwindow,
|
|
|
|
&root, &xwindow,
|
|
|
|
&xroot_x, &xroot_y,
|
|
|
|
&xwin_x, &xwin_y,
|
|
|
|
&button_state,
|
|
|
|
&mod_state,
|
|
|
|
&group_state);
|
|
|
|
if (!retval)
|
2010-12-13 22:43:10 +00:00
|
|
|
break;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2020-05-19 19:00:32 +00:00
|
|
|
if (last != root &&
|
2018-06-25 22:47:40 +00:00
|
|
|
(surface = gdk_x11_surface_lookup_for_display (display, last)) != NULL)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
|
|
|
xwindow = last;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_x11_display_ungrab (display);
|
|
|
|
|
2015-06-30 17:04:13 +00:00
|
|
|
if (gdk_x11_display_error_trap_pop (display) == 0)
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
surface = gdk_x11_surface_lookup_for_display (display, last);
|
2015-06-30 17:04:13 +00:00
|
|
|
impl = NULL;
|
2018-03-20 14:14:10 +00:00
|
|
|
if (surface)
|
2019-04-22 01:14:46 +00:00
|
|
|
impl = GDK_X11_SURFACE (surface);
|
2015-06-30 17:04:13 +00:00
|
|
|
|
|
|
|
if (mask)
|
|
|
|
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
|
|
|
|
|
|
|
|
free (button_state.mask);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
surface = NULL;
|
2015-06-30 17:04:13 +00:00
|
|
|
|
|
|
|
if (mask)
|
|
|
|
*mask = 0;
|
|
|
|
}
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
if (win_x)
|
2018-03-20 14:14:10 +00:00
|
|
|
*win_x = (surface) ? (xwin_x / impl->surface_scale) : -1;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
if (win_y)
|
2018-03-20 14:14:10 +00:00
|
|
|
*win_y = (surface) ? (xwin_y / impl->surface_scale) : -1;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2011-01-23 22:19:30 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
return surface;
|
2010-05-25 22:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
guchar *
|
2012-03-01 05:56:51 +00:00
|
|
|
_gdk_x11_device_xi2_translate_event_mask (GdkX11DeviceManagerXI2 *device_manager_xi2,
|
|
|
|
GdkEventMask event_mask,
|
2020-07-24 13:54:49 +00:00
|
|
|
int *len)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
|
|
|
guchar *mask;
|
2020-07-24 13:54:49 +00:00
|
|
|
int minor;
|
2012-03-01 05:56:51 +00:00
|
|
|
|
|
|
|
g_object_get (device_manager_xi2, "minor", &minor, NULL);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
*len = XIMaskLen (XI_LASTEVENT);
|
|
|
|
mask = g_new0 (guchar, *len);
|
|
|
|
|
2017-09-15 16:58:50 +00:00
|
|
|
if (event_mask & GDK_POINTER_MOTION_MASK)
|
2010-05-25 22:38:44 +00:00
|
|
|
XISetMask (mask, XI_Motion);
|
|
|
|
|
|
|
|
if (event_mask & GDK_BUTTON_MOTION_MASK ||
|
|
|
|
event_mask & GDK_BUTTON1_MOTION_MASK ||
|
|
|
|
event_mask & GDK_BUTTON2_MOTION_MASK ||
|
|
|
|
event_mask & GDK_BUTTON3_MOTION_MASK)
|
|
|
|
{
|
|
|
|
XISetMask (mask, XI_ButtonPress);
|
|
|
|
XISetMask (mask, XI_ButtonRelease);
|
|
|
|
XISetMask (mask, XI_Motion);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event_mask & GDK_SCROLL_MASK)
|
|
|
|
{
|
|
|
|
XISetMask (mask, XI_ButtonPress);
|
|
|
|
XISetMask (mask, XI_ButtonRelease);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event_mask & GDK_BUTTON_PRESS_MASK)
|
|
|
|
XISetMask (mask, XI_ButtonPress);
|
|
|
|
|
|
|
|
if (event_mask & GDK_BUTTON_RELEASE_MASK)
|
|
|
|
XISetMask (mask, XI_ButtonRelease);
|
|
|
|
|
|
|
|
if (event_mask & GDK_KEY_PRESS_MASK)
|
|
|
|
XISetMask (mask, XI_KeyPress);
|
|
|
|
|
|
|
|
if (event_mask & GDK_KEY_RELEASE_MASK)
|
|
|
|
XISetMask (mask, XI_KeyRelease);
|
|
|
|
|
|
|
|
if (event_mask & GDK_ENTER_NOTIFY_MASK)
|
|
|
|
XISetMask (mask, XI_Enter);
|
|
|
|
|
|
|
|
if (event_mask & GDK_LEAVE_NOTIFY_MASK)
|
|
|
|
XISetMask (mask, XI_Leave);
|
|
|
|
|
|
|
|
if (event_mask & GDK_FOCUS_CHANGE_MASK)
|
|
|
|
{
|
|
|
|
XISetMask (mask, XI_FocusIn);
|
|
|
|
XISetMask (mask, XI_FocusOut);
|
|
|
|
}
|
|
|
|
|
2012-03-01 05:56:51 +00:00
|
|
|
#ifdef XINPUT_2_2
|
|
|
|
/* XInput 2.2 includes multitouch support */
|
|
|
|
if (minor >= 2 &&
|
|
|
|
event_mask & GDK_TOUCH_MASK)
|
|
|
|
{
|
|
|
|
XISetMask (mask, XI_TouchBegin);
|
|
|
|
XISetMask (mask, XI_TouchUpdate);
|
|
|
|
XISetMask (mask, XI_TouchEnd);
|
|
|
|
}
|
|
|
|
#endif /* XINPUT_2_2 */
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
2010-12-21 06:32:01 +00:00
|
|
|
_gdk_x11_device_xi2_translate_state (XIModifierState *mods_state,
|
2011-02-05 02:01:52 +00:00
|
|
|
XIButtonState *buttons_state,
|
|
|
|
XIGroupState *group_state)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
|
|
|
guint state = 0;
|
|
|
|
|
|
|
|
if (mods_state)
|
2012-02-29 16:18:57 +00:00
|
|
|
state = mods_state->effective;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
if (buttons_state)
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int len, i;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2015-05-02 15:51:38 +00:00
|
|
|
/* We're only interested in the first 3 buttons */
|
|
|
|
len = MIN (3, buttons_state->mask_len * 8);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2015-05-02 15:51:38 +00:00
|
|
|
for (i = 1; i <= len; i++)
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
|
|
|
if (!XIMaskIsSet (buttons_state->mask, i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
state |= GDK_BUTTON1_MASK;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
state |= GDK_BUTTON2_MASK;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
state |= GDK_BUTTON3_MASK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-05 02:08:41 +00:00
|
|
|
if (group_state)
|
2012-02-29 16:15:10 +00:00
|
|
|
state |= (group_state->effective) << 13;
|
2011-02-05 02:08:41 +00:00
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
return state;
|
|
|
|
}
|
2011-02-12 00:27:40 +00:00
|
|
|
|
2012-01-23 23:49:52 +00:00
|
|
|
void
|
|
|
|
_gdk_x11_device_xi2_add_scroll_valuator (GdkX11DeviceXI2 *device,
|
|
|
|
guint n_valuator,
|
2012-03-05 00:12:27 +00:00
|
|
|
GdkScrollDirection direction,
|
2020-07-24 20:32:16 +00:00
|
|
|
double increment)
|
2012-01-23 23:49:52 +00:00
|
|
|
{
|
|
|
|
ScrollValuator scroll;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_X11_DEVICE_XI2 (device));
|
|
|
|
g_return_if_fail (n_valuator < gdk_device_get_n_axes (GDK_DEVICE (device)));
|
|
|
|
|
|
|
|
scroll.n_valuator = n_valuator;
|
|
|
|
scroll.direction = direction;
|
2015-07-15 19:19:25 +00:00
|
|
|
scroll.last_value_valid = FALSE;
|
2012-03-05 00:12:27 +00:00
|
|
|
scroll.increment = increment;
|
2012-01-23 23:49:52 +00:00
|
|
|
|
|
|
|
g_array_append_val (device->scroll_valuators, scroll);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gdk_x11_device_xi2_get_scroll_delta (GdkX11DeviceXI2 *device,
|
|
|
|
guint n_valuator,
|
2020-07-24 20:32:16 +00:00
|
|
|
double valuator_value,
|
2012-01-23 23:49:52 +00:00
|
|
|
GdkScrollDirection *direction_ret,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *delta_ret)
|
2012-01-23 23:49:52 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_X11_DEVICE_XI2 (device), FALSE);
|
|
|
|
g_return_val_if_fail (n_valuator < gdk_device_get_n_axes (GDK_DEVICE (device)), FALSE);
|
|
|
|
|
|
|
|
for (i = 0; i < device->scroll_valuators->len; i++)
|
|
|
|
{
|
|
|
|
ScrollValuator *scroll;
|
|
|
|
|
|
|
|
scroll = &g_array_index (device->scroll_valuators, ScrollValuator, i);
|
|
|
|
|
|
|
|
if (scroll->n_valuator == n_valuator)
|
|
|
|
{
|
|
|
|
if (direction_ret)
|
|
|
|
*direction_ret = scroll->direction;
|
|
|
|
|
|
|
|
if (delta_ret)
|
|
|
|
*delta_ret = 0;
|
|
|
|
|
2015-07-15 19:19:25 +00:00
|
|
|
if (scroll->last_value_valid)
|
|
|
|
{
|
|
|
|
if (delta_ret)
|
|
|
|
*delta_ret = (valuator_value - scroll->last_value) / scroll->increment;
|
2012-01-23 23:49:52 +00:00
|
|
|
|
2015-07-15 19:19:25 +00:00
|
|
|
scroll->last_value = valuator_value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scroll->last_value = valuator_value;
|
|
|
|
scroll->last_value_valid = TRUE;
|
|
|
|
}
|
2012-01-23 23:49:52 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-07-15 19:19:25 +00:00
|
|
|
_gdk_device_xi2_reset_scroll_valuators (GdkX11DeviceXI2 *device)
|
2012-01-23 23:49:52 +00:00
|
|
|
{
|
2015-07-15 19:19:25 +00:00
|
|
|
guint i;
|
2012-01-23 23:49:52 +00:00
|
|
|
|
|
|
|
for (i = 0; i < device->scroll_valuators->len; i++)
|
|
|
|
{
|
|
|
|
ScrollValuator *scroll;
|
|
|
|
|
|
|
|
scroll = &g_array_index (device->scroll_valuators, ScrollValuator, i);
|
2015-07-15 19:19:25 +00:00
|
|
|
scroll->last_value_valid = FALSE;
|
2012-01-23 23:49:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-27 17:32:54 +00:00
|
|
|
void
|
|
|
|
_gdk_device_xi2_unset_scroll_valuators (GdkX11DeviceXI2 *device)
|
|
|
|
{
|
|
|
|
if (device->scroll_valuators->len > 0)
|
|
|
|
g_array_remove_range (device->scroll_valuators, 0,
|
|
|
|
device->scroll_valuators->len);
|
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
int
|
2011-07-14 15:43:59 +00:00
|
|
|
_gdk_x11_device_xi2_get_id (GdkX11DeviceXI2 *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_X11_DEVICE_XI2 (device), 0);
|
|
|
|
|
|
|
|
return device->device_id;
|
|
|
|
}
|
2015-03-02 17:19:16 +00:00
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
double
|
2015-03-02 17:19:16 +00:00
|
|
|
gdk_x11_device_xi2_get_last_axis_value (GdkX11DeviceXI2 *device,
|
2020-07-24 13:54:49 +00:00
|
|
|
int n_axis)
|
2015-03-02 17:19:16 +00:00
|
|
|
{
|
|
|
|
if (n_axis >= gdk_device_get_n_axes (GDK_DEVICE (device)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!device->last_axes)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return device->last_axes[n_axis];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *axes,
|
2020-07-24 13:54:49 +00:00
|
|
|
int n_axes)
|
2015-03-02 17:19:16 +00:00
|
|
|
{
|
|
|
|
g_free (device->last_axes);
|
|
|
|
|
|
|
|
if (axes && n_axes)
|
2020-07-24 20:32:16 +00:00
|
|
|
device->last_axes = g_memdup (axes, sizeof (double) * n_axes);
|
2015-03-02 17:19:16 +00:00
|
|
|
else
|
|
|
|
device->last_axes = NULL;
|
|
|
|
}
|