Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.6286.2.307
diff -u -p -r1.6286.2.307 ChangeLog
--- ChangeLog	27 Jul 2005 06:13:48 -0000	1.6286.2.307
+++ ChangeLog	28 Jul 2005 09:38:23 -0000
@@ -1,3 +1,13 @@
+2005-07-28  Robert Ă–gren  <gtk@roboros.com>
+
+	Avoid spurious core pointer events when the tablet pen is lifted
+	(#167000)
+
+	* gdk/win32/gdkinput-win32.c (set_ignore_core): New static function,
+	handles delayed unsetting of _gdk_input_ignore_core.
+	(_gdk_input_other_event): Call set_ignore_core instead of setting
+	_gdk_input_ignore_core directly.
+
 2005-07-27  Tor Lillqvist  <tml@novell.com>
 
 	* gdk/win32/gdkmain-win32.c (_gdk_win32_psstyle_to_string): Handle
@@ -52,7 +62,7 @@
 	them for staleness like the other caches.  (#310221, Mark 
 	McLoughlin)
 
-2005-07-13  Robert Ögren  <gtk@roboros.com>
+2005-07-13  Robert Ă–gren  <gtk@roboros.com>
 
 	Fix handling of Aiptek and Aiptek-like graphical tablets such as Trust
 	on Windows. (#167004, thanks to	"pnohant" for testing)
Index: gdk/win32/gdkinput-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkinput-win32.c,v
retrieving revision 1.50.2.3
diff -u -p -r1.50.2.3 gdkinput-win32.c
--- gdk/win32/gdkinput-win32.c	13 Jul 2005 12:44:22 -0000	1.50.2.3
+++ gdk/win32/gdkinput-win32.c	28 Jul 2005 09:38:24 -0000
@@ -45,6 +45,8 @@
 
 #define DEBUG_WINTAB 1		/* Verbose debug messages enabled */
 
+#define PROXIMITY_OUT_DELAY 200 /* In milliseconds, see set_ignore_core */
+
 #endif
 
 #if defined(HAVE_WINTAB) || defined(HAVE_WHATEVER_OTHER)
@@ -652,6 +654,47 @@ get_modifier_key_state (void)
   return state;
 }
 
+#ifdef HAVE_WINTAB
+
+static guint ignore_core_timer = 0;
+
+static gboolean
+ignore_core_timefunc (gpointer data)
+{
+  /* The delay has passed */
+  _gdk_input_ignore_core = FALSE;
+  ignore_core_timer = 0;
+
+  return FALSE; /* remove timeout */
+}
+
+/*
+ * Set or unset the _gdk_input_ignore_core variable that tells GDK
+ * to ignore events for the core pointer when the tablet is in proximity
+ * The unsetting is delayed slightly so that if a tablet event arrives
+ * just after proximity out, it does not cause a core pointer event
+ * which e.g. causes GIMP to switch tools.
+ */
+static void
+set_ignore_core (gboolean ignore)
+{
+  if (ignore)
+    {
+      _gdk_input_ignore_core = TRUE;
+      /* Remove any pending clear */
+      if (ignore_core_timer)
+        {
+	  g_source_remove (ignore_core_timer);
+	  ignore_core_timer = 0;
+	}
+    }
+  else
+    if (!ignore_core_timer)
+      ignore_core_timer = g_timeout_add (PROXIMITY_OUT_DELAY,
+					 ignore_core_timefunc, NULL);
+}
+#endif /* HAVE_WINTAB */
+
 gboolean 
 _gdk_input_other_event (GdkEvent  *event,
 			MSG       *msg,
@@ -934,12 +977,12 @@ _gdk_input_other_event (GdkEvent  *event
       if (LOWORD (msg->lParam) == 0)
 	{
 	  event->proximity.type = GDK_PROXIMITY_OUT;
-	  _gdk_input_ignore_core = FALSE;
+	  set_ignore_core (FALSE);
 	}
       else
 	{
 	  event->proximity.type = GDK_PROXIMITY_IN;
-	  _gdk_input_ignore_core = TRUE;
+	  set_ignore_core (TRUE);
 	}
       event->proximity.time = _gdk_win32_get_next_tick (msg->time);
       event->proximity.device = &gdkdev->info;
