]> Pileus Git - ~andy/gtk/blobdiff - gdk/win32/gdkinput-win32.c
Print debugging output only if asked for, not always.
[~andy/gtk] / gdk / win32 / gdkinput-win32.c
index a03c1024dfe5c2efd56759ad4c623ad66fb6f898..10e2c8f4b5f4447dddd353354e15b9d95996ac10 100644 (file)
@@ -71,9 +71,9 @@ static GdkInputWindow *gdk_input_window_find_within (GdkWindow *window);
 
 static GdkDevicePrivate *gdk_input_find_dev_from_ctx (HCTX hctx,
                                                      UINT id);
-static GList     *wintab_contexts;
+static GList     *wintab_contexts = NULL;
 
-static GdkWindow *wintab_window;
+static GdkWindow *wintab_window = NULL;
 
 #endif /* HAVE_WINTAB */
 
@@ -204,9 +204,10 @@ print_lc(LOGCONTEXT *lc)
 
 #endif
 
-static void
-gdk_input_wintab_init (void)
+void
+_gdk_input_wintab_init_check (void)
 {
+  static gboolean wintab_initialized = FALSE;
   GdkDevicePrivate *gdkdev;
   GdkWindowAttr wa;
   WORD specversion;
@@ -219,7 +220,11 @@ gdk_input_wintab_init (void)
   int devix, cursorix;
   char devname[100], csrname[100];
 
-  _gdk_input_devices = NULL;
+  if (wintab_initialized)
+    return;
+  
+  wintab_initialized = TRUE;
+  
   wintab_contexts = NULL;
 
   if (!_gdk_input_ignore_wintab &&
@@ -485,7 +490,7 @@ gdk_input_wintab_init (void)
                                 gdkdev->info.num_axes));
              for (i = 0; i < gdkdev->info.num_axes; i++)
                GDK_NOTE (INPUT,
-                         g_print ("...axis %d: %d--%d@%d (%d--%d@%d)\n",
+                         g_print ("... axis %d: %d--%d@%d (%d--%d@%d)\n",
                                   i,
                                   gdkdev->axes[i].xmin_value, 
                                   gdkdev->axes[i].xmax_value, 
@@ -757,7 +762,7 @@ _gdk_input_other_event (GdkEvent  *event,
   display = gdk_drawable_get_display (window);
 
   GDK_NOTE (EVENTS_OR_INPUT,
-           g_print ("gdk_input_win32_other_event: window=%p (%d,%d)\n",
+           g_print ("gdk_input_win32_other_event: window=%p %+d%+d\n",
                     GDK_WINDOW_HWND (window), x, y));
   
 #else
@@ -786,12 +791,12 @@ _gdk_input_other_event (GdkEvent  *event,
        * moved or resized, see bug #151090. */
       if (_sizemove_in_progress)
        {
-         GDK_NOTE (EVENTS_OR_INPUT, g_print ("...ignored when moving/sizing\n"));
+         GDK_NOTE (EVENTS_OR_INPUT, g_print ("... ignored when moving/sizing\n"));
          return FALSE;
        }
       if (window == _gdk_parent_root && x_grab_window == NULL)
        {
-         GDK_NOTE (EVENTS_OR_INPUT, g_print ("...is root\n"));
+         GDK_NOTE (EVENTS_OR_INPUT, g_print ("... is root\n"));
          return FALSE;
        }
 
@@ -858,10 +863,10 @@ _gdk_input_other_event (GdkEvent  *event,
              || !(x_grab_mask && masktest))
            {
              GDK_NOTE (EVENTS_OR_INPUT, 
-                       g_print ("...grabber doesn't want it\n"));
+                       g_print ("... grabber doesn't want it\n"));
              return FALSE;
            }
-         GDK_NOTE (EVENTS_OR_INPUT, g_print ("...to grabber\n"));
+         GDK_NOTE (EVENTS_OR_INPUT, g_print ("... to grabber\n"));
 
          g_object_ref(x_grab_window);
          g_object_unref(window);
@@ -875,7 +880,7 @@ _gdk_input_other_event (GdkEvent  *event,
       if (!GDK_WINDOW_IMPL_WIN32 (obj->impl)->extension_events_selected
          || !(obj->extension_events & masktest))
        {
-         GDK_NOTE (EVENTS_OR_INPUT, g_print ("...not selected\n"));
+         GDK_NOTE (EVENTS_OR_INPUT, g_print ("... not selected\n"));
 
          if (obj->parent == GDK_WINDOW_OBJECT (_gdk_parent_root))
            return FALSE;
@@ -885,7 +890,7 @@ _gdk_input_other_event (GdkEvent  *event,
          if (obj->event_mask & masktest)
            {
              GDK_NOTE (EVENTS_OR_INPUT, 
-                       g_print ("...wants ordinary event, ignoring this\n"));
+                       g_print ("... wants ordinary event, ignoring this\n"));
              return FALSE;
            }
          
@@ -899,7 +904,7 @@ _gdk_input_other_event (GdkEvent  *event,
          ScreenToClient (GDK_WINDOW_HWND (window), &pt);
          x = pt.x;
          y = pt.y;
-         GDK_NOTE (EVENTS_OR_INPUT, g_print ("...propagating to %p (%d,%d)\n",
+         GDK_NOTE (EVENTS_OR_INPUT, g_print ("... propagating to %p %+d%+d\n",
                                              GDK_WINDOW_HWND (window), x, y));
          goto dijkstra;
        }
@@ -1268,6 +1273,32 @@ gdk_device_get_state (GdkDevice       *device,
     }
 }
 
+#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)
 {
@@ -1276,7 +1307,13 @@ _gdk_input_init (GdkDisplay *display)
 
   _gdk_init_input_core (display);
 #ifdef HAVE_WINTAB
-  gdk_input_wintab_init ();
+#ifdef WINTAB_NO_LAZY_INIT
+  /* Normally, Wintab is only initialized when the application performs
+   * an action that requires it, such as enabling extended input events
+   * for a window or enumerating the devices.
+   */
+  _gdk_input_wintab_init_check ();
+#endif /* WINTAB_NO_LAZY_INIT */
 #endif /* HAVE_WINTAB */
 
   _gdk_input_devices = g_list_append (_gdk_input_devices, display->core_pointer);