[gtk: 7/19] Make room for other API's than Wintab




commit ad3995b1b96684e0c702284c5c1a382c8f843f24
Author: Luca Bacci <luca bacci982 gmail com>
Date:   Fri Jun 18 11:59:38 2021 +0200

    Make room for other API's than Wintab

 gdk/win32/gdkdevicemanager-win32.c | 44 ++++++++++++++++++++++++++++----------
 gdk/win32/gdkevents-win32.c        | 26 +++++++++++++---------
 gdk/win32/gdkglobals-win32.c       |  1 +
 gdk/win32/gdkprivate-win32.h       |  6 ++++++
 4 files changed, 56 insertions(+), 21 deletions(-)
---
diff --git a/gdk/win32/gdkdevicemanager-win32.c b/gdk/win32/gdkdevicemanager-win32.c
index e41b69d1df..19203ab8fe 100644
--- a/gdk/win32/gdkdevicemanager-win32.c
+++ b/gdk/win32/gdkdevicemanager-win32.c
@@ -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
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index c469a886a2..db4f7d1aa7 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -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;
diff --git a/gdk/win32/gdkglobals-win32.c b/gdk/win32/gdkglobals-win32.c
index accc3f5d11..9450830c66 100644
--- a/gdk/win32/gdkglobals-win32.c
+++ b/gdk/win32/gdkglobals-win32.c
@@ -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;
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index 268a1ebac0..0ec15c62d9 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]