Rename x11-specific GdkDevice[Manager] implementations

Make them all fit in the gdk_x11_ prefix, and make the
get_type functions and standard macros available in headers.
This commit is contained in:
Matthias Clasen 2010-12-21 01:32:01 -05:00
parent 5cddc7ccbb
commit b4802e3042
17 changed files with 933 additions and 967 deletions

View File

@ -190,11 +190,11 @@ x11_introspection_files = \
x11/gdkapplaunchcontext-x11.c \ x11/gdkapplaunchcontext-x11.c \
x11/gdkasync.c \ x11/gdkasync.c \
x11/gdkcursor-x11.c \ x11/gdkcursor-x11.c \
x11/gdkdevice-core.c \ x11/gdkdevice-core-x11.c \
x11/gdkdevicemanager-core.c \ x11/gdkdevicemanager-core-x11.c \
x11/gdkdevicemanager-x11.c \ x11/gdkdevicemanager-x11.c \
x11/gdkdevicemanager-xi2.c \
x11/gdkdevicemanager-xi.c \ x11/gdkdevicemanager-xi.c \
x11/gdkdevicemanager-xi2.c \
x11/gdkdevice-xi2.c \ x11/gdkdevice-xi2.c \
x11/gdkdevice-xi.c \ x11/gdkdevice-xi.c \
x11/gdkdisplay-x11.c \ x11/gdkdisplay-x11.c \

View File

@ -54,18 +54,22 @@ libgdk_x11_la_SOURCES = \
xsettings-common.h \ xsettings-common.h \
xsettings-common.c xsettings-common.c
libgdkx11include_HEADERS =
if XINPUT_XFREE if XINPUT_XFREE
libgdk_x11_la_SOURCES += \ libgdk_x11_la_SOURCES += \
gdkdevicemanager-xi.c \ gdkdevicemanager-xi.c \
gdkdevicemanager-xi.h \ gdkdevice-xi.c
gdkdevice-xi.c \ libgdkx11include_HEADERS += \
gdkdevice-xi.h gdkx11devicemanager-xi.h \
gdkx11device-xi.h
if XINPUT_2 if XINPUT_2
libgdk_x11_la_SOURCES += \ libgdk_x11_la_SOURCES += \
gdkdevicemanager-xi2.c \ gdkdevicemanager-xi2.c \
gdkdevicemanager-xi2.h \ gdkdevice-xi2.c
gdkdevice-xi2.c \ libgdkx11include_HEADERS += \
gdkdevice-xi2.h gdkx11devicemanager-xi2.h \
gdkx11device-xi2.h
endif endif
endif endif
@ -73,7 +77,7 @@ endif
libgdkinclude_HEADERS = \ libgdkinclude_HEADERS = \
gdkx.h gdkx.h
libgdkx11include_HEADERS = \ libgdkx11include_HEADERS += \
gdkx11cursor.h \ gdkx11cursor.h \
gdkx11device-core.h \ gdkx11device-core.h \
gdkx11devicemanager-core.h \ gdkx11devicemanager-core.h \

View File

@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#include "gdkdevice-xi.h" #include "gdkx11device-xi.h"
#include "gdkwindow.h" #include "gdkwindow.h"
#include "gdkintl.h" #include "gdkintl.h"
@ -37,67 +37,67 @@ typedef struct
gdouble root_y; gdouble root_y;
} GdkWindowInputInfo; } GdkWindowInputInfo;
static void gdk_device_xi_constructed (GObject *object); static void gdk_x11_device_xi_constructed (GObject *object);
static void gdk_device_xi_dispose (GObject *object); static void gdk_x11_device_xi_dispose (GObject *object);
static void gdk_device_xi_set_property (GObject *object, static void gdk_x11_device_xi_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gdk_device_xi_get_property (GObject *object, static void gdk_x11_device_xi_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static gboolean gdk_device_xi_get_history (GdkDevice *device, static gboolean gdk_x11_device_xi_get_history (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
guint32 start, guint32 start,
guint32 stop, guint32 stop,
GdkTimeCoord ***events, GdkTimeCoord ***events,
gint *n_events); gint *n_events);
static void gdk_device_xi_get_state (GdkDevice *device, static void gdk_x11_device_xi_get_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
gdouble *axes, gdouble *axes,
GdkModifierType *mask); GdkModifierType *mask);
static void gdk_device_xi_set_window_cursor (GdkDevice *device, static void gdk_x11_device_xi_set_window_cursor (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkCursor *cursor); GdkCursor *cursor);
static void gdk_device_xi_warp (GdkDevice *device, static void gdk_x11_device_xi_warp (GdkDevice *device,
GdkScreen *screen, GdkScreen *screen,
gint x, gint x,
gint y); gint y);
static gboolean gdk_device_xi_query_state (GdkDevice *device, static gboolean gdk_x11_device_xi_query_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkWindow **root_window, GdkWindow **root_window,
GdkWindow **child_window, GdkWindow **child_window,
gint *root_x, gint *root_x,
gint *root_y, gint *root_y,
gint *win_x, gint *win_x,
gint *win_y, gint *win_y,
GdkModifierType *mask); GdkModifierType *mask);
static GdkGrabStatus gdk_device_xi_grab (GdkDevice *device, static GdkGrabStatus gdk_x11_device_xi_grab (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
gboolean owner_events, gboolean owner_events,
GdkEventMask event_mask, GdkEventMask event_mask,
GdkWindow *confine_to, GdkWindow *confine_to,
GdkCursor *cursor, GdkCursor *cursor,
guint32 time_); guint32 time_);
static void gdk_device_xi_ungrab (GdkDevice *device, static void gdk_x11_device_xi_ungrab (GdkDevice *device,
guint32 time_); guint32 time_);
static GdkWindow* gdk_device_xi_window_at_position (GdkDevice *device, static GdkWindow* gdk_x11_device_xi_window_at_position (GdkDevice *device,
gint *win_x, gint *win_x,
gint *win_y, gint *win_y,
GdkModifierType *mask, GdkModifierType *mask,
gboolean get_toplevel); gboolean get_toplevel);
static void gdk_device_xi_select_window_events (GdkDevice *device, static void gdk_x11_device_xi_select_window_events (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkEventMask mask); GdkEventMask mask);
G_DEFINE_TYPE (GdkDeviceXI, gdk_device_xi, GDK_TYPE_DEVICE) G_DEFINE_TYPE (GdkX11DeviceXI, gdk_x11_device_xi, GDK_TYPE_DEVICE)
enum { enum {
PROP_0, PROP_0,
@ -105,31 +105,31 @@ enum {
}; };
static void static void
gdk_device_xi_class_init (GdkDeviceXIClass *klass) gdk_x11_device_xi_class_init (GdkX11DeviceXIClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass); GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
quark_window_input_info = g_quark_from_static_string ("gdk-window-input-info"); quark_window_input_info = g_quark_from_static_string ("gdk-window-input-info");
object_class->constructed = gdk_device_xi_constructed; object_class->constructed = gdk_x11_device_xi_constructed;
object_class->set_property = gdk_device_xi_set_property; object_class->set_property = gdk_x11_device_xi_set_property;
object_class->get_property = gdk_device_xi_get_property; object_class->get_property = gdk_x11_device_xi_get_property;
object_class->dispose = gdk_device_xi_dispose; object_class->dispose = gdk_x11_device_xi_dispose;
device_class->get_history = gdk_device_xi_get_history; device_class->get_history = gdk_x11_device_xi_get_history;
device_class->get_state = gdk_device_xi_get_state; device_class->get_state = gdk_x11_device_xi_get_state;
device_class->set_window_cursor = gdk_device_xi_set_window_cursor; device_class->set_window_cursor = gdk_x11_device_xi_set_window_cursor;
device_class->warp = gdk_device_xi_warp; device_class->warp = gdk_x11_device_xi_warp;
device_class->query_state = gdk_device_xi_query_state; device_class->query_state = gdk_x11_device_xi_query_state;
device_class->grab = gdk_device_xi_grab; device_class->grab = gdk_x11_device_xi_grab;
device_class->ungrab = gdk_device_xi_ungrab; device_class->ungrab = gdk_x11_device_xi_ungrab;
device_class->window_at_position = gdk_device_xi_window_at_position; device_class->window_at_position = gdk_x11_device_xi_window_at_position;
device_class->select_window_events = gdk_device_xi_select_window_events; device_class->select_window_events = gdk_x11_device_xi_select_window_events;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_DEVICE_ID, PROP_DEVICE_ID,
g_param_spec_int ("device-id", g_param_spec_int ("device-id",
P_("Device ID"), P_("Device ID"),
P_("Device ID"), P_("Device ID"),
0, G_MAXINT, 0, 0, G_MAXINT, 0,
@ -137,17 +137,17 @@ gdk_device_xi_class_init (GdkDeviceXIClass *klass)
} }
static void static void
gdk_device_xi_init (GdkDeviceXI *device) gdk_x11_device_xi_init (GdkX11DeviceXI *device)
{ {
} }
static void static void
gdk_device_xi_constructed (GObject *object) gdk_x11_device_xi_constructed (GObject *object)
{ {
GdkDeviceXI *device; GdkX11DeviceXI *device;
GdkDisplay *display; GdkDisplay *display;
device = GDK_DEVICE_XI (object); device = GDK_X11_DEVICE_XI (object);
display = gdk_device_get_display (GDK_DEVICE (object)); display = gdk_device_get_display (GDK_DEVICE (object));
gdk_x11_display_error_trap_push (display); gdk_x11_display_error_trap_push (display);
@ -158,17 +158,17 @@ gdk_device_xi_constructed (GObject *object)
g_warning ("Device %s can't be opened", g_warning ("Device %s can't be opened",
gdk_device_get_name (GDK_DEVICE (device))); gdk_device_get_name (GDK_DEVICE (device)));
if (G_OBJECT_CLASS (gdk_device_xi_parent_class)->constructed) if (G_OBJECT_CLASS (gdk_x11_device_xi_parent_class)->constructed)
G_OBJECT_CLASS (gdk_device_xi_parent_class)->constructed (object); G_OBJECT_CLASS (gdk_x11_device_xi_parent_class)->constructed (object);
} }
static void static void
gdk_device_xi_set_property (GObject *object, gdk_x11_device_xi_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GdkDeviceXI *device = GDK_DEVICE_XI (object); GdkX11DeviceXI *device = GDK_X11_DEVICE_XI (object);
switch (prop_id) switch (prop_id)
{ {
@ -182,12 +182,12 @@ gdk_device_xi_set_property (GObject *object,
} }
static void static void
gdk_device_xi_get_property (GObject *object, gdk_x11_device_xi_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GdkDeviceXI *device = GDK_DEVICE_XI (object); GdkX11DeviceXI *device = GDK_X11_DEVICE_XI (object);
switch (prop_id) switch (prop_id)
{ {
@ -201,12 +201,12 @@ gdk_device_xi_get_property (GObject *object,
} }
static void static void
gdk_device_xi_dispose (GObject *object) gdk_x11_device_xi_dispose (GObject *object)
{ {
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
GdkDisplay *display; GdkDisplay *display;
device_xi = GDK_DEVICE_XI (object); device_xi = GDK_X11_DEVICE_XI (object);
display = gdk_device_get_display (GDK_DEVICE (device_xi)); display = gdk_device_get_display (GDK_DEVICE (device_xi));
if (device_xi->xdevice) if (device_xi->xdevice)
@ -221,35 +221,35 @@ gdk_device_xi_dispose (GObject *object)
device_xi->axis_data = NULL; device_xi->axis_data = NULL;
} }
G_OBJECT_CLASS (gdk_device_xi_parent_class)->dispose (object); G_OBJECT_CLASS (gdk_x11_device_xi_parent_class)->dispose (object);
} }
static gboolean static gboolean
gdk_device_xi_get_history (GdkDevice *device, gdk_x11_device_xi_get_history (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
guint32 start, guint32 start,
guint32 stop, guint32 stop,
GdkTimeCoord ***events, GdkTimeCoord ***events,
gint *n_events) gint *n_events)
{ {
GdkTimeCoord **coords; GdkTimeCoord **coords;
XDeviceTimeCoord *device_coords; XDeviceTimeCoord *device_coords;
GdkWindow *impl_window; GdkWindow *impl_window;
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
gint n_events_return; gint n_events_return;
gint mode_return; gint mode_return;
gint axis_count_return; gint axis_count_return;
gint i; gint i;
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
impl_window = _gdk_window_get_impl_window (window); impl_window = _gdk_window_get_impl_window (window);
device_coords = XGetDeviceMotionEvents (GDK_WINDOW_XDISPLAY (impl_window), device_coords = XGetDeviceMotionEvents (GDK_WINDOW_XDISPLAY (impl_window),
device_xi->xdevice, device_xi->xdevice,
start, stop, start, stop,
&n_events_return, &n_events_return,
&mode_return, &mode_return,
&axis_count_return); &axis_count_return);
if (!device_coords) if (!device_coords)
return FALSE; return FALSE;
@ -260,10 +260,10 @@ gdk_device_xi_get_history (GdkDevice *device,
for (i = 0; i < *n_events; i++) for (i = 0; i < *n_events; i++)
{ {
coords[i]->time = device_coords[i].time; coords[i]->time = device_coords[i].time;
gdk_device_xi_translate_axes (device, window, _gdk_x11_device_xi_translate_axes (device, window,
device_coords[i].data, device_coords[i].data,
coords[i]->axes, coords[i]->axes,
NULL, NULL); NULL, NULL);
} }
XFreeDeviceMotionEvents (device_coords); XFreeDeviceMotionEvents (device_coords);
@ -274,12 +274,12 @@ gdk_device_xi_get_history (GdkDevice *device,
} }
static void static void
gdk_device_xi_get_state (GdkDevice *device, gdk_x11_device_xi_get_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
gdouble *axes, gdouble *axes,
GdkModifierType *mask) GdkModifierType *mask)
{ {
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
XDeviceState *state; XDeviceState *state;
XInputClass *input_class; XInputClass *input_class;
gint i; gint i;
@ -287,7 +287,7 @@ gdk_device_xi_get_state (GdkDevice *device,
if (mask) if (mask)
gdk_window_get_pointer (window, NULL, NULL, mask); gdk_window_get_pointer (window, NULL, NULL, mask);
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
state = XQueryDeviceState (GDK_WINDOW_XDISPLAY (window), state = XQueryDeviceState (GDK_WINDOW_XDISPLAY (window),
device_xi->xdevice); device_xi->xdevice);
input_class = state->data; input_class = state->data;
@ -298,9 +298,9 @@ gdk_device_xi_get_state (GdkDevice *device,
{ {
case ValuatorClass: case ValuatorClass:
if (axes) if (axes)
gdk_device_xi_translate_axes (device, window, _gdk_x11_device_xi_translate_axes (device, window,
((XValuatorState *) input_class)->valuators, ((XValuatorState *) input_class)->valuators,
axes, NULL, NULL); axes, NULL, NULL);
break; break;
case ButtonClass: case ButtonClass:
@ -322,17 +322,17 @@ gdk_device_xi_get_state (GdkDevice *device,
} }
static void static void
gdk_device_xi_set_window_cursor (GdkDevice *device, gdk_x11_device_xi_set_window_cursor (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkCursor *cursor) GdkCursor *cursor)
{ {
} }
static void static void
gdk_device_xi_warp (GdkDevice *device, gdk_x11_device_xi_warp (GdkDevice *device,
GdkScreen *screen, GdkScreen *screen,
gint x, gint x,
gint y) gint y)
{ {
} }
@ -342,11 +342,11 @@ find_events (GdkDevice *device,
XEventClass *classes, XEventClass *classes,
int *num_classes) int *num_classes)
{ {
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
XEventClass class; XEventClass class;
gint i; gint i;
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
i = 0; i = 0;
if (mask & GDK_BUTTON_PRESS_MASK) if (mask & GDK_BUTTON_PRESS_MASK)
@ -374,10 +374,10 @@ find_events (GdkDevice *device,
/* Make sure device->motionnotify_type is set */ /* Make sure device->motionnotify_type is set */
DeviceMotionNotify (device_xi->xdevice, device_xi->motion_notify_type, class); DeviceMotionNotify (device_xi->xdevice, device_xi->motion_notify_type, class);
if (class != 0) if (class != 0)
classes[i++] = class; classes[i++] = class;
DeviceStateNotify (device_xi->xdevice, device_xi->state_notify_type, class); DeviceStateNotify (device_xi->xdevice, device_xi->state_notify_type, class);
if (class != 0) if (class != 0)
classes[i++] = class; classes[i++] = class;
} }
if (mask & GDK_KEY_PRESS_MASK) if (mask & GDK_KEY_PRESS_MASK)
@ -412,34 +412,34 @@ find_events (GdkDevice *device,
} }
static gboolean static gboolean
gdk_device_xi_query_state (GdkDevice *device, gdk_x11_device_xi_query_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkWindow **root_window, GdkWindow **root_window,
GdkWindow **child_window, GdkWindow **child_window,
gint *root_x, gint *root_x,
gint *root_y, gint *root_y,
gint *win_x, gint *win_x,
gint *win_y, gint *win_y,
GdkModifierType *mask) GdkModifierType *mask)
{ {
return FALSE; return FALSE;
} }
static GdkGrabStatus static GdkGrabStatus
gdk_device_xi_grab (GdkDevice *device, gdk_x11_device_xi_grab (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
gboolean owner_events, gboolean owner_events,
GdkEventMask event_mask, GdkEventMask event_mask,
GdkWindow *confine_to, GdkWindow *confine_to,
GdkCursor *cursor, GdkCursor *cursor,
guint32 time_) guint32 time_)
{ {
XEventClass event_classes[MAX_DEVICE_CLASSES]; XEventClass event_classes[MAX_DEVICE_CLASSES];
gint status, num_classes; gint status, num_classes;
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
GdkDisplay *display; GdkDisplay *display;
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
display = gdk_device_get_display (device); display = gdk_device_get_display (device);
find_events (device, event_mask, event_classes, &num_classes); find_events (device, event_mask, event_classes, &num_classes);
@ -462,15 +462,15 @@ gdk_device_xi_grab (GdkDevice *device,
} }
static void static void
gdk_device_xi_ungrab (GdkDevice *device, gdk_x11_device_xi_ungrab (GdkDevice *device,
guint32 time_) guint32 time_)
{ {
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
GdkDisplay *display; GdkDisplay *display;
Display *xdisplay; Display *xdisplay;
unsigned long serial; unsigned long serial;
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
display = gdk_device_get_display (device); display = gdk_device_get_display (device);
xdisplay = GDK_DISPLAY_XDISPLAY (display); xdisplay = GDK_DISPLAY_XDISPLAY (display);
@ -482,33 +482,33 @@ gdk_device_xi_ungrab (GdkDevice *device,
} }
static GdkWindow* static GdkWindow*
gdk_device_xi_window_at_position (GdkDevice *device, gdk_x11_device_xi_window_at_position (GdkDevice *device,
gint *win_x, gint *win_x,
gint *win_y, gint *win_y,
GdkModifierType *mask, GdkModifierType *mask,
gboolean get_toplevel) gboolean get_toplevel)
{ {
return NULL; return NULL;
} }
static void static void
gdk_device_xi_select_window_events (GdkDevice *device, gdk_x11_device_xi_select_window_events (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkEventMask event_mask) GdkEventMask event_mask)
{ {
XEventClass event_classes[MAX_DEVICE_CLASSES]; XEventClass event_classes[MAX_DEVICE_CLASSES];
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
gint num_classes; gint num_classes;
event_mask |= (GDK_PROXIMITY_IN_MASK | event_mask |= (GDK_PROXIMITY_IN_MASK |
GDK_PROXIMITY_OUT_MASK); GDK_PROXIMITY_OUT_MASK);
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
find_events (device, event_mask, event_classes, &num_classes); find_events (device, event_mask, event_classes, &num_classes);
XSelectExtensionEvent (GDK_WINDOW_XDISPLAY (window), XSelectExtensionEvent (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
event_classes, num_classes); event_classes, num_classes);
if (event_mask) if (event_mask)
{ {
@ -527,7 +527,7 @@ gdk_device_xi_select_window_events (GdkDevice *device,
} }
void void
gdk_device_xi_update_window_info (GdkWindow *window) _gdk_x11_device_xi_update_window_info (GdkWindow *window)
{ {
GdkWindowInputInfo *info; GdkWindowInputInfo *info;
gint root_x, root_y; gint root_x, root_y;
@ -544,9 +544,9 @@ gdk_device_xi_update_window_info (GdkWindow *window)
} }
static gboolean static gboolean
gdk_device_xi_get_window_info (GdkWindow *window, gdk_x11_device_xi_get_window_info (GdkWindow *window,
gdouble *root_x, gdouble *root_x,
gdouble *root_y) gdouble *root_y)
{ {
GdkWindowInputInfo *info; GdkWindowInputInfo *info;
@ -563,15 +563,15 @@ gdk_device_xi_get_window_info (GdkWindow *window,
} }
void void
gdk_device_xi_update_axes (GdkDevice *device, _gdk_x11_device_xi_update_axes (GdkDevice *device,
gint axes_count, gint axes_count,
gint first_axis, gint first_axis,
gint *axis_data) gint *axis_data)
{ {
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
int i; int i;
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
g_return_if_fail (first_axis >= 0 && g_return_if_fail (first_axis >= 0 &&
first_axis + axes_count <= gdk_device_get_n_axes (device)); first_axis + axes_count <= gdk_device_get_n_axes (device));
@ -583,25 +583,25 @@ gdk_device_xi_update_axes (GdkDevice *device,
} }
void void
gdk_device_xi_translate_axes (GdkDevice *device, _gdk_x11_device_xi_translate_axes (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
gint *axis_data, gint *axis_data,
gdouble *axes, gdouble *axes,
gdouble *x, gdouble *x,
gdouble *y) gdouble *y)
{ {
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
GdkWindow *impl_window; GdkWindow *impl_window;
gdouble root_x, root_y; gdouble root_x, root_y;
gdouble temp_x, temp_y; gdouble temp_x, temp_y;
gint n_axes; gint n_axes;
gint i; gint i;
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
impl_window = _gdk_window_get_impl_window (window); impl_window = _gdk_window_get_impl_window (window);
temp_x = temp_y = 0; temp_x = temp_y = 0;
if (!gdk_device_xi_get_window_info (impl_window, &root_x, &root_y)) if (!gdk_x11_device_xi_get_window_info (impl_window, &root_x, &root_y))
return; return;
n_axes = gdk_device_get_n_axes (device); n_axes = gdk_device_get_n_axes (device);

View File

@ -1,89 +0,0 @@
/* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_XI_H__
#define __GDK_DEVICE_XI_H__
#include "gdkdeviceprivate.h"
#include <X11/extensions/XInput.h>
G_BEGIN_DECLS
#define GDK_TYPE_DEVICE_XI (gdk_device_xi_get_type ())
#define GDK_DEVICE_XI(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_XI, GdkDeviceXI))
#define GDK_DEVICE_XI_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE_XI, GdkDeviceXIClass))
#define GDK_IS_DEVICE_XI(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE_XI))
#define GDK_IS_DEVICE_XI_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE_XI))
#define GDK_DEVICE_XI_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE_XI, GdkDeviceXIClass))
typedef struct _GdkDeviceXI GdkDeviceXI;
typedef struct _GdkDeviceXIClass GdkDeviceXIClass;
struct _GdkDeviceXI
{
GdkDevice parent_instance;
guint32 device_id;
XDevice *xdevice;
gint button_press_type;
gint button_release_type;
gint key_press_type;
gint key_release_type;
gint motion_notify_type;
gint proximity_in_type;
gint proximity_out_type;
gint state_notify_type;
/* minimum key code for device */
gint min_keycode;
gint *axis_data;
guint in_proximity : 1;
};
struct _GdkDeviceXIClass
{
GdkDeviceClass parent_class;
};
G_GNUC_INTERNAL
GType gdk_device_xi_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
void gdk_device_xi_update_window_info (GdkWindow *window);
G_GNUC_INTERNAL
void gdk_device_xi_update_axes (GdkDevice *device,
gint axes_count,
gint first_axis,
gint *axis_data);
G_GNUC_INTERNAL
void gdk_device_xi_translate_axes (GdkDevice *device,
GdkWindow *window,
gint *axis_data,
gdouble *axes,
gdouble *x,
gdouble *y);
G_END_DECLS
#endif /* __GDK_DEVICE_XI_H__ */

View File

@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#include "gdkdevice-xi2.h" #include "gdkx11device-xi2.h"
#include "gdkintl.h" #include "gdkintl.h"
#include "gdkasync.h" #include "gdkasync.h"
@ -27,62 +27,57 @@
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
struct _GdkDeviceXI2Private static void gdk_x11_device_xi2_get_property (GObject *object,
{ guint prop_id,
int device_id; GValue *value,
}; GParamSpec *pspec);
static void gdk_x11_device_xi2_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gdk_device_xi2_get_property (GObject *object, static void gdk_x11_device_xi2_get_state (GdkDevice *device,
guint prop_id, GdkWindow *window,
GValue *value, gdouble *axes,
GParamSpec *pspec); GdkModifierType *mask);
static void gdk_device_xi2_set_property (GObject *object, static void gdk_x11_device_xi2_set_window_cursor (GdkDevice *device,
guint prop_id, GdkWindow *window,
const GValue *value, GdkCursor *cursor);
GParamSpec *pspec); static void gdk_x11_device_xi2_warp (GdkDevice *device,
GdkScreen *screen,
gint x,
gint y);
static gboolean gdk_x11_device_xi2_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
gint *root_x,
gint *root_y,
gint *win_x,
gint *win_y,
GdkModifierType *mask);
static void gdk_device_xi2_get_state (GdkDevice *device, static GdkGrabStatus gdk_x11_device_xi2_grab (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
gdouble *axes, gboolean owner_events,
GdkModifierType *mask); GdkEventMask event_mask,
static void gdk_device_xi2_set_window_cursor (GdkDevice *device, GdkWindow *confine_to,
GdkWindow *window, GdkCursor *cursor,
GdkCursor *cursor); guint32 time_);
static void gdk_device_xi2_warp (GdkDevice *device, static void gdk_x11_device_xi2_ungrab (GdkDevice *device,
GdkScreen *screen, guint32 time_);
gint x,
gint y);
static gboolean gdk_device_xi2_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
gint *root_x,
gint *root_y,
gint *win_x,
gint *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_device_xi2_grab (GdkDevice *device, static GdkWindow * gdk_x11_device_xi2_window_at_position (GdkDevice *device,
GdkWindow *window, gint *win_x,
gboolean owner_events, gint *win_y,
GdkEventMask event_mask, GdkModifierType *mask,
GdkWindow *confine_to, gboolean get_toplevel);
GdkCursor *cursor, static void gdk_x11_device_xi2_select_window_events (GdkDevice *device,
guint32 time_); GdkWindow *window,
static void gdk_device_xi2_ungrab (GdkDevice *device, GdkEventMask event_mask);
guint32 time_);
static GdkWindow * gdk_device_xi2_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_device_xi2_select_window_events (GdkDevice *device,
GdkWindow *window,
GdkEventMask event_mask);
G_DEFINE_TYPE (GdkDeviceXI2, gdk_device_xi2, GDK_TYPE_DEVICE) G_DEFINE_TYPE (GdkX11DeviceXI2, gdk_x11_device_xi2, GDK_TYPE_DEVICE)
enum { enum {
PROP_0, PROP_0,
@ -90,58 +85,49 @@ enum {
}; };
static void static void
gdk_device_xi2_class_init (GdkDeviceXI2Class *klass) gdk_x11_device_xi2_class_init (GdkX11DeviceXI2Class *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass); GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
object_class->get_property = gdk_device_xi2_get_property; object_class->get_property = gdk_x11_device_xi2_get_property;
object_class->set_property = gdk_device_xi2_set_property; object_class->set_property = gdk_x11_device_xi2_set_property;
device_class->get_state = gdk_device_xi2_get_state; device_class->get_state = gdk_x11_device_xi2_get_state;
device_class->set_window_cursor = gdk_device_xi2_set_window_cursor; device_class->set_window_cursor = gdk_x11_device_xi2_set_window_cursor;
device_class->warp = gdk_device_xi2_warp; device_class->warp = gdk_x11_device_xi2_warp;
device_class->query_state = gdk_device_xi2_query_state; device_class->query_state = gdk_x11_device_xi2_query_state;
device_class->grab = gdk_device_xi2_grab; device_class->grab = gdk_x11_device_xi2_grab;
device_class->ungrab = gdk_device_xi2_ungrab; device_class->ungrab = gdk_x11_device_xi2_ungrab;
device_class->window_at_position = gdk_device_xi2_window_at_position; device_class->window_at_position = gdk_x11_device_xi2_window_at_position;
device_class->select_window_events = gdk_device_xi2_select_window_events; device_class->select_window_events = gdk_x11_device_xi2_select_window_events;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_DEVICE_ID, PROP_DEVICE_ID,
g_param_spec_int ("device-id", g_param_spec_int ("device-id",
P_("Device ID"), P_("Device ID"),
P_("Device identifier"), P_("Device identifier"),
0, G_MAXINT, 0, 0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_type_class_add_private (object_class, sizeof (GdkDeviceXI2Private));
} }
static void static void
gdk_device_xi2_init (GdkDeviceXI2 *device) gdk_x11_device_xi2_init (GdkX11DeviceXI2 *device)
{ {
GdkDeviceXI2Private *priv;
device->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (device,
GDK_TYPE_DEVICE_XI2,
GdkDeviceXI2Private);
} }
static void static void
gdk_device_xi2_get_property (GObject *object, gdk_x11_device_xi2_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (object);
priv = GDK_DEVICE_XI2 (object)->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_DEVICE_ID: case PROP_DEVICE_ID:
g_value_set_int (value, priv->device_id); g_value_set_int (value, device_xi2->device_id);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -150,19 +136,17 @@ gdk_device_xi2_get_property (GObject *object,
} }
static void static void
gdk_device_xi2_set_property (GObject *object, gdk_x11_device_xi2_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (object);
priv = GDK_DEVICE_XI2 (object)->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_DEVICE_ID: case PROP_DEVICE_ID:
priv->device_id = g_value_get_int (value); device_xi2->device_id = g_value_get_int (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -171,23 +155,22 @@ gdk_device_xi2_set_property (GObject *object,
} }
static void static void
gdk_device_xi2_get_state (GdkDevice *device, gdk_x11_device_xi2_get_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
gdouble *axes, gdouble *axes,
GdkModifierType *mask) GdkModifierType *mask)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display; GdkDisplay *display;
XIDeviceInfo *info; XIDeviceInfo *info;
gint i, j, ndevices; gint i, j, ndevices;
priv = GDK_DEVICE_XI2 (device)->priv;
display = gdk_device_get_display (device); display = gdk_device_get_display (device);
if (axes) if (axes)
{ {
info = XIQueryDevice(GDK_DISPLAY_XDISPLAY (display), info = XIQueryDevice(GDK_DISPLAY_XDISPLAY (display),
priv->device_id, &ndevices); device_xi2->device_id, &ndevices);
for (i = 0, j = 0; i < info->num_classes; i++) for (i = 0, j = 0; i < info->num_classes; i++)
{ {
@ -232,71 +215,66 @@ gdk_device_xi2_get_state (GdkDevice *device,
} }
if (mask) if (mask)
gdk_device_xi2_query_state (device, window, gdk_x11_device_xi2_query_state (device, window,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
mask); mask);
} }
static void static void
gdk_device_xi2_set_window_cursor (GdkDevice *device, gdk_x11_device_xi2_set_window_cursor (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkCursor *cursor) GdkCursor *cursor)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
priv = GDK_DEVICE_XI2 (device)->priv;
/* Non-master devices don't have a cursor */ /* Non-master devices don't have a cursor */
if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER) if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER)
return; return;
if (cursor) if (cursor)
{ XIDefineCursor (GDK_WINDOW_XDISPLAY (window),
XIDefineCursor (GDK_WINDOW_XDISPLAY (window), device_xi2->device_id,
priv->device_id, GDK_WINDOW_XID (window),
GDK_WINDOW_XID (window), gdk_x11_cursor_get_xcursor (cursor));
gdk_x11_cursor_get_xcursor (cursor));
}
else else
XIUndefineCursor (GDK_WINDOW_XDISPLAY (window), XIUndefineCursor (GDK_WINDOW_XDISPLAY (window),
priv->device_id, device_xi2->device_id,
GDK_WINDOW_XID (window)); GDK_WINDOW_XID (window));
} }
static void static void
gdk_device_xi2_warp (GdkDevice *device, gdk_x11_device_xi2_warp (GdkDevice *device,
GdkScreen *screen, GdkScreen *screen,
gint x, gint x,
gint y) gint y)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
Window dest; Window dest;
priv = GDK_DEVICE_XI2 (device)->priv;
dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen)); dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
XIWarpPointer (GDK_SCREEN_XDISPLAY (screen), XIWarpPointer (GDK_SCREEN_XDISPLAY (screen),
priv->device_id, device_xi2->device_id,
None, dest, None, dest,
0, 0, 0, 0, x, y); 0, 0, 0, 0, x, y);
} }
static gboolean static gboolean
gdk_device_xi2_query_state (GdkDevice *device, gdk_x11_device_xi2_query_state (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkWindow **root_window, GdkWindow **root_window,
GdkWindow **child_window, GdkWindow **child_window,
gint *root_x, gint *root_x,
gint *root_y, gint *root_y,
gint *win_x, gint *win_x,
gint *win_y, gint *win_y,
GdkModifierType *mask) GdkModifierType *mask)
{ {
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display; GdkDisplay *display;
GdkScreen *default_screen; GdkScreen *default_screen;
GdkDeviceXI2Private *priv;
Window xroot_window, xchild_window; Window xroot_window, xchild_window;
gdouble xroot_x, xroot_y, xwin_x, xwin_y; gdouble xroot_x, xroot_y, xwin_x, xwin_y;
XIButtonState button_state; XIButtonState button_state;
@ -306,21 +284,18 @@ gdk_device_xi2_query_state (GdkDevice *device,
if (!window || GDK_WINDOW_DESTROYED (window)) if (!window || GDK_WINDOW_DESTROYED (window))
return FALSE; return FALSE;
priv = GDK_DEVICE_XI2 (device)->priv;
display = gdk_window_get_display (window); display = gdk_window_get_display (window);
default_screen = gdk_display_get_default_screen (display); default_screen = gdk_display_get_default_screen (display);
if (G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client)) if (G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
{ {
if (!XIQueryPointer (GDK_WINDOW_XDISPLAY (window), if (!XIQueryPointer (GDK_WINDOW_XDISPLAY (window),
priv->device_id, device_xi2->device_id,
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
&xroot_window, &xroot_window,
&xchild_window, &xchild_window,
&xroot_x, &xroot_x, &xroot_y,
&xroot_y, &xwin_x, &xwin_y,
&xwin_x,
&xwin_y,
&button_state, &button_state,
&mod_state, &mod_state,
&group_state)) &group_state))
@ -339,14 +314,12 @@ gdk_device_xi2_query_state (GdkDevice *device,
w = XCreateWindow (xdisplay, xwindow, 0, 0, 1, 1, 0, w = XCreateWindow (xdisplay, xwindow, 0, 0, 1, 1, 0,
CopyFromParent, InputOnly, CopyFromParent, CopyFromParent, InputOnly, CopyFromParent,
0, &attributes); 0, &attributes);
XIQueryPointer (xdisplay, priv->device_id, XIQueryPointer (xdisplay, device_xi2->device_id,
w, w,
&xroot_window, &xroot_window,
&xchild_window, &xchild_window,
&xroot_x, &xroot_x, &xroot_y,
&xroot_y, &xwin_x, &xwin_y,
&xwin_x,
&xwin_y,
&button_state, &button_state,
&mod_state, &mod_state,
&group_state); &group_state);
@ -372,28 +345,27 @@ gdk_device_xi2_query_state (GdkDevice *device,
*win_y = (gint) xwin_y; *win_y = (gint) xwin_y;
if (mask) if (mask)
*mask = gdk_device_xi2_translate_state (&mod_state, &button_state); *mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state);
return TRUE; return TRUE;
} }
static GdkGrabStatus static GdkGrabStatus
gdk_device_xi2_grab (GdkDevice *device, gdk_x11_device_xi2_grab (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
gboolean owner_events, gboolean owner_events,
GdkEventMask event_mask, GdkEventMask event_mask,
GdkWindow *confine_to, GdkWindow *confine_to,
GdkCursor *cursor, GdkCursor *cursor,
guint32 time_) guint32 time_)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display; GdkDisplay *display;
XIEventMask mask; XIEventMask mask;
Window xwindow; Window xwindow;
Cursor xcursor; Cursor xcursor;
gint status; gint status;
priv = GDK_DEVICE_XI2 (device)->priv;
display = gdk_device_get_display (device); display = gdk_device_get_display (device);
/* FIXME: confine_to is actually unused */ /* FIXME: confine_to is actually unused */
@ -408,8 +380,8 @@ gdk_device_xi2_grab (GdkDevice *device,
xcursor = gdk_x11_cursor_get_xcursor (cursor); xcursor = gdk_x11_cursor_get_xcursor (cursor);
} }
mask.deviceid = priv->device_id; mask.deviceid = device_xi2->device_id;
mask.mask = gdk_device_xi2_translate_event_mask (event_mask, &mask.mask_len); mask.mask = _gdk_x11_device_xi2_translate_event_mask (event_mask, &mask.mask_len);
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
if (_gdk_debug_flags & GDK_DEBUG_NOGRABS) if (_gdk_debug_flags & GDK_DEBUG_NOGRABS)
@ -417,7 +389,7 @@ gdk_device_xi2_grab (GdkDevice *device,
else else
#endif #endif
status = XIGrabDevice (GDK_DISPLAY_XDISPLAY (display), status = XIGrabDevice (GDK_DISPLAY_XDISPLAY (display),
priv->device_id, device_xi2->device_id,
xwindow, xwindow,
time_, time_,
xcursor, xcursor,
@ -433,30 +405,29 @@ gdk_device_xi2_grab (GdkDevice *device,
} }
static void static void
gdk_device_xi2_ungrab (GdkDevice *device, gdk_x11_device_xi2_ungrab (GdkDevice *device,
guint32 time_) guint32 time_)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display; GdkDisplay *display;
gulong serial; gulong serial;
priv = GDK_DEVICE_XI2 (device)->priv;
display = gdk_device_get_display (device); display = gdk_device_get_display (device);
serial = NextRequest (GDK_DISPLAY_XDISPLAY (display)); serial = NextRequest (GDK_DISPLAY_XDISPLAY (display));
XIUngrabDevice (GDK_DISPLAY_XDISPLAY (display), priv->device_id, time_); XIUngrabDevice (GDK_DISPLAY_XDISPLAY (display), device_xi2->device_id, time_);
_gdk_x11_display_update_grab_info_ungrab (display, device, time_, serial); _gdk_x11_display_update_grab_info_ungrab (display, device, time_, serial);
} }
static GdkWindow * static GdkWindow *
gdk_device_xi2_window_at_position (GdkDevice *device, gdk_x11_device_xi2_window_at_position (GdkDevice *device,
gint *win_x, gint *win_x,
gint *win_y, gint *win_y,
GdkModifierType *mask, GdkModifierType *mask,
gboolean get_toplevel) gboolean get_toplevel)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
GdkDisplay *display; GdkDisplay *display;
GdkScreen *screen; GdkScreen *screen;
Display *xdisplay; Display *xdisplay;
@ -467,7 +438,6 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
XIModifierState mod_state; XIModifierState mod_state;
XIGroupState group_state; XIGroupState group_state;
priv = GDK_DEVICE_XI2 (device)->priv;
display = gdk_device_get_display (device); display = gdk_device_get_display (device);
screen = gdk_display_get_default_screen (display); screen = gdk_display_get_default_screen (display);
@ -484,7 +454,7 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
if (G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client)) if (G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
{ {
XIQueryPointer (xdisplay, XIQueryPointer (xdisplay,
priv->device_id, device_xi2->device_id,
xwindow, xwindow,
&root, &child, &root, &child,
&xroot_x, &xroot_y, &xroot_x, &xroot_y,
@ -518,7 +488,7 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
xwindow = GDK_WINDOW_XID (window); xwindow = GDK_WINDOW_XID (window);
gdk_x11_display_error_trap_push (display); gdk_x11_display_error_trap_push (display);
XIQueryPointer (xdisplay, XIQueryPointer (xdisplay,
priv->device_id, device_xi2->device_id,
xwindow, xwindow,
&root, &child, &root, &child,
&xroot_x, &xroot_y, &xroot_x, &xroot_y,
@ -545,7 +515,7 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
0, &attributes); 0, &attributes);
XMapWindow (xdisplay, w); XMapWindow (xdisplay, w);
XIQueryPointer (xdisplay, XIQueryPointer (xdisplay,
priv->device_id, device_xi2->device_id,
xwindow, xwindow,
&root, &child, &root, &child,
&xroot_x, &xroot_y, &xroot_x, &xroot_y,
@ -575,7 +545,7 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
last = xwindow; last = xwindow;
gdk_x11_display_error_trap_push (display); gdk_x11_display_error_trap_push (display);
XIQueryPointer (xdisplay, XIQueryPointer (xdisplay,
priv->device_id, device_xi2->device_id,
xwindow, xwindow,
&root, &xwindow, &root, &xwindow,
&xroot_x, &xroot_y, &xroot_x, &xroot_y,
@ -606,23 +576,21 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
*win_y = (window) ? (gint) xwin_y : -1; *win_y = (window) ? (gint) xwin_y : -1;
if (mask) if (mask)
*mask = gdk_device_xi2_translate_state (&mod_state, &button_state); *mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state);
return window; return window;
} }
static void static void
gdk_device_xi2_select_window_events (GdkDevice *device, gdk_x11_device_xi2_select_window_events (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkEventMask event_mask) GdkEventMask event_mask)
{ {
GdkDeviceXI2Private *priv; GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
XIEventMask evmask; XIEventMask evmask;
priv = GDK_DEVICE_XI2 (device)->priv; evmask.deviceid = device_xi2->device_id;
evmask.mask = _gdk_x11_device_xi2_translate_event_mask (event_mask, &evmask.mask_len);
evmask.deviceid = priv->device_id;
evmask.mask = gdk_device_xi2_translate_event_mask (event_mask, &evmask.mask_len);
XISelectEvents (GDK_WINDOW_XDISPLAY (window), XISelectEvents (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
@ -632,8 +600,8 @@ gdk_device_xi2_select_window_events (GdkDevice *device,
} }
guchar * guchar *
gdk_device_xi2_translate_event_mask (GdkEventMask event_mask, _gdk_x11_device_xi2_translate_event_mask (GdkEventMask event_mask,
int *len) gint *len)
{ {
guchar *mask; guchar *mask;
@ -688,8 +656,8 @@ gdk_device_xi2_translate_event_mask (GdkEventMask event_mask,
} }
guint guint
gdk_device_xi2_translate_state (XIModifierState *mods_state, _gdk_x11_device_xi2_translate_state (XIModifierState *mods_state,
XIButtonState *buttons_state) XIButtonState *buttons_state)
{ {
guint state = 0; guint state = 0;

View File

@ -1,66 +0,0 @@
/* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_XI2_H__
#define __GDK_DEVICE_XI2_H__
#include "gdkdeviceprivate.h"
#include <X11/extensions/XInput2.h>
G_BEGIN_DECLS
#define GDK_TYPE_DEVICE_XI2 (gdk_device_xi2_get_type ())
#define GDK_DEVICE_XI2(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_XI2, GdkDeviceXI2))
#define GDK_DEVICE_XI2_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE_XI2, GdkDeviceXI2Class))
#define GDK_IS_DEVICE_XI2(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE_XI2))
#define GDK_IS_DEVICE_XI2_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE_XI2))
#define GDK_DEVICE_XI2_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE_XI2, GdkDeviceXI2Class))
typedef struct _GdkDeviceXI2 GdkDeviceXI2;
typedef struct _GdkDeviceXI2Private GdkDeviceXI2Private;
typedef struct _GdkDeviceXI2Class GdkDeviceXI2Class;
struct _GdkDeviceXI2
{
GdkDevice parent_instance;
/*< private >*/
GdkDeviceXI2Private *priv;
};
struct _GdkDeviceXI2Class
{
GdkDeviceClass parent_class;
};
G_GNUC_INTERNAL
GType gdk_device_xi2_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
guchar * gdk_device_xi2_translate_event_mask (GdkEventMask event_mask,
int *len);
G_GNUC_INTERNAL
guint gdk_device_xi2_translate_state (XIModifierState *mods_state,
XIButtonState *buttons_state);
G_END_DECLS
#endif /* __GDK_DEVICE_XI2_H__ */

View File

@ -21,9 +21,9 @@
#include "gdkx11devicemanager-core.h" #include "gdkx11devicemanager-core.h"
#ifdef XINPUT_XFREE #ifdef XINPUT_XFREE
#include "gdkdevicemanager-xi.h" #include "gdkx11devicemanager-xi.h"
#ifdef XINPUT_2 #ifdef XINPUT_2
#include "gdkdevicemanager-xi2.h" #include "gdkx11devicemanager-xi2.h"
#endif #endif
#endif #endif
#include "gdkinternals.h" #include "gdkinternals.h"
@ -52,11 +52,11 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
if (!_gdk_disable_multidevice && if (!_gdk_disable_multidevice &&
XIQueryVersion (xdisplay, &major, &minor) != BadRequest) XIQueryVersion (xdisplay, &major, &minor) != BadRequest)
{ {
GdkDeviceManagerXI2 *device_manager_xi2; GdkX11DeviceManagerXI2 *device_manager_xi2;
GDK_NOTE (INPUT, g_print ("Creating XI2 device manager\n")); GDK_NOTE (INPUT, g_print ("Creating XI2 device manager\n"));
device_manager_xi2 = g_object_new (GDK_TYPE_DEVICE_MANAGER_XI2, device_manager_xi2 = g_object_new (GDK_TYPE_X11_DEVICE_MANAGER_XI2,
"display", display, "display", display,
NULL); NULL);
device_manager_xi2->opcode = opcode; device_manager_xi2->opcode = opcode;
@ -68,7 +68,7 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
{ {
GDK_NOTE (INPUT, g_print ("Creating XI device manager\n")); GDK_NOTE (INPUT, g_print ("Creating XI device manager\n"));
return g_object_new (GDK_TYPE_DEVICE_MANAGER_XI, return g_object_new (GDK_TYPE_X11_DEVICE_MANAGER_XI,
"display", display, "display", display,
"event-base", firstevent, "event-base", firstevent,
NULL); NULL);

View File

@ -19,17 +19,17 @@
#include "config.h" #include "config.h"
#include "gdkdevicemanager-xi.h" #include "gdkx11devicemanager-xi.h"
#include "gdkx11device-xi.h"
#include "gdkeventtranslator.h" #include "gdkeventtranslator.h"
#include "gdkdevice-xi.h"
#include "gdkintl.h" #include "gdkintl.h"
#include "gdkprivate-x11.h" #include "gdkprivate-x11.h"
#include <X11/extensions/XInput.h> #include <X11/extensions/XInput.h>
struct _GdkDeviceManagerXIPrivate struct _GdkX11DeviceManagerXIPrivate
{ {
GHashTable *id_table; GHashTable *id_table;
gint event_base; gint event_base;
@ -37,29 +37,29 @@ struct _GdkDeviceManagerXIPrivate
gboolean ignore_core_events; gboolean ignore_core_events;
}; };
static void gdk_device_manager_xi_constructed (GObject *object); static void gdk_x11_device_manager_xi_constructed (GObject *object);
static void gdk_device_manager_xi_dispose (GObject *object); static void gdk_x11_device_manager_xi_dispose (GObject *object);
static void gdk_device_manager_xi_set_property (GObject *object, static void gdk_x11_device_manager_xi_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gdk_device_manager_xi_get_property (GObject *object, static void gdk_x11_device_manager_xi_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gdk_device_manager_xi_event_translator_init (GdkEventTranslatorIface *iface); static void gdk_x11_device_manager_xi_event_translator_init (GdkEventTranslatorIface *iface);
static gboolean gdk_device_manager_xi_translate_event (GdkEventTranslator *translator, static gboolean gdk_x11_device_manager_xi_translate_event (GdkEventTranslator *translator,
GdkDisplay *display, GdkDisplay *display,
GdkEvent *event, GdkEvent *event,
XEvent *xevent); XEvent *xevent);
static GList * gdk_device_manager_xi_list_devices (GdkDeviceManager *device_manager, static GList * gdk_x11_device_manager_xi_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type); GdkDeviceType type);
G_DEFINE_TYPE_WITH_CODE (GdkDeviceManagerXI, gdk_device_manager_xi, GDK_TYPE_X11_DEVICE_MANAGER_CORE, G_DEFINE_TYPE_WITH_CODE (GdkX11DeviceManagerXI, gdk_x11_device_manager_xi, GDK_TYPE_X11_DEVICE_MANAGER_CORE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR, G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
gdk_device_manager_xi_event_translator_init)) gdk_x11_device_manager_xi_event_translator_init))
enum { enum {
PROP_0, PROP_0,
@ -67,27 +67,27 @@ enum {
}; };
static void static void
gdk_device_manager_xi_class_init (GdkDeviceManagerXIClass *klass) gdk_x11_device_manager_xi_class_init (GdkX11DeviceManagerXIClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass); GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass);
object_class->constructed = gdk_device_manager_xi_constructed; object_class->constructed = gdk_x11_device_manager_xi_constructed;
object_class->dispose = gdk_device_manager_xi_dispose; object_class->dispose = gdk_x11_device_manager_xi_dispose;
object_class->set_property = gdk_device_manager_xi_set_property; object_class->set_property = gdk_x11_device_manager_xi_set_property;
object_class->get_property = gdk_device_manager_xi_get_property; object_class->get_property = gdk_x11_device_manager_xi_get_property;
device_manager_class->list_devices = gdk_device_manager_xi_list_devices; device_manager_class->list_devices = gdk_x11_device_manager_xi_list_devices;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_EVENT_BASE, PROP_EVENT_BASE,
g_param_spec_int ("event-base", g_param_spec_int ("event-base",
P_("Event base"), P_("Event base"),
P_("Event base for XInput events"), P_("Event base for XInput events"),
0, G_MAXINT, 0, 0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_type_class_add_private (object_class, sizeof (GdkDeviceManagerXIPrivate)); g_type_class_add_private (object_class, sizeof (GdkX11DeviceManagerXIPrivate));
} }
static GdkFilterReturn static GdkFilterReturn
@ -107,19 +107,19 @@ window_input_info_filter (GdkXEvent *xevent,
window = gdk_x11_window_lookup_for_display (display, xev->xany.window); window = gdk_x11_window_lookup_for_display (display, xev->xany.window);
if (window && xev->type == ConfigureNotify) if (window && xev->type == ConfigureNotify)
gdk_device_xi_update_window_info (window); _gdk_x11_device_xi_update_window_info (window);
return GDK_FILTER_CONTINUE; return GDK_FILTER_CONTINUE;
} }
static void static void
gdk_device_manager_xi_init (GdkDeviceManagerXI *device_manager) gdk_x11_device_manager_xi_init (GdkX11DeviceManagerXI *device_manager)
{ {
GdkDeviceManagerXIPrivate *priv; GdkX11DeviceManagerXIPrivate *priv;
device_manager->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (device_manager, device_manager->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (device_manager,
GDK_TYPE_DEVICE_MANAGER_XI, GDK_TYPE_X11_DEVICE_MANAGER_XI,
GdkDeviceManagerXIPrivate); GdkX11DeviceManagerXIPrivate);
priv->id_table = g_hash_table_new_full (NULL, NULL, NULL, priv->id_table = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_object_unref); (GDestroyNotify) g_object_unref);
@ -131,72 +131,73 @@ static void
translate_class_info (GdkDevice *device, translate_class_info (GdkDevice *device,
XDeviceInfo *info) XDeviceInfo *info)
{ {
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
XAnyClassPtr class; XAnyClassPtr class;
gint i, j; gint i, j;
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
class = info->inputclassinfo; class = info->inputclassinfo;
for (i = 0; i < info->num_classes; i++) for (i = 0; i < info->num_classes; i++)
{ {
switch (class->class) { switch (class->class)
case ButtonClass: {
break; case ButtonClass:
case KeyClass: break;
{ case KeyClass:
XKeyInfo *xki = (XKeyInfo *)class; {
guint num_keys; XKeyInfo *xki = (XKeyInfo *)class;
guint num_keys;
num_keys = xki->max_keycode - xki->min_keycode + 1; num_keys = xki->max_keycode - xki->min_keycode + 1;
_gdk_device_set_keys (device, num_keys); _gdk_device_set_keys (device, num_keys);
device_xi->min_keycode = xki->min_keycode; device_xi->min_keycode = xki->min_keycode;
break; break;
} }
case ValuatorClass: case ValuatorClass:
{ {
XValuatorInfo *xvi = (XValuatorInfo *)class; XValuatorInfo *xvi = (XValuatorInfo *)class;
for (j = 0; j < xvi->num_axes; j++) for (j = 0; j < xvi->num_axes; j++)
{ {
GdkAxisUse use; GdkAxisUse use;
switch (j) switch (j)
{ {
case 0: case 0:
use = GDK_AXIS_X; use = GDK_AXIS_X;
break; break;
case 1: case 1:
use = GDK_AXIS_Y; use = GDK_AXIS_Y;
break; break;
case 2: case 2:
use = GDK_AXIS_PRESSURE; use = GDK_AXIS_PRESSURE;
break; break;
case 3: case 3:
use = GDK_AXIS_XTILT; use = GDK_AXIS_XTILT;
break; break;
case 4: case 4:
use = GDK_AXIS_YTILT; use = GDK_AXIS_YTILT;
break; break;
case 5: case 5:
use = GDK_AXIS_WHEEL; use = GDK_AXIS_WHEEL;
break; break;
default: default:
use = GDK_AXIS_IGNORE; use = GDK_AXIS_IGNORE;
} }
_gdk_device_add_axis (device, _gdk_device_add_axis (device,
GDK_NONE, GDK_NONE,
use, use,
xvi->axes[j].min_value, xvi->axes[j].min_value,
xvi->axes[j].max_value, xvi->axes[j].max_value,
xvi->axes[j].resolution); xvi->axes[j].resolution);
} }
break; break;
} }
} }
class = (XAnyClassPtr) (((char *) class) + class->length); class = (XAnyClassPtr) (((char *) class) + class->length);
@ -242,7 +243,7 @@ create_device (GdkDeviceManager *device_manager,
g_free (tmp_name); g_free (tmp_name);
} }
device = g_object_new (GDK_TYPE_DEVICE_XI, device = g_object_new (GDK_TYPE_X11_DEVICE_XI,
"name", info->name, "name", info->name,
"type", GDK_DEVICE_TYPE_FLOATING, "type", GDK_DEVICE_TYPE_FLOATING,
"input-source", input_source, "input-source", input_source,
@ -258,16 +259,16 @@ create_device (GdkDeviceManager *device_manager,
} }
static void static void
gdk_device_manager_xi_constructed (GObject *object) gdk_x11_device_manager_xi_constructed (GObject *object)
{ {
GdkDeviceManagerXIPrivate *priv; GdkX11DeviceManagerXIPrivate *priv;
XDeviceInfo *devices; XDeviceInfo *devices;
gint i, num_devices; gint i, num_devices;
GdkDisplay *display; GdkDisplay *display;
priv = GDK_DEVICE_MANAGER_XI (object)->priv; priv = GDK_X11_DEVICE_MANAGER_XI (object)->priv;
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object)); display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object));
devices = XListInputDevices(GDK_DISPLAY_XDISPLAY (display), &num_devices); devices = XListInputDevices (GDK_DISPLAY_XDISPLAY (display), &num_devices);
for(i = 0; i < num_devices; i++) for(i = 0; i < num_devices; i++)
{ {
@ -284,22 +285,22 @@ gdk_device_manager_xi_constructed (GObject *object)
} }
} }
XFreeDeviceList(devices); XFreeDeviceList (devices);
gdk_x11_register_standard_event_type (display, gdk_x11_register_standard_event_type (display,
priv->event_base, priv->event_base,
15 /* Number of events */); 15 /* Number of events */);
if (G_OBJECT_CLASS (gdk_device_manager_xi_parent_class)->constructed) if (G_OBJECT_CLASS (gdk_x11_device_manager_xi_parent_class)->constructed)
G_OBJECT_CLASS (gdk_device_manager_xi_parent_class)->constructed (object); G_OBJECT_CLASS (gdk_x11_device_manager_xi_parent_class)->constructed (object);
} }
static void static void
gdk_device_manager_xi_dispose (GObject *object) gdk_x11_device_manager_xi_dispose (GObject *object)
{ {
GdkDeviceManagerXIPrivate *priv; GdkX11DeviceManagerXIPrivate *priv;
priv = GDK_DEVICE_MANAGER_XI (object)->priv; priv = GDK_X11_DEVICE_MANAGER_XI (object)->priv;
g_list_foreach (priv->devices, (GFunc) g_object_unref, NULL); g_list_foreach (priv->devices, (GFunc) g_object_unref, NULL);
g_list_free (priv->devices); g_list_free (priv->devices);
@ -313,18 +314,18 @@ gdk_device_manager_xi_dispose (GObject *object)
gdk_window_remove_filter (NULL, window_input_info_filter, object); gdk_window_remove_filter (NULL, window_input_info_filter, object);
G_OBJECT_CLASS (gdk_device_manager_xi_parent_class)->dispose (object); G_OBJECT_CLASS (gdk_x11_device_manager_xi_parent_class)->dispose (object);
} }
static void static void
gdk_device_manager_xi_set_property (GObject *object, gdk_x11_device_manager_xi_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GdkDeviceManagerXIPrivate *priv; GdkX11DeviceManagerXIPrivate *priv;
priv = GDK_DEVICE_MANAGER_XI (object)->priv; priv = GDK_X11_DEVICE_MANAGER_XI (object)->priv;
switch (prop_id) switch (prop_id)
{ {
@ -338,14 +339,14 @@ gdk_device_manager_xi_set_property (GObject *object,
} }
static void static void
gdk_device_manager_xi_get_property (GObject *object, gdk_x11_device_manager_xi_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GdkDeviceManagerXIPrivate *priv; GdkX11DeviceManagerXIPrivate *priv;
priv = GDK_DEVICE_MANAGER_XI (object)->priv; priv = GDK_X11_DEVICE_MANAGER_XI (object)->priv;
switch (prop_id) switch (prop_id)
{ {
@ -359,9 +360,9 @@ gdk_device_manager_xi_get_property (GObject *object,
} }
static void static void
gdk_device_manager_xi_event_translator_init (GdkEventTranslatorIface *iface) gdk_x11_device_manager_xi_event_translator_init (GdkEventTranslatorIface *iface)
{ {
iface->translate_event = gdk_device_manager_xi_translate_event; iface->translate_event = gdk_x11_device_manager_xi_translate_event;
} }
/* combine the state of the core device and the device state /* combine the state of the core device and the device state
@ -377,13 +378,13 @@ translate_state (guint state, guint device_state)
} }
static GdkDevice * static GdkDevice *
lookup_device (GdkDeviceManagerXI *device_manager, lookup_device (GdkX11DeviceManagerXI *device_manager,
XEvent *xevent) XEvent *xevent)
{ {
GdkDeviceManagerXIPrivate *priv; GdkX11DeviceManagerXIPrivate *priv;
guint32 device_id; guint32 device_id;
priv = GDK_DEVICE_MANAGER_XI (device_manager)->priv; priv = GDK_X11_DEVICE_MANAGER_XI (device_manager)->priv;
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent - /* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
but it's potentially faster than scanning through the types of but it's potentially faster than scanning through the types of
@ -395,20 +396,20 @@ lookup_device (GdkDeviceManagerXI *device_manager,
} }
static gboolean static gboolean
gdk_device_manager_xi_translate_event (GdkEventTranslator *translator, gdk_x11_device_manager_xi_translate_event (GdkEventTranslator *translator,
GdkDisplay *display, GdkDisplay *display,
GdkEvent *event, GdkEvent *event,
XEvent *xevent) XEvent *xevent)
{ {
GdkDeviceManagerXIPrivate *priv; GdkX11DeviceManagerXIPrivate *priv;
GdkDeviceManagerXI *device_manager; GdkX11DeviceManagerXI *device_manager;
GdkEventTranslatorIface *parent_iface; GdkEventTranslatorIface *parent_iface;
GdkDeviceXI *device_xi; GdkX11DeviceXI *device_xi;
GdkDevice *device; GdkDevice *device;
GdkWindow *window; GdkWindow *window;
parent_iface = g_type_interface_peek_parent (GDK_EVENT_TRANSLATOR_GET_IFACE (translator)); parent_iface = g_type_interface_peek_parent (GDK_EVENT_TRANSLATOR_GET_IFACE (translator));
device_manager = GDK_DEVICE_MANAGER_XI (translator); device_manager = GDK_X11_DEVICE_MANAGER_XI (translator);
priv = device_manager->priv; priv = device_manager->priv;
if (!priv->ignore_core_events && if (!priv->ignore_core_events &&
@ -416,7 +417,7 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
return TRUE; return TRUE;
device = lookup_device (device_manager, xevent); device = lookup_device (device_manager, xevent);
device_xi = GDK_DEVICE_XI (device); device_xi = GDK_X11_DEVICE_XI (device);
if (!device) if (!device)
return FALSE; return FALSE;
@ -442,35 +443,35 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
event->button.y_root = (gdouble) xdbe->y_root; event->button.y_root = (gdouble) xdbe->y_root;
event->button.axes = g_new0 (gdouble, gdk_device_get_n_axes (device)); event->button.axes = g_new0 (gdouble, gdk_device_get_n_axes (device));
gdk_device_xi_update_axes (device, xdbe->axes_count, _gdk_x11_device_xi_update_axes (device, xdbe->axes_count,
xdbe->first_axis, xdbe->axis_data); xdbe->first_axis, xdbe->axis_data);
gdk_device_xi_translate_axes (device, window, _gdk_x11_device_xi_translate_axes (device, window,
device_xi->axis_data, device_xi->axis_data,
event->button.axes, event->button.axes,
&event->button.x, &event->button.x,
&event->button.y); &event->button.y);
event->button.state = translate_state (xdbe->state, xdbe->device_state); event->button.state = translate_state (xdbe->state, xdbe->device_state);
event->button.button = xdbe->button; event->button.button = xdbe->button;
if (event->button.type == GDK_BUTTON_PRESS) if (event->button.type == GDK_BUTTON_PRESS)
_gdk_event_button_generate (gdk_window_get_display (event->button.window), _gdk_event_button_generate (gdk_window_get_display (event->button.window),
event); event);
GDK_NOTE (EVENTS, GDK_NOTE (EVENTS,
g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n", g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n",
(event->button.type == GDK_BUTTON_PRESS) ? "press" : "release", (event->button.type == GDK_BUTTON_PRESS) ? "press" : "release",
xdbe->window, xdbe->window,
xdbe->deviceid, xdbe->deviceid,
event->button.x, event->button.y, event->button.x, event->button.y,
xdbe->button)); xdbe->button));
/* Update the timestamp of the latest user interaction, if the event has /* Update the timestamp of the latest user interaction, if the event has
* a valid timestamp. * a valid timestamp.
*/ */
if (gdk_event_get_time (event) != GDK_CURRENT_TIME) if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
gdk_x11_window_set_user_time (gdk_window_get_toplevel (window), gdk_x11_window_set_user_time (gdk_window_get_toplevel (window),
gdk_event_get_time (event)); gdk_event_get_time (event));
return TRUE; return TRUE;
} }
@ -480,33 +481,33 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *) xevent; XDeviceKeyEvent *xdke = (XDeviceKeyEvent *) xevent;
GDK_NOTE (EVENTS, GDK_NOTE (EVENTS,
g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n", g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
(event->key.type == GDK_KEY_PRESS) ? "press" : "release", (event->key.type == GDK_KEY_PRESS) ? "press" : "release",
xdke->window, xdke->window,
xdke->deviceid, xdke->deviceid,
xdke->keycode)); xdke->keycode));
if (xdke->keycode < device_xi->min_keycode || if (xdke->keycode < device_xi->min_keycode ||
xdke->keycode >= device_xi->min_keycode + gdk_device_get_n_keys (device)) xdke->keycode >= device_xi->min_keycode + gdk_device_get_n_keys (device))
{ {
g_warning ("Invalid device key code received"); g_warning ("Invalid device key code received");
return FALSE; return FALSE;
} }
gdk_device_get_key (device, xdke->keycode - device_xi->min_keycode, gdk_device_get_key (device, xdke->keycode - device_xi->min_keycode,
&event->key.keyval, &event->key.keyval,
&event->key.state); &event->key.state);
if (event->key.keyval == 0) if (event->key.keyval == 0)
{ {
GDK_NOTE (EVENTS, GDK_NOTE (EVENTS,
g_print ("\t\ttranslation - NONE\n")); g_print ("\t\ttranslation - NONE\n"));
return FALSE; return FALSE;
} }
event->key.type = (xdke->type == device_xi->key_press_type) ? event->key.type = (xdke->type == device_xi->key_press_type) ?
GDK_KEY_PRESS : GDK_KEY_RELEASE; GDK_KEY_PRESS : GDK_KEY_RELEASE;
event->key.window = g_object_ref (window); event->key.window = g_object_ref (window);
event->key.time = xdke->time; event->key.time = xdke->time;
@ -515,29 +516,29 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
/* Add a string translation for the key event */ /* Add a string translation for the key event */
if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF)) if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF))
{ {
event->key.length = 1; event->key.length = 1;
event->key.string = g_new (gchar, 2); event->key.string = g_new (gchar, 2);
event->key.string[0] = (gchar) event->key.keyval; event->key.string[0] = (gchar) event->key.keyval;
event->key.string[1] = 0; event->key.string[1] = 0;
} }
else else
{ {
event->key.length = 0; event->key.length = 0;
event->key.string = g_new0 (gchar, 1); event->key.string = g_new0 (gchar, 1);
} }
GDK_NOTE (EVENTS, GDK_NOTE (EVENTS,
g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n", g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
event->key.keyval, event->key.keyval,
event->key.state)); event->key.state));
/* Update the timestamp of the latest user interaction, if the event has /* Update the timestamp of the latest user interaction, if the event has
* a valid timestamp. * a valid timestamp.
*/ */
if (gdk_event_get_time (event) != GDK_CURRENT_TIME) if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
gdk_x11_window_set_user_time (gdk_window_get_toplevel (window), gdk_x11_window_set_user_time (gdk_window_get_toplevel (window),
gdk_event_get_time (event)); gdk_event_get_time (event));
return TRUE; return TRUE;
} }
@ -554,13 +555,13 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
event->motion.y_root = (gdouble) xdme->y_root; event->motion.y_root = (gdouble) xdme->y_root;
event->motion.axes = g_new0 (gdouble, gdk_device_get_n_axes (device)); event->motion.axes = g_new0 (gdouble, gdk_device_get_n_axes (device));
gdk_device_xi_update_axes (device, xdme->axes_count, _gdk_x11_device_xi_update_axes (device, xdme->axes_count,
xdme->first_axis, xdme->axis_data); xdme->first_axis, xdme->axis_data);
gdk_device_xi_translate_axes (device, window, _gdk_x11_device_xi_translate_axes (device, window,
device_xi->axis_data, device_xi->axis_data,
event->motion.axes, event->motion.axes,
&event->motion.x, &event->motion.x,
&event->motion.y); &event->motion.y);
event->motion.type = GDK_MOTION_NOTIFY; event->motion.type = GDK_MOTION_NOTIFY;
event->motion.window = g_object_ref (window); event->motion.window = g_object_ref (window);
@ -570,20 +571,20 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
event->motion.is_hint = xdme->is_hint; event->motion.is_hint = xdme->is_hint;
GDK_NOTE (EVENTS, GDK_NOTE (EVENTS,
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n", g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n",
xdme->window, xdme->window,
xdme->deviceid, xdme->deviceid,
event->motion.x, event->motion.y, event->motion.x, event->motion.y,
event->motion.state, event->motion.state,
(xdme->is_hint) ? "true" : "false")); (xdme->is_hint) ? "true" : "false"));
/* Update the timestamp of the latest user interaction, if the event has /* Update the timestamp of the latest user interaction, if the event has
* a valid timestamp. * a valid timestamp.
*/ */
if (gdk_event_get_time (event) != GDK_CURRENT_TIME) if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
gdk_x11_window_set_user_time (gdk_window_get_toplevel (window), gdk_x11_window_set_user_time (gdk_window_get_toplevel (window),
gdk_event_get_time (event)); gdk_event_get_time (event));
return TRUE; return TRUE;
} }
@ -613,8 +614,8 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
* a valid timestamp. * a valid timestamp.
*/ */
if (gdk_event_get_time (event) != GDK_CURRENT_TIME) if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
gdk_x11_window_set_user_time (gdk_window_get_toplevel (window), gdk_x11_window_set_user_time (gdk_window_get_toplevel (window),
gdk_event_get_time (event)); gdk_event_get_time (event));
return TRUE; return TRUE;
} }
@ -627,8 +628,8 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
for (i = 0; i < xdse->num_classes; i++) for (i = 0; i < xdse->num_classes; i++)
{ {
if (input_class->class == ValuatorClass) if (input_class->class == ValuatorClass)
gdk_device_xi_update_axes (device, gdk_device_get_n_axes (device), 0, _gdk_x11_device_xi_update_axes (device, gdk_device_get_n_axes (device), 0,
((XValuatorState *)input_class)->valuators); ((XValuatorState *)input_class)->valuators);
input_class = (XInputClass *)(((char *)input_class)+input_class->length); input_class = (XInputClass *)(((char *)input_class)+input_class->length);
} }
@ -645,15 +646,15 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
} }
static GList * static GList *
gdk_device_manager_xi_list_devices (GdkDeviceManager *device_manager, gdk_x11_device_manager_xi_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type) GdkDeviceType type)
{ {
GdkDeviceManagerXIPrivate *priv; GdkX11DeviceManagerXIPrivate *priv;
priv = GDK_DEVICE_MANAGER_XI (device_manager)->priv; priv = GDK_X11_DEVICE_MANAGER_XI (device_manager)->priv;
if (type == GDK_DEVICE_TYPE_MASTER) if (type == GDK_DEVICE_TYPE_MASTER)
return GDK_DEVICE_MANAGER_CLASS (gdk_device_manager_xi_parent_class)->list_devices (device_manager, type); return GDK_DEVICE_MANAGER_CLASS (gdk_x11_device_manager_xi_parent_class)->list_devices (device_manager, type);
else if (type == GDK_DEVICE_TYPE_FLOATING) else if (type == GDK_DEVICE_TYPE_FLOATING)
{ {
return g_list_copy (priv->devices); return g_list_copy (priv->devices);

View File

@ -1,57 +0,0 @@
/* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_MANAGER_XI_H__
#define __GDK_DEVICE_MANAGER_XI_H__
#include "gdkx11devicemanager-core.h"
G_BEGIN_DECLS
#define GDK_TYPE_DEVICE_MANAGER_XI (gdk_device_manager_xi_get_type ())
#define GDK_DEVICE_MANAGER_XI(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_MANAGER_XI, GdkDeviceManagerXI))
#define GDK_DEVICE_MANAGER_XI_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE_MANAGER_XI, GdkDeviceManagerXIClass))
#define GDK_IS_DEVICE_MANAGER_XI(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE_MANAGER_XI))
#define GDK_IS_DEVICE_MANAGER_XI_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE_MANAGER_XI))
#define GDK_DEVICE_MANAGER_XI_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE_MANAGER_XI, GdkDeviceManagerXIClass))
typedef struct _GdkDeviceManagerXI GdkDeviceManagerXI;
typedef struct _GdkDeviceManagerXIPrivate GdkDeviceManagerXIPrivate;
typedef struct _GdkDeviceManagerXIClass GdkDeviceManagerXIClass;
struct _GdkDeviceManagerXI
{
GdkX11DeviceManagerCore parent_object;
GdkDevice *core_pointer;
GdkDevice *core_keyboard;
/*< private >*/
GdkDeviceManagerXIPrivate *priv;
};
struct _GdkDeviceManagerXIClass
{
GdkX11DeviceManagerCoreClass parent_class;
};
GType gdk_device_manager_xi_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_DEVICE_MANAGER_XI_H__ */

View File

@ -19,13 +19,13 @@
#include "config.h" #include "config.h"
#include "gdkdevicemanager-xi2.h" #include "gdkx11devicemanager-xi2.h"
#include "gdkx11device-xi2.h"
#include "gdkkeysyms.h" #include "gdkkeysyms.h"
#include "gdkdeviceprivate.h" #include "gdkdeviceprivate.h"
#include "gdkdisplayprivate.h" #include "gdkdisplayprivate.h"
#include "gdkeventtranslator.h" #include "gdkeventtranslator.h"
#include "gdkdevice-xi2.h"
#include "gdkprivate-x11.h" #include "gdkprivate-x11.h"
#include <string.h> #include <string.h>
@ -33,45 +33,45 @@
#define HAS_FOCUS(toplevel) ((toplevel)->has_focus || (toplevel)->has_pointer_focus) #define HAS_FOCUS(toplevel) ((toplevel)->has_focus || (toplevel)->has_pointer_focus)
static void gdk_device_manager_xi2_constructed (GObject *object); static void gdk_x11_device_manager_xi2_constructed (GObject *object);
static void gdk_device_manager_xi2_dispose (GObject *object); static void gdk_x11_device_manager_xi2_dispose (GObject *object);
static GList * gdk_device_manager_xi2_list_devices (GdkDeviceManager *device_manager, static GList * gdk_x11_device_manager_xi2_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type); GdkDeviceType type);
static GdkDevice * gdk_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager); static GdkDevice * gdk_x11_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager);
static void gdk_device_manager_xi2_event_translator_init (GdkEventTranslatorIface *iface); static void gdk_x11_device_manager_xi2_event_translator_init (GdkEventTranslatorIface *iface);
static gboolean gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, static gboolean gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
GdkDisplay *display, GdkDisplay *display,
GdkEvent *event, GdkEvent *event,
XEvent *xevent); XEvent *xevent);
static GdkEventMask gdk_device_manager_xi2_get_handled_events (GdkEventTranslator *translator); static GdkEventMask gdk_x11_device_manager_xi2_get_handled_events (GdkEventTranslator *translator);
static void gdk_device_manager_xi2_select_window_events (GdkEventTranslator *translator, static void gdk_x11_device_manager_xi2_select_window_events (GdkEventTranslator *translator,
Window window, Window window,
GdkEventMask event_mask); GdkEventMask event_mask);
G_DEFINE_TYPE_WITH_CODE (GdkDeviceManagerXI2, gdk_device_manager_xi2, GDK_TYPE_DEVICE_MANAGER, G_DEFINE_TYPE_WITH_CODE (GdkX11DeviceManagerXI2, gdk_x11_device_manager_xi2, GDK_TYPE_DEVICE_MANAGER,
G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR, G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
gdk_device_manager_xi2_event_translator_init)) gdk_x11_device_manager_xi2_event_translator_init))
static void static void
gdk_device_manager_xi2_class_init (GdkDeviceManagerXI2Class *klass) gdk_x11_device_manager_xi2_class_init (GdkX11DeviceManagerXI2Class *klass)
{ {
GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass); GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = gdk_device_manager_xi2_constructed; object_class->constructed = gdk_x11_device_manager_xi2_constructed;
object_class->dispose = gdk_device_manager_xi2_dispose; object_class->dispose = gdk_x11_device_manager_xi2_dispose;
device_manager_class->list_devices = gdk_device_manager_xi2_list_devices; device_manager_class->list_devices = gdk_x11_device_manager_xi2_list_devices;
device_manager_class->get_client_pointer = gdk_device_manager_xi2_get_client_pointer; device_manager_class->get_client_pointer = gdk_x11_device_manager_xi2_get_client_pointer;
} }
static void static void
gdk_device_manager_xi2_init (GdkDeviceManagerXI2 *device_manager) gdk_x11_device_manager_xi2_init (GdkX11DeviceManagerXI2 *device_manager)
{ {
device_manager->id_table = g_hash_table_new_full (g_direct_hash, device_manager->id_table = g_hash_table_new_full (g_direct_hash,
g_direct_equal, g_direct_equal,
@ -80,9 +80,9 @@ gdk_device_manager_xi2_init (GdkDeviceManagerXI2 *device_manager)
} }
static void static void
_gdk_device_manager_xi2_select_events (GdkDeviceManager *device_manager, _gdk_x11_device_manager_xi2_select_events (GdkDeviceManager *device_manager,
Window xwindow, Window xwindow,
XIEventMask *event_mask) XIEventMask *event_mask)
{ {
GdkDisplay *display; GdkDisplay *display;
Display *xdisplay; Display *xdisplay;
@ -230,7 +230,7 @@ create_device (GdkDeviceManager *device_manager,
break; break;
} }
device = g_object_new (GDK_TYPE_DEVICE_XI2, device = g_object_new (GDK_TYPE_X11_DEVICE_XI2,
"name", dev->name, "name", dev->name,
"type", type, "type", type,
"input-source", input_source, "input-source", input_source,
@ -247,9 +247,9 @@ create_device (GdkDeviceManager *device_manager,
} }
static GdkDevice * static GdkDevice *
add_device (GdkDeviceManagerXI2 *device_manager, add_device (GdkX11DeviceManagerXI2 *device_manager,
XIDeviceInfo *dev, XIDeviceInfo *dev,
gboolean emit_signal) gboolean emit_signal)
{ {
GdkDisplay *display; GdkDisplay *display;
GdkDevice *device; GdkDevice *device;
@ -291,8 +291,8 @@ add_device (GdkDeviceManagerXI2 *device_manager,
} }
static void static void
remove_device (GdkDeviceManagerXI2 *device_manager, remove_device (GdkX11DeviceManagerXI2 *device_manager,
int device_id) gint device_id)
{ {
GdkDevice *device; GdkDevice *device;
@ -318,7 +318,7 @@ relate_masters (gpointer key,
gpointer value, gpointer value,
gpointer user_data) gpointer user_data)
{ {
GdkDeviceManagerXI2 *device_manager; GdkX11DeviceManagerXI2 *device_manager;
GdkDevice *device, *relative; GdkDevice *device, *relative;
device_manager = user_data; device_manager = user_data;
@ -334,7 +334,7 @@ relate_slaves (gpointer key,
gpointer value, gpointer value,
gpointer user_data) gpointer user_data)
{ {
GdkDeviceManagerXI2 *device_manager; GdkX11DeviceManagerXI2 *device_manager;
GdkDevice *slave, *master; GdkDevice *slave, *master;
device_manager = user_data; device_manager = user_data;
@ -346,9 +346,9 @@ relate_slaves (gpointer key,
} }
static void static void
gdk_device_manager_xi2_constructed (GObject *object) gdk_x11_device_manager_xi2_constructed (GObject *object)
{ {
GdkDeviceManagerXI2 *device_manager_xi2; GdkX11DeviceManagerXI2 *device_manager;
GdkDisplay *display; GdkDisplay *display;
GdkScreen *screen; GdkScreen *screen;
GHashTable *masters, *slaves; GHashTable *masters, *slaves;
@ -358,14 +358,14 @@ gdk_device_manager_xi2_constructed (GObject *object)
XIEventMask event_mask; XIEventMask event_mask;
unsigned char mask[2] = { 0 }; unsigned char mask[2] = { 0 };
device_manager_xi2 = GDK_DEVICE_MANAGER_XI2 (object); device_manager = GDK_X11_DEVICE_MANAGER_XI2 (object);
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object)); display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object));
xdisplay = GDK_DISPLAY_XDISPLAY (display); xdisplay = GDK_DISPLAY_XDISPLAY (display);
masters = g_hash_table_new (NULL, NULL); masters = g_hash_table_new (NULL, NULL);
slaves = g_hash_table_new (NULL, NULL); slaves = g_hash_table_new (NULL, NULL);
info = XIQueryDevice(xdisplay, XIAllDevices, &ndevices); info = XIQueryDevice (xdisplay, XIAllDevices, &ndevices);
/* Initialize devices list */ /* Initialize devices list */
for (i = 0; i < ndevices; i++) for (i = 0; i < ndevices; i++)
@ -373,7 +373,7 @@ gdk_device_manager_xi2_constructed (GObject *object)
GdkDevice *device; GdkDevice *device;
dev = &info[i]; dev = &info[i];
device = add_device (device_manager_xi2, dev, FALSE); device = add_device (device_manager, dev, FALSE);
if (dev->use == XIMasterPointer || if (dev->use == XIMasterPointer ||
dev->use == XIMasterKeyboard) dev->use == XIMasterKeyboard)
@ -391,7 +391,7 @@ gdk_device_manager_xi2_constructed (GObject *object)
} }
} }
XIFreeDeviceInfo(info); XIFreeDeviceInfo (info);
/* Stablish relationships between devices */ /* Stablish relationships between devices */
g_hash_table_foreach (masters, relate_masters, object); g_hash_table_foreach (masters, relate_masters, object);
@ -409,43 +409,41 @@ gdk_device_manager_xi2_constructed (GObject *object)
event_mask.mask_len = sizeof (mask); event_mask.mask_len = sizeof (mask);
event_mask.mask = mask; event_mask.mask = mask;
_gdk_device_manager_xi2_select_events (GDK_DEVICE_MANAGER (object), _gdk_x11_device_manager_xi2_select_events (GDK_DEVICE_MANAGER (object),
GDK_WINDOW_XID (gdk_screen_get_root_window (screen)), GDK_WINDOW_XID (gdk_screen_get_root_window (screen)),
&event_mask); &event_mask);
} }
static void static void
gdk_device_manager_xi2_dispose (GObject *object) gdk_x11_device_manager_xi2_dispose (GObject *object)
{ {
GdkDeviceManagerXI2 *device_manager_xi2; GdkX11DeviceManagerXI2 *device_manager;
device_manager_xi2 = GDK_DEVICE_MANAGER_XI2 (object); device_manager = GDK_X11_DEVICE_MANAGER_XI2 (object);
g_list_foreach (device_manager_xi2->master_devices, (GFunc) g_object_unref, NULL); g_list_free_full (device_manager->master_devices, g_object_unref);
g_list_free (device_manager_xi2->master_devices); device_manager->master_devices = NULL;
device_manager_xi2->master_devices = NULL;
g_list_foreach (device_manager_xi2->slave_devices, (GFunc) g_object_unref, NULL); g_list_free_full (device_manager->slave_devices, g_object_unref);
g_list_free (device_manager_xi2->slave_devices); device_manager->slave_devices = NULL;
device_manager_xi2->slave_devices = NULL;
if (device_manager_xi2->id_table) if (device_manager->id_table)
{ {
g_hash_table_destroy (device_manager_xi2->id_table); g_hash_table_destroy (device_manager->id_table);
device_manager_xi2->id_table = NULL; device_manager->id_table = NULL;
} }
G_OBJECT_CLASS (gdk_device_manager_xi2_parent_class)->dispose (object); G_OBJECT_CLASS (gdk_x11_device_manager_xi2_parent_class)->dispose (object);
} }
static GList * static GList *
gdk_device_manager_xi2_list_devices (GdkDeviceManager *device_manager, gdk_x11_device_manager_xi2_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type) GdkDeviceType type)
{ {
GdkDeviceManagerXI2 *device_manager_xi2; GdkX11DeviceManagerXI2 *device_manager_xi2;
GList *list = NULL; GList *list = NULL;
device_manager_xi2 = GDK_DEVICE_MANAGER_XI2 (device_manager); device_manager_xi2 = GDK_X11_DEVICE_MANAGER_XI2 (device_manager);
switch (type) switch (type)
{ {
@ -477,13 +475,13 @@ gdk_device_manager_xi2_list_devices (GdkDeviceManager *device_manager,
} }
static GdkDevice * static GdkDevice *
gdk_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager) gdk_x11_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager)
{ {
GdkDeviceManagerXI2 *device_manager_xi2; GdkX11DeviceManagerXI2 *device_manager_xi2;
GdkDisplay *display; GdkDisplay *display;
int device_id; int device_id;
device_manager_xi2 = (GdkDeviceManagerXI2 *) device_manager; device_manager_xi2 = (GdkX11DeviceManagerXI2 *) device_manager;
display = gdk_device_manager_get_display (device_manager); display = gdk_device_manager_get_display (device_manager);
XIGetClientPointer (GDK_DISPLAY_XDISPLAY (display), XIGetClientPointer (GDK_DISPLAY_XDISPLAY (display),
@ -494,16 +492,16 @@ gdk_device_manager_xi2_get_client_pointer (GdkDeviceManager *device_manager)
} }
static void static void
gdk_device_manager_xi2_event_translator_init (GdkEventTranslatorIface *iface) gdk_x11_device_manager_xi2_event_translator_init (GdkEventTranslatorIface *iface)
{ {
iface->translate_event = gdk_device_manager_xi2_translate_event; iface->translate_event = gdk_x11_device_manager_xi2_translate_event;
iface->get_handled_events = gdk_device_manager_xi2_get_handled_events; iface->get_handled_events = gdk_x11_device_manager_xi2_get_handled_events;
iface->select_window_events = gdk_device_manager_xi2_select_window_events; iface->select_window_events = gdk_x11_device_manager_xi2_select_window_events;
} }
static void static void
handle_hierarchy_changed (GdkDeviceManagerXI2 *device_manager, handle_hierarchy_changed (GdkX11DeviceManagerXI2 *device_manager,
XIHierarchyEvent *ev) XIHierarchyEvent *ev)
{ {
GdkDisplay *display; GdkDisplay *display;
Display *xdisplay; Display *xdisplay;
@ -519,9 +517,9 @@ handle_hierarchy_changed (GdkDeviceManagerXI2 *device_manager,
{ {
if (ev->info[i].flags & XIDeviceEnabled) if (ev->info[i].flags & XIDeviceEnabled)
{ {
info = XIQueryDevice(xdisplay, ev->info[i].deviceid, &ndevices); info = XIQueryDevice (xdisplay, ev->info[i].deviceid, &ndevices);
device = add_device (device_manager, &info[0], TRUE); device = add_device (device_manager, &info[0], TRUE);
XIFreeDeviceInfo(info); XIFreeDeviceInfo (info);
} }
else if (ev->info[i].flags & XIDeviceDisabled) else if (ev->info[i].flags & XIDeviceDisabled)
remove_device (device_manager, ev->info[i].deviceid); remove_device (device_manager, ev->info[i].deviceid);
@ -547,7 +545,7 @@ handle_hierarchy_changed (GdkDeviceManagerXI2 *device_manager,
/* Add new master if it's an attachment event */ /* Add new master if it's an attachment event */
if (ev->info[i].flags & XISlaveAttached) if (ev->info[i].flags & XISlaveAttached)
{ {
info = XIQueryDevice(xdisplay, ev->info[i].deviceid, &ndevices); info = XIQueryDevice (xdisplay, ev->info[i].deviceid, &ndevices);
master = g_hash_table_lookup (device_manager->id_table, master = g_hash_table_lookup (device_manager->id_table,
GINT_TO_POINTER (info->attachment)); GINT_TO_POINTER (info->attachment));
@ -564,8 +562,8 @@ handle_hierarchy_changed (GdkDeviceManagerXI2 *device_manager,
} }
static void static void
handle_device_changed (GdkDeviceManagerXI2 *device_manager, handle_device_changed (GdkX11DeviceManagerXI2 *device_manager,
XIDeviceChangedEvent *ev) XIDeviceChangedEvent *ev)
{ {
GdkDisplay *display; GdkDisplay *display;
GdkDevice *device; GdkDevice *device;
@ -581,7 +579,7 @@ handle_device_changed (GdkDeviceManagerXI2 *device_manager,
} }
static GdkCrossingMode static GdkCrossingMode
translate_crossing_mode (int mode) translate_crossing_mode (gint mode)
{ {
switch (mode) switch (mode)
{ {
@ -597,7 +595,7 @@ translate_crossing_mode (int mode)
} }
static GdkNotifyType static GdkNotifyType
translate_notify_type (int detail) translate_notify_type (gint detail)
{ {
switch (detail) switch (detail)
{ {
@ -618,8 +616,8 @@ translate_notify_type (int detail)
static gboolean static gboolean
set_screen_from_root (GdkDisplay *display, set_screen_from_root (GdkDisplay *display,
GdkEvent *event, GdkEvent *event,
Window xrootwin) Window xrootwin)
{ {
GdkScreen *screen; GdkScreen *screen;
@ -675,19 +673,19 @@ translate_keyboard_string (GdkEventKey *event)
/* Apply the control key - Taken from Xlib /* Apply the control key - Taken from Xlib
*/ */
if (event->state & GDK_CONTROL_MASK) if (event->state & GDK_CONTROL_MASK)
{ {
if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F; if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
else if (c == '2') else if (c == '2')
{ {
event->string = g_memdup ("\0\0", 2); event->string = g_memdup ("\0\0", 2);
event->length = 1; event->length = 1;
buf[0] = '\0'; buf[0] = '\0';
return; return;
} }
else if (c >= '3' && c <= '7') c -= ('3' - '\033'); else if (c >= '3' && c <= '7') c -= ('3' - '\033');
else if (c == '8') c = '\177'; else if (c == '8') c = '\177';
else if (c == '/') c = '_' & 0x1F; else if (c == '/') c = '_' & 0x1F;
} }
len = g_unichar_to_utf8 (c, buf); len = g_unichar_to_utf8 (c, buf);
buf[len] = '\0'; buf[len] = '\0';
@ -696,7 +694,7 @@ translate_keyboard_string (GdkEventKey *event)
NULL, &bytes_written, NULL, &bytes_written,
NULL); NULL);
if (event->string) if (event->string)
event->length = bytes_written; event->length = bytes_written;
} }
else if (event->keyval == GDK_KEY_Escape) else if (event->keyval == GDK_KEY_Escape)
{ {
@ -704,7 +702,7 @@ translate_keyboard_string (GdkEventKey *event)
event->string = g_strdup ("\033"); event->string = g_strdup ("\033");
} }
else if (event->keyval == GDK_KEY_Return || else if (event->keyval == GDK_KEY_Return ||
event->keyval == GDK_KEY_KP_Enter) event->keyval == GDK_KEY_KP_Enter)
{ {
event->length = 1; event->length = 1;
event->string = g_strdup ("\r"); event->string = g_strdup ("\r");
@ -866,7 +864,7 @@ is_parent_of (GdkWindow *parent,
while (w != NULL) while (w != NULL)
{ {
if (w == parent) if (w == parent)
return TRUE; return TRUE;
w = gdk_window_get_parent (w); w = gdk_window_get_parent (w);
} }
@ -902,7 +900,7 @@ get_event_window (GdkEventTranslator *translator,
GdkDevice *device; GdkDevice *device;
gulong serial; gulong serial;
device = g_hash_table_lookup (GDK_DEVICE_MANAGER_XI2 (translator)->id_table, device = g_hash_table_lookup (GDK_X11_DEVICE_MANAGER_XI2 (translator)->id_table,
GUINT_TO_POINTER (((XIDeviceEvent *) ev)->deviceid)); GUINT_TO_POINTER (((XIDeviceEvent *) ev)->deviceid));
serial = _gdk_display_get_next_serial (display); serial = _gdk_display_get_next_serial (display);
@ -934,12 +932,12 @@ get_event_window (GdkEventTranslator *translator,
} }
static gboolean static gboolean
gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
GdkDisplay *display, GdkDisplay *display,
GdkEvent *event, GdkEvent *event,
XEvent *xevent) XEvent *xevent)
{ {
GdkDeviceManagerXI2 *device_manager; GdkX11DeviceManagerXI2 *device_manager;
XGenericEventCookie *cookie; XGenericEventCookie *cookie;
gboolean return_val = TRUE; gboolean return_val = TRUE;
GdkWindow *window; GdkWindow *window;
@ -947,7 +945,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
Display *dpy; Display *dpy;
dpy = GDK_DISPLAY_XDISPLAY (display); dpy = GDK_DISPLAY_XDISPLAY (display);
device_manager = (GdkDeviceManagerXI2 *) translator; device_manager = (GdkX11DeviceManagerXI2 *) translator;
cookie = &xevent->xcookie; cookie = &xevent->xcookie;
if (!XGetEventData (dpy, cookie)) if (!XGetEventData (dpy, cookie))
@ -1005,7 +1003,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->key.window = window; event->key.window = window;
event->key.time = xev->time; event->key.time = xev->time;
event->key.state = gdk_device_xi2_translate_state (&xev->mods, &xev->buttons); event->key.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons);
event->key.group = _gdk_x11_get_group_for_state (display, event->key.state); event->key.group = _gdk_x11_get_group_for_state (display, event->key.state);
event->key.hardware_keycode = xev->detail; event->key.hardware_keycode = xev->detail;
@ -1080,7 +1078,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
GUINT_TO_POINTER (xev->sourceid)); GUINT_TO_POINTER (xev->sourceid));
gdk_event_set_source_device (event, source_device); gdk_event_set_source_device (event, source_device);
event->scroll.state = gdk_device_xi2_translate_state (&xev->mods, &xev->buttons); event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons);
break; break;
default: default:
event->button.type = (ev->evtype == XI_ButtonPress) ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE; event->button.type = (ev->evtype == XI_ButtonPress) ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
@ -1114,7 +1112,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
gdk_device_get_axis (device, event->button.axes, GDK_AXIS_Y, &event->button.y); gdk_device_get_axis (device, event->button.axes, GDK_AXIS_Y, &event->button.y);
} }
event->button.state = gdk_device_xi2_translate_state (&xev->mods, &xev->buttons); event->button.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons);
event->button.button = xev->detail; event->button.button = xev->detail;
} }
@ -1150,7 +1148,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
GUINT_TO_POINTER (xev->sourceid)); GUINT_TO_POINTER (xev->sourceid));
gdk_event_set_source_device (event, source_device); gdk_event_set_source_device (event, source_device);
event->motion.state = gdk_device_xi2_translate_state (&xev->mods, &xev->buttons); event->motion.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons);
/* There doesn't seem to be motion hints in XI */ /* There doesn't seem to be motion hints in XI */
event->motion.is_hint = FALSE; event->motion.is_hint = FALSE;
@ -1199,7 +1197,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->crossing.mode = translate_crossing_mode (xev->mode); event->crossing.mode = translate_crossing_mode (xev->mode);
event->crossing.detail = translate_notify_type (xev->detail); event->crossing.detail = translate_notify_type (xev->detail);
event->crossing.state = gdk_device_xi2_translate_state (&xev->mods, &xev->buttons); event->crossing.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons);
} }
break; break;
case XI_FocusIn: case XI_FocusIn:
@ -1233,8 +1231,8 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
g_object_ref (event->any.window); g_object_ref (event->any.window);
if (((event->any.type == GDK_ENTER_NOTIFY) || if (((event->any.type == GDK_ENTER_NOTIFY) ||
(event->any.type == GDK_LEAVE_NOTIFY)) && (event->any.type == GDK_LEAVE_NOTIFY)) &&
(event->crossing.subwindow != NULL)) (event->crossing.subwindow != NULL))
g_object_ref (event->crossing.subwindow); g_object_ref (event->crossing.subwindow);
} }
else else
@ -1250,7 +1248,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
} }
static GdkEventMask static GdkEventMask
gdk_device_manager_xi2_get_handled_events (GdkEventTranslator *translator) gdk_x11_device_manager_xi2_get_handled_events (GdkEventTranslator *translator)
{ {
return (GDK_KEY_PRESS_MASK | return (GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK | GDK_KEY_RELEASE_MASK |
@ -1269,9 +1267,9 @@ gdk_device_manager_xi2_get_handled_events (GdkEventTranslator *translator)
} }
static void static void
gdk_device_manager_xi2_select_window_events (GdkEventTranslator *translator, gdk_x11_device_manager_xi2_select_window_events (GdkEventTranslator *translator,
Window window, Window window,
GdkEventMask evmask) GdkEventMask evmask)
{ {
GdkDeviceManager *device_manager; GdkDeviceManager *device_manager;
XIEventMask event_mask; XIEventMask event_mask;
@ -1279,8 +1277,8 @@ gdk_device_manager_xi2_select_window_events (GdkEventTranslator *translator,
device_manager = GDK_DEVICE_MANAGER (translator); device_manager = GDK_DEVICE_MANAGER (translator);
event_mask.deviceid = XIAllMasterDevices; event_mask.deviceid = XIAllMasterDevices;
event_mask.mask = gdk_device_xi2_translate_event_mask (evmask, &event_mask.mask_len); event_mask.mask = _gdk_x11_device_xi2_translate_event_mask (evmask, &event_mask.mask_len);
_gdk_device_manager_xi2_select_events (device_manager, window, &event_mask); _gdk_x11_device_manager_xi2_select_events (device_manager, window, &event_mask);
g_free (event_mask.mask); g_free (event_mask.mask);
} }

View File

@ -1,63 +0,0 @@
/* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_MANAGER_XI2_H__
#define __GDK_DEVICE_MANAGER_XI2_H__
#include "gdkdevicemanagerprivate.h"
#include <X11/extensions/XInput2.h>
G_BEGIN_DECLS
#define GDK_TYPE_DEVICE_MANAGER_XI2 (gdk_device_manager_xi2_get_type ())
#define GDK_DEVICE_MANAGER_XI2(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_MANAGER_XI2, GdkDeviceManagerXI2))
#define GDK_DEVICE_MANAGER_XI2_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE_MANAGER_XI2, GdkDeviceManagerXI2Class))
#define GDK_IS_DEVICE_MANAGER_XI2(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE_MANAGER_XI2))
#define GDK_IS_DEVICE_MANAGER_XI2_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE_MANAGER_XI2))
#define GDK_DEVICE_MANAGER_XI2_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE_MANAGER_XI2, GdkDeviceManagerXI2Class))
typedef struct _GdkDeviceManagerXI2 GdkDeviceManagerXI2;
typedef struct _GdkDeviceManagerXI2Class GdkDeviceManagerXI2Class;
struct _GdkDeviceManagerXI2
{
GdkDeviceManager parent_object;
GHashTable *id_table;
GList *master_devices;
GList *slave_devices;
GdkDevice *client_pointer;
int opcode;
};
struct _GdkDeviceManagerXI2Class
{
GdkDeviceManagerClass parent_class;
};
GType gdk_device_manager_xi2_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_DEVICE_MANAGER_XI2_H__ */

View File

@ -213,6 +213,24 @@ void _gdk_x11_device_check_extension_events (GdkDevice *device);
GdkDeviceManager *_gdk_x11_device_manager_new (GdkDisplay *display); GdkDeviceManager *_gdk_x11_device_manager_new (GdkDisplay *display);
void _gdk_x11_device_xi_update_window_info (GdkWindow *window);
void _gdk_x11_device_xi_update_axes (GdkDevice *device,
gint axes_count,
gint first_axis,
gint *axis_data);
void _gdk_x11_device_xi_translate_axes (GdkDevice *device,
GdkWindow *window,
gint *axis_data,
gdouble *axes,
gdouble *x,
gdouble *y);
guchar * _gdk_x11_device_xi2_translate_event_mask (GdkEventMask event_mask,
gint *len);
guint _gdk_x11_device_xi2_translate_state (XIModifierState *mods_state,
XIButtonState *buttons_state);
void _gdk_x11_display_manager_add_display (GdkDisplayManager *manager, void _gdk_x11_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display); GdkDisplay *display);
void _gdk_x11_display_manager_remove_display (GdkDisplayManager *manager, void _gdk_x11_display_manager_remove_display (GdkDisplayManager *manager,

View File

@ -57,7 +57,11 @@
#include <gdk/x11/gdkx11cursor.h> #include <gdk/x11/gdkx11cursor.h>
#include <gdk/x11/gdkx11device-core.h> #include <gdk/x11/gdkx11device-core.h>
#include <gdk/x11/gdkx11device-xi.h>
#include <gdk/x11/gdkx11device-xi2.h>
#include <gdk/x11/gdkx11devicemanager-core.h> #include <gdk/x11/gdkx11devicemanager-core.h>
#include <gdk/x11/gdkx11devicemanager-xi.h>
#include <gdk/x11/gdkx11devicemanager-xi2.h>
#include <gdk/x11/gdkx11display.h> #include <gdk/x11/gdkx11display.h>
#include <gdk/x11/gdkx11displaymanager.h> #include <gdk/x11/gdkx11displaymanager.h>
#include <gdk/x11/gdkx11keys.h> #include <gdk/x11/gdkx11keys.h>

72
gdk/x11/gdkx11device-xi.h Normal file
View File

@ -0,0 +1,72 @@
/* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_X11_DEVICE_XI_H__
#define __GDK_X11_DEVICE_XI_H__
#include "gdkdeviceprivate.h"
#include <X11/extensions/XInput.h>
G_BEGIN_DECLS
#define GDK_TYPE_X11_DEVICE_XI (gdk_x11_device_xi_get_type ())
#define GDK_X11_DEVICE_XI(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_X11_DEVICE_XI, GdkX11DeviceXI))
#define GDK_X11_DEVICE_XI_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_X11_DEVICE_XI, GdkX11DeviceXIClass))
#define GDK_IS_X11_DEVICE_XI(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_X11_DEVICE_XI))
#define GDK_IS_X11_DEVICE_XI_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_X11_DEVICE_XI))
#define GDK_X11_DEVICE_XI_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_X11_DEVICE_XI, GdkX11DeviceXIClass))
typedef struct _GdkX11DeviceXI GdkX11DeviceXI;
typedef struct _GdkX11DeviceXIClass GdkX11DeviceXIClass;
struct _GdkX11DeviceXI
{
GdkDevice parent_instance;
/*< private >*/
guint32 device_id;
XDevice *xdevice;
gint button_press_type;
gint button_release_type;
gint key_press_type;
gint key_release_type;
gint motion_notify_type;
gint proximity_in_type;
gint proximity_out_type;
gint state_notify_type;
/* minimum key code for device */
gint min_keycode;
gint *axis_data;
guint in_proximity : 1;
};
struct _GdkX11DeviceXIClass
{
GdkDeviceClass parent_class;
};
GType gdk_x11_device_xi_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_X11_DEVICE_XI_H__ */

View File

@ -0,0 +1,56 @@
/* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_X11_DEVICE_XI2_H__
#define __GDK_X11_DEVICE_XI2_H__
#include "gdkdeviceprivate.h"
#include <X11/extensions/XInput2.h>
G_BEGIN_DECLS
#define GDK_TYPE_X11_DEVICE_XI2 (gdk_x11_device_xi2_get_type ())
#define GDK_X11_DEVICE_XI2(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_X11_DEVICE_XI2, GdkX11DeviceXI2))
#define GDK_X11_DEVICE_XI2_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_X11_DEVICE_XI2, GdkX11DeviceXI2Class))
#define GDK_IS_X11_DEVICE_XI2(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_X11_DEVICE_XI2))
#define GDK_IS_X11_DEVICE_XI2_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_X11_DEVICE_XI2))
#define GDK_X11_DEVICE_XI2_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_X11_DEVICE_XI2, GdkX11DeviceXI2Class))
typedef struct _GdkX11DeviceXI2 GdkX11DeviceXI2;
typedef struct _GdkX11DeviceXI2Class GdkX11DeviceXI2Class;
struct _GdkX11DeviceXI2
{
GdkDevice parent_instance;
/*< private >*/
gint device_id;
};
struct _GdkX11DeviceXI2Class
{
GdkDeviceClass parent_class;
};
GType gdk_x11_device_xi2_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_X11_DEVICE_XI2_H__ */

View File

@ -0,0 +1,55 @@
/* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_X11_DEVICE_MANAGER_XI_H__
#define __GDK_X11_DEVICE_MANAGER_XI_H__
#include "gdkx11devicemanager-core.h"
G_BEGIN_DECLS
#define GDK_TYPE_X11_DEVICE_MANAGER_XI (gdk_x11_device_manager_xi_get_type ())
#define GDK_X11_DEVICE_MANAGER_XI(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_X11_DEVICE_MANAGER_XI, GdkX11DeviceManagerXI))
#define GDK_X11_DEVICE_MANAGER_XI_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_X11_DEVICE_MANAGER_XI, GdkX11DeviceManagerXIClass))
#define GDK_IS_X11_DEVICE_MANAGER_XI(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_X11_DEVICE_MANAGER_XI))
#define GDK_IS_X11_DEVICE_MANAGER_XI_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_X11_DEVICE_MANAGER_XI))
#define GDK_X11_DEVICE_MANAGER_XI_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_X11_DEVICE_MANAGER_XI, GdkX11DeviceManagerXIClass))
typedef struct _GdkX11DeviceManagerXI GdkX11DeviceManagerXI;
typedef struct _GdkX11DeviceManagerXIPrivate GdkX11DeviceManagerXIPrivate;
typedef struct _GdkX11DeviceManagerXIClass GdkX11DeviceManagerXIClass;
struct _GdkX11DeviceManagerXI
{
GdkX11DeviceManagerCore parent_object;
/*< private >*/
GdkX11DeviceManagerXIPrivate *priv;
};
struct _GdkX11DeviceManagerXIClass
{
GdkX11DeviceManagerCoreClass parent_class;
};
GType gdk_x11_device_manager_xi_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_X11_DEVICE_MANAGER_XI_H__ */

View File

@ -0,0 +1,65 @@
/* 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
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_X11_DEVICE_MANAGER_XI2_H__
#define __GDK_X11_DEVICE_MANAGER_XI2_H__
#include "gdkdevicemanagerprivate.h"
#include <X11/extensions/XInput2.h>
G_BEGIN_DECLS
#define GDK_TYPE_X11_DEVICE_MANAGER_XI2 (gdk_x11_device_manager_xi2_get_type ())
#define GDK_X11_DEVICE_MANAGER_XI2(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_X11_DEVICE_MANAGER_XI2, GdkX11DeviceManagerXI2))
#define GDK_X11_DEVICE_MANAGER_XI2_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_X11_DEVICE_MANAGER_XI2, GdkX11DeviceManagerXI2Class))
#define GDK_IS_X11_DEVICE_MANAGER_XI2(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_X11_DEVICE_MANAGER_XI2))
#define GDK_IS_X11_DEVICE_MANAGER_XI2_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_X11_DEVICE_MANAGER_XI2))
#define GDK_X11_DEVICE_MANAGER_XI2_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_X11_DEVICE_MANAGER_XI2, GdkX11DeviceManagerXI2Class))
typedef struct _GdkX11DeviceManagerXI2 GdkX11DeviceManagerXI2;
typedef struct _GdkX11DeviceManagerXI2Class GdkX11DeviceManagerXI2Class;
struct _GdkX11DeviceManagerXI2
{
GdkDeviceManager parent_object;
/*< private >*/
GHashTable *id_table;
GList *master_devices;
GList *slave_devices;
GdkDevice *client_pointer;
gint opcode;
};
struct _GdkX11DeviceManagerXI2Class
{
GdkDeviceManagerClass parent_class;
};
GType gdk_x11_device_manager_xi2_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_X11_DEVICE_MANAGER_XI2_H__ */