Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.6286.2.68
diff -u -p -r1.6286.2.68 ChangeLog
--- ChangeLog	11 Feb 2005 17:31:44 -0000	1.6286.2.68
+++ ChangeLog	13 Feb 2005 21:05:25 -0000
@@ -1,3 +1,16 @@
+2005-02-13  Robert Ögren  <gtk@roboros.com>
+
+	Implement better handling of Wintab tablet context overlap on Win32
+	(#167298)
+
+	* gdk/win32/gdkinput-win32.c (_gdk_input_set_tablet_active): New
+	  function that brings any tablet contexts to the top of the
+	  overlap order.
+	* gdk/win32/gdkinput-win32.h: Declare _gdk_input_set_tablet_active ()
+	* gdk/win32/gdkevents-win32.c (gdk_event_translate):
+	  Call _gdk_input_set_tablet_active when a window is activated
+	  (on WM_ACTIVATE)
+
 2005-02-11  Matthias Clasen  <mclasen@redhat.com>
 
 	* gtk/gtkpathbar.c (gtk_path_bar_finalize): Stop scrolling 
Index: gdk/win32/gdkevents-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkevents-win32.c,v
retrieving revision 1.141.2.2
diff -u -p -r1.141.2.2 gdkevents-win32.c
--- gdk/win32/gdkevents-win32.c	1 Feb 2005 11:33:58 -0000	1.141.2.2
+++ gdk/win32/gdkevents-win32.c	13 Feb 2005 21:05:25 -0000
@@ -3367,6 +3367,16 @@ gdk_event_translate (GdkDisplay *display
       break;
  
 #ifdef HAVE_WINTAB
+    case WM_ACTIVATE:
+      /* Bring any tablet contexts to the top of the overlap order when
+       * one of our windows is activated.
+       * NOTE: It doesn't seem to work well if it is done in WM_ACTIVATEAPP
+       * instead
+       */
+      if (LOWORD(msg->wParam) != WA_INACTIVE)
+	_gdk_input_set_tablet_active ();
+      break;
+      
       /* Handle WINTAB events here, as we know that gdkinput.c will
        * use the fixed WT_DEFBASE as lcMsgBase, and we thus can use the
        * constants as case labels.
Index: gdk/win32/gdkinput-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkinput-win32.c,v
retrieving revision 1.50.2.1
diff -u -p -r1.50.2.1 gdkinput-win32.c
--- gdk/win32/gdkinput-win32.c	2 Feb 2005 18:13:41 -0000	1.50.2.1
+++ gdk/win32/gdkinput-win32.c	13 Feb 2005 21:05:25 -0000
@@ -1273,6 +1273,32 @@ gdk_device_get_state (GdkDevice       *d
     }
 }
 
+#ifdef HAVE_WINTAB
+void
+_gdk_input_set_tablet_active (void)
+{
+  GList *tmp_list;
+  HCTX *hctx;
+
+  /* Bring the contexts to the top of the overlap order when one of the
+   * application's windows is activated */
+  
+  if (!wintab_contexts)
+    return; /* No tablet devices found, or Wintab not initialized yet */
+  
+  GDK_NOTE (INPUT, g_print ("_gdk_input_set_tablet_active: "
+	"Bringing Wintab contexts to the top of the overlap order\n"));
+
+  tmp_list = wintab_contexts;
+  while (tmp_list)
+    {
+      hctx = (HCTX *) (tmp_list->data);
+      WTOverlap (*hctx, TRUE);
+      tmp_list = tmp_list->next;
+    }
+}
+#endif /* HAVE_WINTAB */
+
 void 
 _gdk_input_init (GdkDisplay *display)
 {
Index: gdk/win32/gdkinput-win32.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkinput-win32.h,v
retrieving revision 1.10.4.1
diff -u -p -r1.10.4.1 gdkinput-win32.h
--- gdk/win32/gdkinput-win32.h	2 Feb 2005 18:13:41 -0000	1.10.4.1
+++ gdk/win32/gdkinput-win32.h	13 Feb 2005 21:05:25 -0000
@@ -168,6 +168,7 @@ gboolean         _gdk_device_get_history
 
 #ifdef HAVE_WINTAB
 void		_gdk_input_wintab_init_check (void);
+void		_gdk_input_set_tablet_active (void);
 #endif /* HAVE_WINTAB */
 
 #endif /* __GDK_INPUT_WIN32_H__ */
