Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.5367.2.32
diff -u -r1.5367.2.32 ChangeLog
--- ChangeLog	24 May 2004 22:30:52 -0000	1.5367.2.32
+++ ChangeLog	26 May 2004 20:28:39 -0000
@@ -1,3 +1,9 @@
+2004-05-26  Robert Ögren  <gtk@roboros.com>
+
+	* gdk/win32/gdkinput-win32.c (gdk_device_get_state): Simple
+	implementation for extended input devices using last known 
+	device state (#143237)
+
 2004-05-11  Robert Ögren  <gtk@roboros.com>
 
 	* gdk/win32/gdkevents-win32.c (propagate): Don't propagate mouse
Index: gdk/win32/gdkinput-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkinput-win32.c,v
retrieving revision 1.41.2.3
diff -u -r1.41.2.3 gdkinput-win32.c
--- gdk/win32/gdkinput-win32.c	24 May 2004 22:30:52 -0000	1.41.2.3
+++ gdk/win32/gdkinput-win32.c	26 May 2004 20:28:40 -0000
@@ -1196,42 +1196,27 @@
       GdkDevicePrivate *gdkdev;
       GdkInputWindow *input_window;
       
-      if (mask)
-	gdk_window_get_pointer (window, NULL, NULL, mask);
-      
       gdkdev = (GdkDevicePrivate *)device;
-      input_window = _gdk_input_window_find (window);
-      g_return_if_fail (input_window != NULL);
-
-#if 0 /* FIXME */
-      state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
-      input_class = state->data;
-      for (i = 0; i < state->num_classes; i++)
+      /* For now just use the last known button and axis state of the device.
+       * Since graphical tablets send an insane amount of motion events each
+       * second, the info should be fairly up to date */
+      if (mask)
 	{
-	  switch (input_class->class)
-	    {
-	    case ValuatorClass:
-	      if (axes)
-		gdk_input_translate_coordinates (gdkdev, input_window,
-						 ((XValuatorState *)input_class)->valuators,
-						 axes, NULL, NULL);
-	      break;
-	      
-	    case ButtonClass:
-	      if (mask)
-		{
-		  *mask &= 0xFF;
-		  if (((XButtonState *)input_class)->num_buttons > 0)
-		    *mask |= ((XButtonState *)input_class)->buttons[0] << 7;
-		  /* GDK_BUTTON1_MASK = 1 << 8, and button n is stored
-		   * in bit 1<<(n%8) in byte n/8. n = 1,2,... */
-		}
-	      break;
-	    }
-	  input_class = (XInputClass *)(((char *)input_class)+input_class->length);
+	  gdk_window_get_pointer (window, NULL, NULL, mask);
+	  *mask &= 0xFF; /* Mask away core pointer buttons */
+	  *mask |= ((gdkdev->button_state << 8)
+		    & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK
+		       | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK
+		       | GDK_BUTTON5_MASK));
 	}
-      XFreeDeviceState (state);
-#endif
+      input_window = _gdk_input_window_find (window);
+      g_return_if_fail (input_window != NULL);
+      /* For some reason, input_window is sometimes NULL when I use The GIMP 2
+       * (bug #141543?). Avoid crashing if debugging is disabled. */
+      if (axes && gdkdev->last_axis_data && input_window)
+	gdk_input_translate_coordinates (gdkdev, input_window,
+					 gdkdev->last_axis_data,
+					 axes, NULL, NULL);
     }
 }
 
