gtk/gdk/x11/gdkdevice-xi2.c

847 lines
24 KiB
C
Raw Normal View History

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"
#include "gdkx11device-xi2.h"
#include "gdkdeviceprivate.h"
#include "gdkdevice-xi2-private.h"
2010-05-25 22:38:44 +00:00
#include "gdkintl.h"
#include "gdkasync.h"
#include "gdkprivate-x11.h"
#include "gdkdisplay-x11.h"
2010-05-25 22:38:44 +00:00
#include "gdk-private.h"
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XInput2.h>
#include <math.h>
typedef struct _ScrollValuator ScrollValuator;
struct _ScrollValuator
{
guint n_valuator : 4;
guint direction : 4;
guint last_value_valid : 1;
2020-07-24 20:32:16 +00:00
double last_value;
double increment;
};
struct _GdkX11DeviceXI2
{
GdkDevice parent_instance;
2020-07-24 13:54:49 +00:00
int device_id;
GArray *scroll_valuators;
2020-07-24 20:32:16 +00:00
double *last_axes;
GdkX11DeviceType device_type;
};
struct _GdkX11DeviceXI2Class
{
GdkDeviceClass parent_class;
};
2010-05-25 22:38:44 +00:00
G_DEFINE_TYPE (GdkX11DeviceXI2, gdk_x11_device_xi2, GDK_TYPE_DEVICE)
static void gdk_x11_device_xi2_finalize (GObject *object);
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);
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 11:05:26 +00:00
static void gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device,
GdkSurface *surface,
GdkCursor *cursor);
static GdkGrabStatus gdk_x11_device_xi2_grab (GdkDevice *device,
GdkSurface *surface,
gboolean owner_events,
GdkEventMask event_mask,
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
GdkSurface *confine_to,
GdkCursor *cursor,
guint32 time_);
static void gdk_x11_device_xi2_ungrab (GdkDevice *device,
guint32 time_);
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
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,
GdkModifierType *mask);
2010-05-25 22:38:44 +00:00
enum {
PROP_0,
PROP_DEVICE_ID
};
static void
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);
object_class->finalize = gdk_x11_device_xi2_finalize;
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
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 11:05:26 +00:00
device_class->set_surface_cursor = gdk_x11_device_xi2_set_surface_cursor;
device_class->grab = gdk_x11_device_xi2_grab;
device_class->ungrab = gdk_x11_device_xi2_ungrab;
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
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,
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,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
2010-05-25 22:38:44 +00:00
}
static void
gdk_x11_device_xi2_init (GdkX11DeviceXI2 *device)
2010-05-25 22:38:44 +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);
g_free (device->last_axes);
G_OBJECT_CLASS (gdk_x11_device_xi2_parent_class)->finalize (object);
2010-05-25 22:38:44 +00:00
}
static void
gdk_x11_device_xi2_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
2010-05-25 22:38:44 +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:
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
gdk_x11_device_xi2_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
2010-05-25 22:38:44 +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:
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
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 11:05:26 +00:00
gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device,
GdkSurface *surface,
GdkCursor *cursor)
2010-05-25 22:38:44 +00:00
{
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
2010-05-25 22:38:44 +00:00
/* Non-logical devices don't have a cursor */
if (device_xi2->device_type != GDK_X11_DEVICE_TYPE_LOGICAL)
2010-05-25 22:38:44 +00:00
return;
if (cursor)
XIDefineCursor (GDK_SURFACE_XDISPLAY (surface),
device_xi2->device_id,
GDK_SURFACE_XID (surface),
gdk_x11_display_get_xcursor (GDK_SURFACE_DISPLAY (surface), cursor));
2010-05-25 22:38:44 +00:00
else
XIUndefineCursor (GDK_SURFACE_XDISPLAY (surface),
device_xi2->device_id,
GDK_SURFACE_XID (surface));
2010-05-25 22:38:44 +00:00
}
void
gdk_x11_device_xi2_query_state (GdkDevice *device,
GdkSurface *surface,
2020-07-24 20:32:16 +00:00
double *win_x,
double *win_y,
GdkModifierType *mask)
2010-05-25 22:38:44 +00:00
{
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
2010-05-25 22:38:44 +00:00
GdkDisplay *display;
GdkX11Screen *default_screen;
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;
int scale;
2010-05-25 22:38:44 +00:00
display = gdk_device_get_display (device);
default_screen = GDK_X11_DISPLAY (display)->screen;
if (surface == NULL)
{
xwindow = GDK_DISPLAY_XROOTWIN (display);
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 11:05:26 +00:00
scale = default_screen->surface_scale;
}
else
{
xwindow = GDK_SURFACE_XID (surface);
scale = GDK_X11_SURFACE (surface)->surface_scale;
}
if (!GDK_X11_DISPLAY (display)->trusted_client ||
!XIQueryPointer (GDK_DISPLAY_XDISPLAY (display),
device_xi2->device_id,
xwindow,
&xroot_window,
&xchild_window,
&xroot_x, &xroot_y,
&xwin_x, &xwin_y,
&button_state,
&mod_state,
&group_state))
{
XSetWindowAttributes attributes;
Display *xdisplay;
Window w;
/* 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);
XIQueryPointer (xdisplay, device_xi2->device_id,
w,
&xroot_window,
&xchild_window,
&xroot_x, &xroot_y,
&xwin_x, &xwin_y,
&button_state,
&mod_state,
&group_state);
XDestroyWindow (xdisplay, w);
2010-05-25 22:38:44 +00:00
}
if (win_x)
*win_x = xwin_x / scale;
2010-05-25 22:38:44 +00:00
if (win_y)
*win_y = xwin_y / scale;
2010-05-25 22:38:44 +00:00
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
2010-05-25 22:38:44 +00:00
free (button_state.mask);
2010-05-25 22:38:44 +00:00
}
2021-09-24 19:20:15 +00:00
static GdkGrabStatus
gdk_x11_convert_grab_status (int status)
{
switch (status)
{
case GrabSuccess:
return GDK_GRAB_SUCCESS;
case AlreadyGrabbed:
return GDK_GRAB_ALREADY_GRABBED;
case GrabInvalidTime:
return GDK_GRAB_INVALID_TIME;
case GrabNotViewable:
return GDK_GRAB_NOT_VIEWABLE;
case GrabFrozen:
return GDK_GRAB_FROZEN;
default:
g_assert_not_reached();
return 0;
}
}
2010-05-25 22:38:44 +00:00
static GdkGrabStatus
gdk_x11_device_xi2_grab (GdkDevice *device,
GdkSurface *surface,
gboolean owner_events,
GdkEventMask event_mask,
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
GdkSurface *confine_to,
GdkCursor *cursor,
guint32 time_)
2010-05-25 22:38:44 +00:00
{
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
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);
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 */
xwindow = GDK_SURFACE_XID (surface);
2010-05-25 22:38:44 +00:00
if (!cursor)
xcursor = None;
else
{
xcursor = gdk_x11_display_get_xcursor (display, cursor);
2010-05-25 22:38:44 +00:00
}
mask.deviceid = device_xi2->device_id;
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
#ifdef G_ENABLE_DEBUG
if (GDK_DISPLAY_DEBUG_CHECK (display, NOGRABS))
status = GrabSuccess;
else
#endif
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);
_gdk_x11_display_update_grab_info (display, device, status);
2021-09-24 19:20:15 +00:00
return gdk_x11_convert_grab_status (status);
2010-05-25 22:38:44 +00:00
}
static void
gdk_x11_device_xi2_ungrab (GdkDevice *device,
guint32 time_)
2010-05-25 22:38:44 +00:00
{
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
2010-05-25 22:38:44 +00:00
GdkDisplay *display;
gulong serial;
2010-05-25 22:38:44 +00:00
display = gdk_device_get_display (device);
serial = NextRequest (GDK_DISPLAY_XDISPLAY (display));
XIUngrabDevice (GDK_DISPLAY_XDISPLAY (display), device_xi2->device_id, time_);
2010-05-25 22:38:44 +00:00
_gdk_x11_display_update_grab_info_ungrab (display, device, time_, serial);
2010-05-25 22:38:44 +00:00
}
GdkWindow -> GdkSurface initial type rename This renames the GdkWindow class and related classes (impl, backend subclasses) to surface. Additionally it renames related types: GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType, GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge This is an automatic conversion using the below commands: git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass git sed -f g GdkWindow GdkSurface git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2" git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE" git sed -f g "broadway_window" "broadway_surface" git sed -f g "BroadwayWindow" "BroadwaySurface" git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE" git sed -f g "wayland_window" "wayland_surface" git sed -f g "WaylandWindow" "WaylandSurface" git sed -f g "X11_WINDOW" "X11_SURFACE" git sed -f g "x11_window" "x11_surface" git sed -f g "X11Window" "X11Surface" git sed -f g "WIN32_WINDOW" "WIN32_SURFACE" git sed -f g "win32_window" "win32_surface" git sed -f g "Win32Window" "Win32Surface" git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE" git sed -f g "quartz_window" "quartz_surface" git sed -f g "QuartzWindow" "QuartzSurface" git checkout NEWS* po-properties
2018-03-20 10:40:08 +00:00
static GdkSurface *
GdkSurface: Rename various functions and variables This is an automatic rename of various things related to the window->surface rename. Public symbols changed by this is: GDK_MODE_WINDOW gdk_device_get_window_at_position gdk_device_get_window_at_position_double gdk_device_get_last_event_window gdk_display_get_monitor_at_window gdk_drag_context_get_source_window gdk_drag_context_get_dest_window gdk_drag_context_get_drag_window gdk_draw_context_get_window gdk_drawing_context_get_window gdk_gl_context_get_window gdk_synthesize_window_state gdk_surface_get_window_type gdk_x11_display_set_window_scale gsk_renderer_new_for_window gsk_renderer_get_window gtk_text_view_buffer_to_window_coords gtk_tree_view_convert_widget_to_bin_window_coords gtk_tree_view_convert_tree_to_bin_window_coords The commands that generated this are: git sed -f g "GDK window" "GDK surface" git sed -f g window_impl surface_impl (cd gdk; git sed -f g impl_window impl_surface) git sed -f g WINDOW_IMPL SURFACE_IMPL git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface git sed -f g gsk_renderer_get_window gsk_renderer_get_surface git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface (cd gdk; git sed -f g window_type surface_type) git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type git sed -f g window_at_position surface_at_position git sed -f g event_window event_surface git sed -f g window_coord surface_coord git sed -f g window_state surface_state git sed -f g window_cursor surface_cursor git sed -f g window_scale surface_scale git sed -f g window_events surface_events git sed -f g monitor_at_window monitor_at_surface git sed -f g window_under_pointer surface_under_pointer (cd gdk; git sed -f g for_window for_surface) git sed -f g window_anchor surface_anchor git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL git sed -f g native_window native_surface git sed -f g source_window source_surface git sed -f g dest_window dest_surface git sed -f g drag_window drag_surface git sed -f g input_window input_surface git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
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,
GdkModifierType *mask)
2010-05-25 22:38:44 +00:00
{
GdkX11Surface *impl;
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
2010-05-25 22:38:44 +00:00
GdkDisplay *display;
GdkX11Screen *screen;
2010-05-25 22:38:44 +00:00
Display *xdisplay;
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;
XIButtonState button_state = { 0 };
2010-05-25 22:38:44 +00:00
XIModifierState mod_state;
XIGroupState group_state;
Bool retval;
2010-05-25 22:38:44 +00:00
display = gdk_device_get_display (device);
screen = GDK_X11_DISPLAY (display)->screen;
2010-05-25 22:38:44 +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);
if (G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
{
XIQueryPointer (xdisplay,
device_xi2->device_id,
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
{
2020-07-24 13:54:49 +00:00
int width, height;
GList *toplevels, *list;
Window pointer_window;
/* FIXME: untrusted clients case not multidevice-safe */
pointer_window = None;
toplevels = gdk_x11_display_get_toplevel_windows (display);
for (list = toplevels; list != NULL; list = list->next)
{
surface = GDK_SURFACE (list->data);
xwindow = GDK_SURFACE_XID (surface);
/* Free previous button mask, if any */
g_free (button_state.mask);
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)
continue;
if (child != None)
{
pointer_window = child;
break;
}
gdk_surface_get_geometry (surface, NULL, NULL, &width, &height);
if (xwin_x >= 0 && xwin_y >= 0 && xwin_x < width && xwin_y < height)
{
/* A childless toplevel, or below another window? */
XSetWindowAttributes attributes;
Window w;
free (button_state.mask);
w = XCreateWindow (xdisplay, xwindow, (int)xwin_x, (int)xwin_y, 1, 1, 0,
CopyFromParent, InputOnly, CopyFromParent,
0, &attributes);
XMapWindow (xdisplay, w);
XIQueryPointer (xdisplay,
device_xi2->device_id,
xwindow,
&root, &child,
&xroot_x, &xroot_y,
&xwin_x, &xwin_y,
&button_state,
&mod_state,
&group_state);
XDestroyWindow (xdisplay, w);
if (child == w)
{
pointer_window = xwindow;
break;
}
}
if (pointer_window != None)
break;
}
xwindow = pointer_window;
}
2010-05-25 22:38:44 +00:00
while (xwindow)
{
last = xwindow;
free (button_state.mask);
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)
break;
2010-05-25 22:38:44 +00:00
if (last != root &&
(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);
if (gdk_x11_display_error_trap_pop (display) == 0)
{
surface = gdk_x11_surface_lookup_for_display (display, last);
impl = NULL;
if (surface)
impl = GDK_X11_SURFACE (surface);
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
free (button_state.mask);
}
else
{
surface = NULL;
if (mask)
*mask = 0;
}
2010-05-25 22:38:44 +00:00
if (win_x)
*win_x = (surface) ? (xwin_x / impl->surface_scale) : -1;
2010-05-25 22:38:44 +00:00
if (win_y)
*win_y = (surface) ? (xwin_y / impl->surface_scale) : -1;
2010-05-25 22:38:44 +00:00
return surface;
2010-05-25 22:38:44 +00:00
}
guchar *
_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;
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);
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);
}
#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 */
#ifdef XINPUT_2_4
/* XInput 2.4 includes touchpad gesture support */
if (minor >= 4 &&
event_mask & GDK_TOUCHPAD_GESTURE_MASK)
{
XISetMask (mask, XI_GesturePinchBegin);
XISetMask (mask, XI_GesturePinchUpdate);
XISetMask (mask, XI_GesturePinchEnd);
XISetMask (mask, XI_GestureSwipeBegin);
XISetMask (mask, XI_GestureSwipeUpdate);
XISetMask (mask, XI_GestureSwipeEnd);
}
#endif
2010-05-25 22:38:44 +00:00
return mask;
}
guint
_gdk_x11_device_xi2_translate_state (XIModifierState *mods_state,
XIButtonState *buttons_state,
XIGroupState *group_state)
2010-05-25 22:38:44 +00:00
{
guint state = 0;
if (mods_state)
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
/* 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
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;
}
}
}
if (group_state)
state |= (group_state->effective) << 13;
2010-05-25 22:38:44 +00:00
return state;
}
#ifdef XINPUT_2_4
guint
_gdk_x11_device_xi2_gesture_type_to_phase (int evtype, int flags)
{
switch (evtype)
{
case XI_GesturePinchBegin:
case XI_GestureSwipeBegin:
return GDK_TOUCHPAD_GESTURE_PHASE_BEGIN;
case XI_GesturePinchUpdate:
case XI_GestureSwipeUpdate:
return GDK_TOUCHPAD_GESTURE_PHASE_UPDATE;
case XI_GesturePinchEnd:
if (flags & XIGesturePinchEventCancelled)
return GDK_TOUCHPAD_GESTURE_PHASE_CANCEL;
return GDK_TOUCHPAD_GESTURE_PHASE_END;
case XI_GestureSwipeEnd:
if (flags & XIGestureSwipeEventCancelled)
return GDK_TOUCHPAD_GESTURE_PHASE_CANCEL;
return GDK_TOUCHPAD_GESTURE_PHASE_END;
default:
g_assert_not_reached ();
return GDK_TOUCHPAD_GESTURE_PHASE_END;
}
}
#endif /* XINPUT_2_4 */
void
_gdk_x11_device_xi2_add_scroll_valuator (GdkX11DeviceXI2 *device,
guint n_valuator,
GdkScrollDirection direction,
2020-07-24 20:32:16 +00:00
double increment)
{
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;
scroll.last_value_valid = FALSE;
scroll.increment = increment;
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,
GdkScrollDirection *direction_ret,
2020-07-24 20:32:16 +00:00
double *delta_ret)
{
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;
if (scroll->last_value_valid)
{
if (delta_ret)
*delta_ret = (valuator_value - scroll->last_value) / scroll->increment;
scroll->last_value = valuator_value;
}
else
{
scroll->last_value = valuator_value;
scroll->last_value_valid = TRUE;
}
return TRUE;
}
}
return FALSE;
}
void
_gdk_device_xi2_reset_scroll_valuators (GdkX11DeviceXI2 *device)
{
guint i;
for (i = 0; i < device->scroll_valuators->len; i++)
{
ScrollValuator *scroll;
scroll = &g_array_index (device->scroll_valuators, ScrollValuator, i);
scroll->last_value_valid = FALSE;
}
}
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
_gdk_x11_device_xi2_get_id (GdkX11DeviceXI2 *device)
{
g_return_val_if_fail (GDK_IS_X11_DEVICE_XI2 (device), 0);
return device->device_id;
}
2020-07-24 20:32:16 +00:00
double
gdk_x11_device_xi2_get_last_axis_value (GdkX11DeviceXI2 *device,
2020-07-24 13:54:49 +00:00
int n_axis)
{
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)
{
g_free (device->last_axes);
if (axes && n_axes)
device->last_axes = g_memdup2 (axes, sizeof (double) * n_axes);
else
device->last_axes = NULL;
}
GdkX11DeviceType
gdk_x11_device_xi2_get_device_type (GdkX11DeviceXI2 *device)
{
return device->device_type;
}
void
gdk_x11_device_xi2_set_device_type (GdkX11DeviceXI2 *device,
GdkX11DeviceType type)
{
device->device_type = type;
}