summaryrefslogtreecommitdiff
path: root/gdk/x11/gdkinput-x11.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdk/x11/gdkinput-x11.c')
-rw-r--r--gdk/x11/gdkinput-x11.c80
1 files changed, 45 insertions, 35 deletions
diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c
index 770c9b874..b1a72182d 100644
--- a/gdk/x11/gdkinput-x11.c
+++ b/gdk/x11/gdkinput-x11.c
@@ -28,26 +28,28 @@
#include "gdkinternals.h"
#include "gdkx.h"
#include "gdk.h" /* For gdk_error_trap_push()/pop() */
+#include "gdkdisplay-x11.h"
#include <string.h>
/* Forward declarations */
-static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
- gint include_core);
-static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
- GdkInputWindow *input_window,
- gint *axis_data,
- gdouble *axis_out,
- gdouble *x_out,
- gdouble *y_out);
-static guint gdk_input_translate_state(guint state, guint device_state);
-
-/* Global variables */
+static GdkDevicePrivate *gdk_input_device_new (GdkDisplay *display,
+ XDeviceInfo *device,
+ gint include_core);
+static void gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
+ GdkInputWindow *input_window,
+ gint *axis_data,
+ gdouble *axis_out,
+ gdouble *x_out,
+ gdouble *y_out);
+static guint gdk_input_translate_state (guint state,
+ guint device_state);
GdkDevicePrivate *
-gdk_input_find_device (guint32 id)
+gdk_input_find_device (GdkDisplay *display,
+ guint32 id)
{
- GList *tmp_list = _gdk_input_devices;
+ GList *tmp_list = GDK_DISPLAY_X11 (display)->input_devices;
GdkDevicePrivate *gdkdev;
while (tmp_list)
{
@@ -60,7 +62,7 @@ gdk_input_find_device (guint32 id)
}
void
-gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
+gdk_input_get_root_relative_geometry(Display *display, Window w, int *x_ret, int *y_ret,
int *width_ret, int *height_ret)
{
Window root, parent, child;
@@ -70,13 +72,13 @@ gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_
guint width, height;
guint border_widthc, depthc;
- XQueryTree (dpy, w, &root, &parent, &children, &nchildren);
+ XQueryTree (display, w, &root, &parent, &children, &nchildren);
if (children)
XFree(children);
- XGetGeometry (dpy, w, &root, &x, &y, &width, &height, &border_widthc, &depthc);
+ XGetGeometry (display, w, &root, &x, &y, &width, &height, &border_widthc, &depthc);
- XTranslateCoordinates (dpy, w, root, 0, 0, &x, &y, &child);
+ XTranslateCoordinates (display, w, root, 0, 0, &x, &y, &child);
if (x_ret)
*x_ret = x;
@@ -89,7 +91,9 @@ gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_
}
static GdkDevicePrivate *
-gdk_input_device_new (XDeviceInfo *device, gint include_core)
+gdk_input_device_new (GdkDisplay *display,
+ XDeviceInfo *device,
+ gint include_core)
{
GdkDevicePrivate *gdkdev;
gchar *tmp_name;
@@ -99,6 +103,8 @@ gdk_input_device_new (XDeviceInfo *device, gint include_core)
gdkdev = g_object_new (GDK_TYPE_DEVICE, NULL);
gdkdev->deviceid = device->id;
+ gdkdev->display = display;
+
if (device->name[0])
gdkdev->info.name = g_strdup (device->name);
else
@@ -218,7 +224,8 @@ gdk_input_device_new (XDeviceInfo *device, gint include_core)
if (device->use != IsXPointer)
{
gdk_error_trap_push ();
- gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->deviceid);
+ gdkdev->xdevice = XOpenDevice (GDK_DISPLAY_XDISPLAY (display),
+ gdkdev->deviceid);
/* return NULL if device is not ready */
if (gdk_error_trap_pop ())
@@ -263,7 +270,7 @@ gdk_input_common_find_events(GdkWindow *window,
i = 0;
/* We have to track press and release events in pairs to keep
track of button state correctly and implement grabbing for
- the gxi support */
+ the gxi support. FIXME - is this needed any more since gxi is gone? */
if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
{
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
@@ -366,44 +373,46 @@ gdk_input_common_select_events(GdkWindow *window,
((GdkWindowObject *)window)->extension_events,
classes, &num_classes);
- XSelectExtensionEvent (gdk_display,
- GDK_WINDOW_XWINDOW(window),
+ XSelectExtensionEvent (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XWINDOW (window),
classes, num_classes);
}
gint
-gdk_input_common_init(gint include_core)
+gdk_input_common_init (GdkDisplay *display,
+ gint include_core)
{
char **extensions;
XDeviceInfo *devices;
int num_devices;
int num_extensions, loop;
- Display *display = gdk_display;
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
/* Init XInput extension */
- extensions = XListExtensions(display, &num_extensions);
+ extensions = XListExtensions(display_x11->xdisplay, &num_extensions);
for (loop = 0; loop < num_extensions &&
(strcmp(extensions[loop], "XInputExtension") != 0); loop++);
XFreeExtensionList(extensions);
- _gdk_input_devices = NULL;
+ display_x11->input_devices = NULL;
if (loop < num_extensions)
{
/* XInput extension found */
- devices = XListInputDevices(display, &num_devices);
+ devices = XListInputDevices(display_x11->xdisplay, &num_devices);
for(loop=0; loop<num_devices; loop++)
{
- GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
- include_core);
+ GdkDevicePrivate *gdkdev = gdk_input_device_new(display,
+ &devices[loop],
+ include_core);
if (gdkdev)
- _gdk_input_devices = g_list_append(_gdk_input_devices, gdkdev);
+ display_x11->input_devices = g_list_append(display_x11->input_devices, gdkdev);
}
XFreeDeviceList(devices);
}
- _gdk_input_devices = g_list_append (_gdk_input_devices, _gdk_core_pointer);
+ display_x11->input_devices = g_list_append (display_x11->input_devices, _gdk_core_pointer);
return TRUE;
}
@@ -448,8 +457,8 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
if (gdkdev->info.mode == GDK_MODE_SCREEN)
{
- x_scale = gdk_screen_width() / device_width;
- y_scale = gdk_screen_height() / device_height;
+ x_scale = gdk_screen_get_width (gdk_drawable_get_screen (input_window->window)) / device_width;
+ y_scale = gdk_screen_get_height (gdk_drawable_get_screen (input_window->window)) / device_height;
x_offset = - input_window->root_x;
y_offset = - input_window->root_y;
@@ -690,7 +699,7 @@ _gdk_device_get_history (GdkDevice *device,
g_return_val_if_fail (input_window != NULL, FALSE);
- device_coords = XGetDeviceMotionEvents (gdk_display,
+ device_coords = XGetDeviceMotionEvents (GDK_WINDOW_XDISPLAY (window),
gdkdev->xdevice,
start, stop,
n_events, &mode_return,
@@ -756,7 +765,8 @@ gdk_device_get_state (GdkDevice *device,
input_window = gdk_input_window_find (window);
g_return_if_fail (input_window != NULL);
- state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
+ state = XQueryDeviceState (GDK_WINDOW_XDISPLAY (window),
+ gdkdev->xdevice);
input_class = state->data;
for (i=0; i<state->num_classes; i++)
{