1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
29 /* Forward declarations */
30 static void gdk_input_get_root_relative_geometry (Display *dpy, Window w,
31 int *x_ret, int *y_ret,
34 static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
36 static void gdk_input_common_find_events(GdkWindow *window,
37 GdkDevicePrivate *gdkdev,
41 static void gdk_input_common_select_events(GdkWindow *window,
42 GdkDevicePrivate *gdkdev);
43 static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
44 GdkInputWindow *input_window,
46 gdouble *x, gdouble *y,
48 gdouble *xtilt, gdouble *ytilt);
49 static guint gdk_input_translate_state(guint state, guint device_state);
50 static gint gdk_input_common_init(gint include_core);
51 static gint gdk_input_common_other_event (GdkEvent *event,
53 GdkInputWindow *input_window,
54 GdkDevicePrivate *gdkdev);
55 static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
56 static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
60 gint *nevents_return);
61 static void gdk_input_common_get_pointer (GdkWindow *window,
68 GdkModifierType *mask);
70 #define GDK_MAX_DEVICE_CLASSES 13
72 /* Global variables */
74 static gint gdk_input_root_width;
75 static gint gdk_input_root_height;
78 gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
79 int *width_ret, int *height_ret)
87 guint widthc,heightc,border_widthc,depthc;
89 XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
90 if (children) XFree(children);
91 XGetGeometry(dpy,w,&root,&x,&y,&width,&height,&border_widthc,
96 while (root != parent)
99 XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
100 if (children) XFree(children);
101 XGetGeometry(dpy,w,&root,&xc,&yc,&widthc,&heightc,
102 &border_widthc,&depthc);
103 x += xc + border_widthc;
104 y += yc + border_widthc;
114 *height_ret = height;
117 static GdkDevicePrivate *
118 gdk_input_device_new(XDeviceInfo *device, gint include_core)
120 GdkDevicePrivate *gdkdev;
125 gdkdev = g_new(GdkDevicePrivate,1);
127 gdkdev->info.deviceid = device->id;
128 if (device->name[0]) {
129 gdkdev->info.name = g_new(char, strlen(device->name)+1);
130 strcpy(gdkdev->info.name,device->name);
132 /* XFree86 3.2 gives an empty name to the default core devices,
134 gdkdev->info.name = g_strdup("pointer");
135 strcpy(gdkdev->info.name,"pointer");
136 gdkdev->info.source = GDK_SOURCE_MOUSE;
139 gdkdev->info.mode = GDK_MODE_DISABLED;
141 /* Try to figure out what kind of device this is by its name -
142 could invite a very, very, long list... Lowercase name
143 for comparison purposes */
145 tmp_name = g_strdup(gdkdev->info.name);
146 for (p = tmp_name; *p; p++)
148 if (*p >= 'A' && *p <= 'Z')
152 if (!strcmp (tmp_name, "pointer"))
153 gdkdev->info.source = GDK_SOURCE_MOUSE;
154 else if (!strcmp (tmp_name, "wacom") ||
155 !strcmp (tmp_name, "pen"))
156 gdkdev->info.source = GDK_SOURCE_PEN;
157 else if (!strcmp (tmp_name, "eraser"))
158 gdkdev->info.source = GDK_SOURCE_ERASER;
159 else if (!strcmp (tmp_name, "cursor"))
160 gdkdev->info.source = GDK_SOURCE_CURSOR;
162 gdkdev->info.source = GDK_SOURCE_PEN;
166 gdkdev->xdevice = NULL;
168 /* step through the classes */
170 gdkdev->info.num_axes = 0;
171 gdkdev->info.num_keys = 0;
172 gdkdev->info.keys = NULL;
174 gdkdev->info.has_cursor = 0;
175 gdkdev->needs_update = FALSE;
176 gdkdev->claimed = FALSE;
177 gdkdev->button_state = 0;
179 class = device->inputclassinfo;
180 for (i=0;i<device->num_classes;i++)
182 switch (class->class) {
189 XKeyInfo *xki = (XKeyInfo *)class;
190 /* Hack to catch XFree86 3.3.1 bug. Other devices better
191 * not have exactly 25 keys...
193 if ((xki->min_keycode == 8) && (xki->max_keycode == 32))
195 gdkdev->info.num_keys = 32;
196 gdkdev->min_keycode = 1;
200 gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
201 gdkdev->min_keycode = xki->min_keycode;
203 gdkdev->info.keys = g_new (GdkDeviceKey, gdkdev->info.num_keys);
205 for (j=0; j<gdkdev->info.num_keys; j++)
207 gdkdev->info.keys[j].keyval = 0;
208 gdkdev->info.keys[j].modifiers = 0;
215 XValuatorInfo *xvi = (XValuatorInfo *)class;
216 gdkdev->info.num_axes = xvi->num_axes;
217 gdkdev->axes = g_new(GdkAxisInfo, xvi->num_axes);
218 gdkdev->info.axes = g_new(GdkAxisUse, xvi->num_axes);
219 for (j=0;j<xvi->num_axes;j++)
221 gdkdev->axes[j].resolution =
222 gdkdev->axes[j].xresolution = xvi->axes[j].resolution;
223 gdkdev->axes[j].min_value =
224 gdkdev->axes[j].xmin_value = xvi->axes[j].min_value;
225 gdkdev->axes[j].max_value =
226 gdkdev->axes[j].xmax_value = xvi->axes[j].max_value;
227 gdkdev->info.axes[j] = GDK_AXIS_IGNORE;
231 gdkdev->info.axes[j++] = GDK_AXIS_X;
233 gdkdev->info.axes[j++] = GDK_AXIS_Y;
235 gdkdev->info.axes[j++] = GDK_AXIS_PRESSURE;
237 gdkdev->info.axes[j++] = GDK_AXIS_XTILT;
239 gdkdev->info.axes[j++] = GDK_AXIS_YTILT;
241 /* set up reverse lookup on axis use */
242 for (j=GDK_AXIS_IGNORE;j<GDK_AXIS_LAST;j++)
243 gdkdev->axis_for_use[j] = -1;
245 for (j=0;j<xvi->num_axes;j++)
246 if (gdkdev->info.axes[j] != GDK_AXIS_IGNORE)
247 gdkdev->axis_for_use[gdkdev->info.axes[j]] = j;
252 class = (XAnyClassPtr)(((char *)class) + class->length);
254 /* return NULL if no axes */
255 if (!gdkdev->info.num_axes || !gdkdev->axes ||
256 (!include_core && device->use == IsXPointer))
258 g_free(gdkdev->info.name);
260 g_free(gdkdev->axes);
261 if (gdkdev->info.keys)
262 g_free(gdkdev->info.keys);
267 if (device->use != IsXPointer)
269 int error_warn = gdk_error_warnings;
271 gdk_error_warnings = 0;
273 gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
274 gdk_error_warnings = error_warn;
276 /* return NULL if device is not ready */
279 g_free (gdkdev->info.name);
281 g_free (gdkdev->axes);
282 if (gdkdev->info.keys)
283 g_free (gdkdev->info.keys);
284 if (gdkdev->info.axes)
285 g_free (gdkdev->info.axes);
292 gdkdev->buttonpress_type = 0;
293 gdkdev->buttonrelease_type = 0;
294 gdkdev->keypress_type = 0;
295 gdkdev->keyrelease_type = 0;
296 gdkdev->motionnotify_type = 0;
297 gdkdev->proximityin_type = 0;
298 gdkdev->proximityout_type = 0;
299 gdkdev->changenotify_type = 0;
305 gdk_input_common_find_events(GdkWindow *window,
306 GdkDevicePrivate *gdkdev,
308 XEventClass *classes,
315 /* We have to track press and release events in pairs to keep
316 track of button state correctly and implement grabbing for
318 if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
320 DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
323 classes[i++] = class;
324 DeviceButtonPressGrab (gdkdev->xdevice, 0, class);
326 classes[i++] = class;
327 DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
330 classes[i++] = class;
332 if (mask & GDK_POINTER_MOTION_MASK)
334 DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
336 classes[i++] = class;
339 if (mask & (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
340 GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
341 GDK_POINTER_MOTION_HINT_MASK))
343 /* Make sure gdkdev->motionnotify_type is set */
344 DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
346 if (mask & GDK_BUTTON1_MOTION_MASK)
348 DeviceButton1Motion (gdkdev->xdevice, 0, class);
350 classes[i++] = class;
352 if (mask & GDK_BUTTON2_MOTION_MASK)
354 DeviceButton2Motion (gdkdev->xdevice, 0, class);
356 classes[i++] = class;
358 if (mask & GDK_BUTTON3_MOTION_MASK)
360 DeviceButton3Motion (gdkdev->xdevice, 0, class);
362 classes[i++] = class;
364 if (mask & GDK_BUTTON_MOTION_MASK)
366 DeviceButtonMotion (gdkdev->xdevice, 0, class);
368 classes[i++] = class;
370 if (mask & GDK_POINTER_MOTION_HINT_MASK)
372 /* We'll get into trouble if the macros change, but at least we'll
373 know about it, and we avoid warnings now */
374 DevicePointerMotionHint (gdkdev->xdevice, 0, class);
376 classes[i++] = class;
378 if (mask & GDK_KEY_PRESS_MASK)
380 DeviceKeyPress (gdkdev->xdevice, gdkdev->keypress_type, class);
382 classes[i++] = class;
384 if (mask & GDK_KEY_RELEASE_MASK)
386 DeviceKeyRelease (gdkdev->xdevice, gdkdev->keyrelease_type, class);
388 classes[i++] = class;
390 if (mask & GDK_PROXIMITY_IN_MASK)
392 ProximityIn (gdkdev->xdevice, gdkdev->proximityin_type, class);
394 classes[i++] = class;
396 if (mask & GDK_PROXIMITY_OUT_MASK)
398 ProximityOut (gdkdev->xdevice, gdkdev->proximityout_type, class);
400 classes[i++] = class;
407 gdk_input_common_select_events(GdkWindow *window,
408 GdkDevicePrivate *gdkdev)
410 XEventClass classes[GDK_MAX_DEVICE_CLASSES];
413 if (gdkdev->info.mode == GDK_MODE_DISABLED)
414 gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes);
416 gdk_input_common_find_events(window, gdkdev,
417 ((GdkWindowPrivate *)window)->extension_events,
418 classes, &num_classes);
420 XSelectExtensionEvent (gdk_display,
421 GDK_WINDOW_XWINDOW(window),
422 classes, num_classes);
426 gdk_input_common_init(gint include_core)
429 XDeviceInfo *devices;
431 int num_extensions, loop;
432 Display *display = gdk_display;
434 /* Init global vars */
435 gdk_window_get_geometry(NULL, /* use root window */
437 &gdk_input_root_width,&gdk_input_root_height,
440 /* Init XInput extension */
442 extensions = XListExtensions(display, &num_extensions);
443 for (loop = 0; loop < num_extensions &&
444 (strcmp(extensions[loop], "XInputExtension") != 0); loop++);
445 XFreeExtensionList(extensions);
446 gdk_input_devices = NULL;
447 if (loop < num_extensions)
449 /* XInput extension found */
451 devices = XListInputDevices(display, &num_devices);
453 for(loop=0; loop<num_devices; loop++)
455 GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
458 gdk_input_devices = g_list_append(gdk_input_devices, gdkdev);
460 XFreeDeviceList(devices);
463 gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
469 gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
470 GdkInputWindow *input_window,
472 gdouble *x, gdouble *y, gdouble *pressure,
473 gdouble *xtilt, gdouble *ytilt)
475 GdkWindowPrivate *win_priv;
477 int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis;
479 double device_width, device_height;
480 double x_offset, y_offset, x_scale, y_scale;
482 win_priv = (GdkWindowPrivate *) input_window->window;
484 x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
485 y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
486 pressure_axis = gdkdev->axis_for_use[GDK_AXIS_PRESSURE];
487 xtilt_axis = gdkdev->axis_for_use[GDK_AXIS_XTILT];
488 ytilt_axis = gdkdev->axis_for_use[GDK_AXIS_YTILT];
490 device_width = gdkdev->axes[x_axis].max_value -
491 gdkdev->axes[x_axis].min_value;
492 device_height = gdkdev->axes[y_axis].max_value -
493 gdkdev->axes[y_axis].min_value;
495 if (gdkdev->info.mode == GDK_MODE_SCREEN)
497 x_scale = gdk_input_root_width / device_width;
498 y_scale = gdk_input_root_height / device_height;
500 x_offset = - input_window->root_x;
501 y_offset = - input_window->root_y;
503 else /* GDK_MODE_WINDOW */
505 double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /
506 (device_width*gdkdev->axes[x_axis].resolution);
508 if (device_aspect * win_priv->width >= win_priv->height)
510 /* device taller than window */
511 x_scale = win_priv->width / device_width;
512 y_scale = (x_scale * gdkdev->axes[x_axis].resolution)
513 / gdkdev->axes[y_axis].resolution;
516 y_offset = -(device_height * y_scale -
521 /* window taller than device */
522 y_scale = win_priv->height / device_height;
523 x_scale = (y_scale * gdkdev->axes[y_axis].resolution)
524 / gdkdev->axes[x_axis].resolution;
527 x_offset = - (device_width * x_scale - win_priv->width)/2;
531 if (x) *x = x_offset + x_scale*axis_data[x_axis];
532 if (y) *y = y_offset + y_scale*axis_data[y_axis];
536 if (pressure_axis != -1)
537 *pressure = ((double)axis_data[pressure_axis]
538 - gdkdev->axes[pressure_axis].min_value)
539 / (gdkdev->axes[pressure_axis].max_value
540 - gdkdev->axes[pressure_axis].min_value);
547 if (xtilt_axis != -1)
549 *xtilt = 2. * (double)(axis_data[xtilt_axis] -
550 (gdkdev->axes[xtilt_axis].min_value +
551 gdkdev->axes[xtilt_axis].max_value)/2) /
552 (gdkdev->axes[xtilt_axis].max_value -
553 gdkdev->axes[xtilt_axis].min_value);
560 if (ytilt_axis != -1)
562 *ytilt = 2. * (double)(axis_data[ytilt_axis] -
563 (gdkdev->axes[ytilt_axis].min_value +
564 gdkdev->axes[ytilt_axis].max_value)/2) /
565 (gdkdev->axes[ytilt_axis].max_value -
566 gdkdev->axes[ytilt_axis].min_value);
573 /* combine the state of the core device and the device state
574 into one - for now we do this in a simple-minded manner -
575 we just take the keyboard portion of the core device and
576 the button portion (all of?) the device state.
577 Any button remapping should go on here. */
579 gdk_input_translate_state(guint state, guint device_state)
581 return device_state | (state & 0xFF);
585 gdk_input_common_other_event (GdkEvent *event,
587 GdkInputWindow *input_window,
588 GdkDevicePrivate *gdkdev)
590 if ((xevent->type == gdkdev->buttonpress_type) ||
591 (xevent->type == gdkdev->buttonrelease_type))
593 XDeviceButtonEvent *xdbe = (XDeviceButtonEvent *)(xevent);
595 if (xdbe->type == gdkdev->buttonpress_type)
597 event->button.type = GDK_BUTTON_PRESS;
598 gdkdev->button_state |= 1 << xdbe->button;
602 event->button.type = GDK_BUTTON_RELEASE;
603 gdkdev->button_state &= ~(1 << xdbe->button);
605 event->button.window = input_window->window;
606 event->button.time = xdbe->time;
607 event->button.source = gdkdev->info.source;
608 event->button.deviceid = xdbe->deviceid;
610 gdk_input_translate_coordinates (gdkdev,input_window, xdbe->axis_data,
611 &event->button.x,&event->button.y,
612 &event->button.pressure,
613 &event->button.xtilt,
614 &event->button.ytilt);
615 event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
616 event->button.button = xdbe->button;
619 g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n",
620 (event->button.type == GDK_BUTTON_PRESS) ? "press" : "release",
623 event->button.x, event->button.y,
629 if ((xevent->type == gdkdev->keypress_type) ||
630 (xevent->type == gdkdev->keyrelease_type))
632 XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
635 g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
636 (event->key.type == GDK_KEY_PRESS) ? "press" : "release",
641 if (xdke->keycode < gdkdev->min_keycode ||
642 xdke->keycode >= gdkdev->min_keycode + gdkdev->info.num_keys)
644 g_warning ("Invalid device key code received");
648 event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
650 if (event->key.keyval == 0)
653 g_print ("\t\ttranslation - NONE\n"));
658 event->key.type = (xdke->type == gdkdev->keypress_type) ?
659 GDK_KEY_PRESS : GDK_KEY_RELEASE;
661 event->key.window = input_window->window;
662 event->key.time = xdke->time;
664 event->key.state = gdk_input_translate_state(xdke->state, xdke->device_state)
665 | gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].modifiers;
667 /* Add a string translation for the key event */
668 if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF))
670 event->key.length = 1;
671 event->key.string = g_new (gchar, 2);
672 event->key.string[0] = (gchar)event->key.keyval;
673 event->key.string[1] = 0;
677 event->key.length = 0;
678 event->key.string = g_new0 (gchar, 1);
682 g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
689 if (xevent->type == gdkdev->motionnotify_type)
691 XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
693 gdk_input_translate_coordinates(gdkdev,input_window,xdme->axis_data,
694 &event->motion.x,&event->motion.y,
695 &event->motion.pressure,
696 &event->motion.xtilt,
697 &event->motion.ytilt);
699 event->motion.type = GDK_MOTION_NOTIFY;
700 event->motion.window = input_window->window;
701 event->motion.time = xdme->time;
702 event->motion.deviceid = xdme->deviceid;
703 event->motion.state = gdk_input_translate_state(xdme->state,
705 event->motion.is_hint = xdme->is_hint;
706 event->motion.source = gdkdev->info.source;
707 event->motion.deviceid = xdme->deviceid;
710 g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n",
713 event->motion.x, event->motion.y,
715 (xdme->is_hint) ? "true" : "false"));
721 if (xevent->type == gdkdev->proximityin_type ||
722 xevent->type == gdkdev->proximityout_type)
724 XProximityNotifyEvent *xpne = (XProximityNotifyEvent *)(xevent);
726 event->proximity.type = (xevent->type == gdkdev->proximityin_type)?
727 GDK_PROXIMITY_IN:GDK_PROXIMITY_OUT;
728 event->proximity.window = input_window->window;
729 event->proximity.time = xpne->time;
730 event->proximity.source = gdkdev->info.source;
731 event->proximity.deviceid = xpne->deviceid;
736 return -1; /* wasn't one of our event types */
740 gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
743 GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
744 g_return_if_fail (gdkdev != NULL);
746 for (i=GDK_AXIS_IGNORE;i<GDK_AXIS_LAST;i++)
748 gdkdev->axis_for_use[i] = -1;
751 for (i=0;i<gdkdev->info.num_axes;i++)
753 gdkdev->info.axes[i] = axes[i];
754 gdkdev->axis_for_use[axes[i]] = i;
758 void gdk_input_common_set_key (guint32 deviceid,
761 GdkModifierType modifiers)
763 GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
765 gdkdev = gdk_input_find_device (deviceid);
766 g_return_if_fail (gdkdev != NULL);
767 g_return_if_fail (index < gdkdev->info.num_keys);
769 gdkdev->info.keys[index].keyval = keyval;
770 gdkdev->info.keys[index].modifiers = modifiers;
773 static GdkTimeCoord *
774 gdk_input_common_motion_events (GdkWindow *window,
778 gint *nevents_return)
780 GdkTimeCoord *coords;
781 XDeviceTimeCoord *device_coords;
782 GdkInputWindow *input_window;
783 GdkDevicePrivate *gdkdev;
786 int axis_count_return;
789 gdkdev = gdk_input_find_device (deviceid);
790 input_window = gdk_input_window_find (window);
792 g_return_val_if_fail (gdkdev != NULL, NULL);
793 g_return_val_if_fail (gdkdev->xdevice != NULL, NULL);
794 g_return_val_if_fail (input_window != NULL, NULL);
796 device_coords = XGetDeviceMotionEvents (gdk_display,
799 nevents_return, &mode_return,
804 coords = g_new (GdkTimeCoord, *nevents_return);
806 for (i=0; i<*nevents_return; i++)
808 gdk_input_translate_coordinates (gdkdev, input_window,
809 device_coords[i].data,
810 &coords[i].x, &coords[i].y,
812 &coords[i].xtilt, &coords[i].ytilt);
814 XFreeDeviceMotionEvents (device_coords);
823 gdk_input_common_get_pointer (GdkWindow *window,
830 GdkModifierType *mask)
832 GdkDevicePrivate *gdkdev;
833 GdkInputWindow *input_window;
835 XInputClass *input_class;
839 /* we probably need to get the mask in any case */
841 if (deviceid == GDK_CORE_POINTER)
843 gdk_window_get_pointer (window, &x_int, &y_int, mask);
846 if (pressure) *pressure = 0.5;
847 if (xtilt) *xtilt = 0;
848 if (ytilt) *ytilt = 0;
853 gdk_window_get_pointer (window, NULL, NULL, mask);
855 gdkdev = gdk_input_find_device (deviceid);
856 input_window = gdk_input_window_find (window);
858 g_return_if_fail (gdkdev != NULL);
859 g_return_if_fail (gdkdev->xdevice != NULL);
860 g_return_if_fail (input_window != NULL);
862 state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
863 input_class = state->data;
864 for (i=0; i<state->num_classes; i++)
866 switch (input_class->class)
869 gdk_input_translate_coordinates (gdkdev, input_window,
870 ((XValuatorState *)input_class)->valuators,
880 if (((XButtonState *)input_class)->num_buttons > 0)
881 *mask |= ((XButtonState *)input_class)->buttons[0] << 7;
882 /* GDK_BUTTON1_MASK = 1 << 8, and button n is stored
883 * in bit 1<<(n%8) in byte n/8. n = 1,2,... */
887 input_class = (XInputClass *)(((char *)input_class)+input_class->length);