[gimp/gtk3-port: 208/226] app: gimp_device_info_get_device_coords():	workaround for XI2 b0rk
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gimp/gtk3-port: 208/226] app: gimp_device_info_get_device_coords():	workaround for XI2 b0rk
- Date: Tue, 21 Feb 2012 00:34:40 +0000 (UTC)
commit c6f8b73be75a1b6e6bd671609f6457554ae3d889
Author: Michael Natterer <mitch gimp org>
Date:   Sun Feb 27 16:06:11 2011 +0100
    app: gimp_device_info_get_device_coords(): workaround for XI2 b0rk
    
    for the time being, use gdk_window_get_device_position() instead of
    gdk_device_get_axis() for X and Y, which gets rid of subpixel
    coordinates, but at least returns values != 0. Also, don't ask
    keyboard devices for coordinates.
 app/widgets/gimpdeviceinfo-coords.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpdeviceinfo-coords.c b/app/widgets/gimpdeviceinfo-coords.c
index 796399a..e8797e1 100644
--- a/app/widgets/gimpdeviceinfo-coords.c
+++ b/app/widgets/gimpdeviceinfo-coords.c
@@ -117,12 +117,26 @@ gimp_device_info_get_device_coords (GimpDeviceInfo *info,
   if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_SLAVE)
     device = gdk_device_get_associated_device (device);
 
+  if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+    device = gdk_device_get_associated_device (device);
+
   *coords = default_coords;
 
   gdk_device_get_state (device, window, axes, NULL);
 
+#if 0
   gdk_device_get_axis (device, axes, GDK_AXIS_X, &coords->x);
   gdk_device_get_axis (device, axes, GDK_AXIS_Y, &coords->y);
+#else
+  {
+    gint x, y;
+
+    gdk_window_get_device_position (window, device, &x, &y, NULL);
+
+    coords->x = x;
+    coords->y = y;
+  }
+#endif
 
   if (gdk_device_get_axis (device,
                            axes, GDK_AXIS_PRESSURE, &coords->pressure))
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]