Fixes for Wintab problems by Robert OEgren. Possible ChangeLog entry:

2004-05-11  Robert OEgren  <gtk@roboros.com>

	* gdk/win32/gdkevents-win32.c: Added missing call to g_object_ref
	in Wintab code (#138341)

	* gdk/win32/gdkinput-win32.c: Fixed numerous Wintab problems including
	unallocated buffers for event->motion.axes and event->button.axes,
	unsigned wraparound problem in the code for detecting missing
	press/release events and assigning min instead of max when setting
	up axes.

diff -ru gtk+-2.2.4-20040124.orig/gdk/win32/gdkevents-win32.c gtk+-2.2.4-20040124/gdk/win32/gdkevents-win32.c
--- gtk+-2.2.4-20040124.orig/gdk/win32/gdkevents-win32.c	2003-12-14 03:00:48.000000000 +0100
+++ gtk+-2.2.4-20040124/gdk/win32/gdkevents-win32.c	2004-05-11 19:01:39.203125000 +0100
@@ -3308,6 +3308,7 @@
 
       event = gdk_event_new (GDK_NOTHING);
       event->any.window = window;
+      g_object_ref (window);
       if (_gdk_input_other_event (event, msg, window))
 	append_event (display, event);
       else
diff -ru gtk+-2.2.4-20040124.orig/gdk/win32/gdkinput-win32.c gtk+-2.2.4-20040124/gdk/win32/gdkinput-win32.c
--- gtk+-2.2.4-20040124.orig/gdk/win32/gdkinput-win32.c	2003-08-07 22:59:34.000000000 +0100
+++ gtk+-2.2.4-20040124/gdk/win32/gdkinput-win32.c	2004-05-11 19:02:57.187500000 +0100
@@ -346,6 +346,20 @@
 	  GDK_NOTE (INPUT, (g_print("context for device %d after WTOpen:\n", devix),
 			   print_lc(&lc)));
 #endif
+	  /* Increase packet queue size to reduce the risk of lost packets */
+	  /* According to the specs, if the function fails we must try again */
+	  /* with a smaller queue size */
+	  GDK_NOTE (INPUT, g_print("Attempting to increase queue size\n"));
+	  for (i = 128; i >= 1; i >>= 1)
+	    {
+	      if (WTQueueSizeSet(*hctx, i))
+		{
+		  GDK_NOTE (INPUT, g_print("Queue size set to %d\n", i));
+		  break;
+		}
+	    }
+	  if (!i)
+	    GDK_NOTE (INPUT, g_print("Whoops, no queue size could be set\n"));
 	  for (cursorix = firstcsr; cursorix < firstcsr + ncsrtypes; cursorix++)
 	    {
 	      active = FALSE;
@@ -399,7 +413,7 @@
 		    gdkdev->axes[k].max_value = axis_x.axMax;
 		  gdkdev->info.axes[k].use = GDK_AXIS_X;
 		  gdkdev->info.axes[k].min = axis_x.axMin;
-		  gdkdev->info.axes[k].min = axis_x.axMax;
+		  gdkdev->info.axes[k].max = axis_x.axMax;
 		  k++;
 		}
 	      if (gdkdev->pktdata & PK_Y)
@@ -412,7 +426,7 @@
 		    gdkdev->axes[k].max_value = axis_y.axMax;
 		  gdkdev->info.axes[k].use = GDK_AXIS_Y;
 		  gdkdev->info.axes[k].min = axis_y.axMin;
-		  gdkdev->info.axes[k].min = axis_y.axMax;
+		  gdkdev->info.axes[k].max = axis_y.axMax;
 		  k++;
 		}
 	      if (gdkdev->pktdata & PK_NORMAL_PRESSURE)
@@ -424,8 +438,9 @@
 		  gdkdev->axes[k].xmax_value =
 		    gdkdev->axes[k].max_value = axis_npressure.axMax;
 		  gdkdev->info.axes[k].use = GDK_AXIS_PRESSURE;
-		  gdkdev->info.axes[k].min = axis_npressure.axMin;
-		  gdkdev->info.axes[k].min = axis_npressure.axMax;
+		  /* GIMP seems to expect values in the range 0-1 */
+		  gdkdev->info.axes[k].min = 0.0; /*axis_npressure.axMin;*/
+		  gdkdev->info.axes[k].max = 1.0; /*axis_npressure.axMax;*/
 		  k++;
 		}
 	      if (gdkdev->pktdata & PK_ORIENTATION)
@@ -447,7 +462,7 @@
 			gdkdev->axes[k].max_value = 1000;
 		      gdkdev->info.axes[k].use = axis;
 		      gdkdev->info.axes[k].min = -1000;
-		      gdkdev->info.axes[k].min = 1000;
+		      gdkdev->info.axes[k].max = 1000;
 		      k++;
 		    }
 		}
@@ -856,6 +871,8 @@
 	    return FALSE;
 #endif
 #endif
+	  event->button.axes = g_new(gdouble, gdkdev->info.num_axes);
+
 	  gdk_input_translate_coordinates (gdkdev, input_window,
 					   gdkdev->last_axis_data,
 					   event->button.axes,
@@ -879,6 +896,8 @@
 	  event->motion.is_hint = FALSE;
 	  event->motion.device = &gdkdev->info;
 
+	  event->motion.axes = g_new(gdouble, gdkdev->info.num_axes);
+
 	  gdk_input_translate_coordinates (gdkdev, input_window,
 					   gdkdev->last_axis_data,
 					   event->motion.axes,
@@ -900,7 +919,7 @@
 	   */
 	  if ((gdkdev->pktdata & PK_NORMAL_PRESSURE
 	       && (event->motion.state & GDK_BUTTON1_MASK)
-	       && packet.pkNormalPressure <= MAX (0, gdkdev->npbtnmarks[0] - 2))
+	       && packet.pkNormalPressure <= MAX (0, (gint) gdkdev->npbtnmarks[0] - 2))
 	      || (gdkdev->pktdata & PK_NORMAL_PRESSURE
 		  && !(event->motion.state & GDK_BUTTON1_MASK)
 		  && packet.pkNormalPressure > gdkdev->npbtnmarks[1] + 2))
