Make room for other API's than Wintab
authorLuca Bacci <luca.bacci982@gmail.com>
Fri, 18 Jun 2021 09:59:38 +0000 (11:59 +0200)
committerLuca Bacci <luca.bacci982@gmail.com>
Thu, 19 Aug 2021 13:57:38 +0000 (15:57 +0200)
gdk/win32/gdkdevicemanager-win32.c
gdk/win32/gdkevents-win32.c
gdk/win32/gdkglobals-win32.c
gdk/win32/gdkprivate-win32.h

index e41b69d1df36b669871ab4e2c72fd0c487eef2ab..19203ab8fe7b717b472e9b7359c5f0592ff62851 100644 (file)
@@ -685,6 +685,8 @@ gdk_device_manager_win32_constructed (GObject *object)
   GdkSeat *seat;
   GdkDisplayManager *display_manager = NULL;
   GdkDisplay *default_display = NULL;
+  const char *tablet_input_api_user_preference = NULL;
+  gboolean have_tablet_input_api_preference = FALSE;
 
   device_manager = GDK_DEVICE_MANAGER_WIN32 (object);
   device_manager->core_pointer =
@@ -725,18 +727,38 @@ gdk_device_manager_win32_constructed (GObject *object)
   gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), device_manager->system_keyboard);
   g_object_unref (seat);
 
-  /* Only call Wintab init stuff after the default display
-   * is globally known and accessible through the display manager
-   * singleton. Approach lifted from gtkmodules.c.
-   */
-  display_manager = gdk_display_manager_get ();
-  g_assert (display_manager != NULL);
-  default_display = gdk_display_manager_get_default_display (display_manager);
-  g_assert (default_display == NULL);
+  tablet_input_api_user_preference = g_getenv ("GDK_WIN32_TABLET_INPUT_API");
+  if (g_strcmp0 (tablet_input_api_user_preference, "none") == 0)
+    {
+      have_tablet_input_api_preference = TRUE;
+      _gdk_win32_tablet_input_api = GDK_WIN32_TABLET_INPUT_API_NONE;
+    }
+  else if (g_strcmp0 (tablet_input_api_user_preference, "wintab") == 0)
+    {
+      have_tablet_input_api_preference = TRUE;
+      _gdk_win32_tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINTAB;
+    }
+  else
+    {
+      have_tablet_input_api_preference = FALSE;
+      _gdk_win32_tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINTAB;
+    }
 
-  g_signal_connect (display_manager, "notify::default-display",
-                    G_CALLBACK (wintab_default_display_notify_cb),
-                    NULL);
+  if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
+    {
+      /* Only call Wintab init stuff after the default display
+       * is globally known and accessible through the display manager
+       * singleton. Approach lifted from gtkmodules.c.
+       */
+      display_manager = gdk_display_manager_get ();
+      g_assert (display_manager != NULL);
+      default_display = gdk_display_manager_get_default_display (display_manager);
+      g_assert (default_display == NULL);
+
+      g_signal_connect (display_manager, "notify::default-display",
+                        G_CALLBACK (wintab_default_display_notify_cb),
+                        NULL);
+    }
 }
 
 static void
index c469a886a20b666c1bbd64e3544e5e7cc47c4c84..db4f7d1aa7946c34de2e98791468cb0994d4ee4b 100644 (file)
@@ -3056,12 +3056,15 @@ gdk_event_translate (MSG *msg,
         {
           gdk_synthesize_surface_state (window, 0, GDK_TOPLEVEL_STATE_FOCUSED);
 
-          /* 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
-           */
-          _gdk_wintab_set_tablet_active ();
+          if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
+            {
+              /* 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
+               */
+              _gdk_wintab_set_tablet_active ();
+           }
         }
 
       break;
@@ -3100,11 +3103,14 @@ gdk_event_translate (MSG *msg,
       /* Fall through */
     wintab:
 
-      event = gdk_wintab_make_event (display, msg, window);
-      if (event)
+      if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
         {
-          _gdk_win32_append_event (event);
-         gdk_event_unref (event);
+          event = gdk_wintab_make_event (display, msg, window);
+          if (event)
+            {
+              _gdk_win32_append_event (event);
+               gdk_event_unref (event);
+            }
         }
 
       break;
index accc3f5d11979edc0f835b41c48606245e716950..9450830c6608d207a444a6933abd4dddfa52e232 100644 (file)
@@ -37,6 +37,7 @@ HINSTANCE       _gdk_dll_hinstance;
 HINSTANCE        _gdk_app_hmodule;
 
 int              _gdk_input_ignore_core;
+GdkWin32TabletInputAPI _gdk_win32_tablet_input_api;
 
 HKL              _gdk_input_locale;
 gboolean         _gdk_input_locale_is_ime = FALSE;
index 268a1ebac07762fb9b8fcfb9437531e12fc56af9..0ec15c62d9524706bf9e39db9141d577ef728fc7 100644 (file)
@@ -147,6 +147,11 @@ typedef enum
   GDK_DRAG_PROTO_OLE2,
 } GdkDragProtocol;
 
+typedef enum {
+  GDK_WIN32_TABLET_INPUT_API_NONE = 0,
+  GDK_WIN32_TABLET_INPUT_API_WINTAB
+} GdkWin32TabletInputAPI;
+
 GType _gdk_gc_win32_get_type (void);
 
 gulong _gdk_win32_get_next_tick (gulong suggested_tick);
@@ -267,6 +272,7 @@ extern HINSTANCE         _gdk_dll_hinstance;
 extern HINSTANCE         _gdk_app_hmodule;
 
 extern int               _gdk_input_ignore_core;
+extern GdkWin32TabletInputAPI _gdk_win32_tablet_input_api;
 
 /* These are thread specific, but GDK/win32 works OK only when invoked
  * from a single thread anyway.