Start of integration of Erwann Chenede's multihead work from the
Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
This commit is contained in:
@ -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++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user