[gtk: 18/19] Move the _gdk_win32_pointer_input_api global variable into GdkWin32Display
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 18/19] Move the _gdk_win32_pointer_input_api global variable into GdkWin32Display
- Date: Fri, 20 Aug 2021 11:31:18 +0000 (UTC)
commit c02bae9e0868d7bdb2d179cab087702fdc88b5b8
Author: Luca Bacci <luca bacci982 gmail com>
Date: Thu Aug 19 16:29:45 2021 +0200
Move the _gdk_win32_pointer_input_api global variable into GdkWin32Display
gdk/win32/gdkdevicemanager-win32.c | 51 +++++++++++++++++++++++---------------
gdk/win32/gdkdisplay-win32.h | 10 +++++++-
gdk/win32/gdkevents-win32.c | 20 +++++++--------
gdk/win32/gdkglobals-win32.c | 1 -
gdk/win32/gdkprivate-win32.h | 7 ------
gdk/win32/gdksurface-win32.c | 2 +-
6 files changed, 51 insertions(+), 40 deletions(-)
---
diff --git a/gdk/win32/gdkdevicemanager-win32.c b/gdk/win32/gdkdevicemanager-win32.c
index 4ab0cc705d..ad850a8a24 100644
--- a/gdk/win32/gdkdevicemanager-win32.c
+++ b/gdk/win32/gdkdevicemanager-win32.c
@@ -31,6 +31,7 @@
#include "gdkdevice-wintab.h"
#include "gdkinput-winpointer.h"
#include "gdkdisplayprivate.h"
+#include "gdkdisplay-win32.h"
#include "gdkseatdefaultprivate.h"
#define WINTAB32_DLL "Wintab32.dll"
@@ -682,12 +683,13 @@ wintab_default_display_notify_cb (GdkDisplayManager *display_manager)
static void
gdk_device_manager_win32_constructed (GObject *object)
{
+ GdkWin32Display *display_win32;
GdkDeviceManagerWin32 *device_manager;
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;
+ const char *api_preference = NULL;
+ gboolean have_api_preference = TRUE;
+
+ display_win32 = GDK_WIN32_DISPLAY (_gdk_display);
device_manager = GDK_DEVICE_MANAGER_WIN32 (object);
device_manager->core_pointer =
@@ -730,35 +732,44 @@ gdk_device_manager_win32_constructed (GObject *object)
_gdk_device_manager = device_manager;
- tablet_input_api_user_preference = g_getenv ("GDK_WIN32_TABLET_INPUT_API");
- if (g_strcmp0 (tablet_input_api_user_preference, "none") == 0)
+ api_preference = g_getenv ("GDK_WIN32_TABLET_INPUT_API");
+ if (g_strcmp0 (api_preference, "none") == 0)
{
- have_tablet_input_api_preference = TRUE;
- _gdk_win32_tablet_input_api = GDK_WIN32_TABLET_INPUT_API_NONE;
+ display_win32->tablet_input_api = GDK_WIN32_TABLET_INPUT_API_NONE;
}
- else if (g_strcmp0 (tablet_input_api_user_preference, "wintab") == 0)
+ else if (g_strcmp0 (api_preference, "wintab") == 0)
{
- have_tablet_input_api_preference = TRUE;
- _gdk_win32_tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINTAB;
+ display_win32->tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINTAB;
}
- else if (g_strcmp0 (tablet_input_api_user_preference, "winpointer") == 0)
+ else if (g_strcmp0 (api_preference, "winpointer") == 0)
{
- have_tablet_input_api_preference = TRUE;
- _gdk_win32_tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINPOINTER;
+ display_win32->tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINPOINTER;
}
else
{
- have_tablet_input_api_preference = FALSE;
- _gdk_win32_tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINPOINTER;
+ /* No user preference, default to WinPointer. If unsuccessful,
+ * try to initialize other API's in sequence until one succeeds.
+ */
+ display_win32->tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINPOINTER;
+ have_api_preference = FALSE;
}
- if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
+ if (display_win32->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
{
- if (!gdk_winpointer_initialize () && !have_tablet_input_api_preference)
- _gdk_win32_tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINTAB;
+ gboolean init_successful = gdk_winpointer_initialize ();
+
+ if (!init_successful && !have_api_preference)
+ {
+ /* Try Wintab */
+ display_win32->tablet_input_api = GDK_WIN32_TABLET_INPUT_API_WINTAB;
+ }
}
- if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
+
+ if (display_win32->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
{
+ GdkDisplayManager *display_manager = NULL;
+ GdkDisplay *default_display = NULL;
+
/* Only call Wintab init stuff after the default display
* is globally known and accessible through the display manager
* singleton. Approach lifted from gtkmodules.c.
diff --git a/gdk/win32/gdkdisplay-win32.h b/gdk/win32/gdkdisplay-win32.h
index 221987c537..f9885e72e2 100644
--- a/gdk/win32/gdkdisplay-win32.h
+++ b/gdk/win32/gdkdisplay-win32.h
@@ -99,6 +99,12 @@ typedef struct _GdkWin32User32DPIFuncs
funcADACE areDACEqual;
} GdkWin32User32DPIFuncs;
+typedef enum {
+ GDK_WIN32_TABLET_INPUT_API_NONE,
+ GDK_WIN32_TABLET_INPUT_API_WINTAB,
+ GDK_WIN32_TABLET_INPUT_API_WINPOINTER
+} GdkWin32TabletInputAPI;
+
/* Detect running architecture */
typedef BOOL (WINAPI *funcIsWow64Process2) (HANDLE, USHORT *, USHORT *);
typedef struct _GdkWin32KernelCPUFuncs
@@ -159,7 +165,9 @@ struct _GdkWin32Display
GdkWin32ShcoreFuncs shcore_funcs;
GdkWin32User32DPIFuncs user32_dpi_funcs;
-
+
+ GdkWin32TabletInputAPI tablet_input_api;
+
/* Cursor Items (GdkCursor->GdkWin32HCursor) */
GHashTable *cursors;
/* The cursor that is used by current grab (if any) */
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 7b00f3e97d..a705ee7e2a 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -2345,7 +2345,7 @@ gdk_event_translate (MSG *msg,
* https://devblogs.microsoft.com/oldnewthing/20031001-00/?p=42343
*
*/
- if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER &&
+ if (win32_display->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER &&
( (msg->time - last_digitizer_time) < 200 ||
-(msg->time - last_digitizer_time) < 200 ))
break;
@@ -2496,7 +2496,7 @@ gdk_event_translate (MSG *msg,
break;
case WM_POINTERDOWN:
- if (_gdk_win32_tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
+ if (win32_display->tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
gdk_winpointer_should_forward_message (msg))
{
return_val = FALSE;
@@ -2526,7 +2526,7 @@ gdk_event_translate (MSG *msg,
break;
case WM_POINTERUP:
- if (_gdk_win32_tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
+ if (win32_display->tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
gdk_winpointer_should_forward_message (msg))
{
return_val = FALSE;
@@ -2559,7 +2559,7 @@ gdk_event_translate (MSG *msg,
break;
case WM_POINTERUPDATE:
- if (_gdk_win32_tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
+ if (win32_display->tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
gdk_winpointer_should_forward_message (msg))
{
return_val = FALSE;
@@ -2598,7 +2598,7 @@ gdk_event_translate (MSG *msg,
break;
case WM_NCPOINTERUPDATE:
- if (_gdk_win32_tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
+ if (win32_display->tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
gdk_winpointer_should_forward_message (msg))
{
return_val = FALSE;
@@ -2633,7 +2633,7 @@ gdk_event_translate (MSG *msg,
break;
case WM_POINTERENTER:
- if (_gdk_win32_tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
+ if (win32_display->tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
gdk_winpointer_should_forward_message (msg))
{
return_val = FALSE;
@@ -2663,7 +2663,7 @@ gdk_event_translate (MSG *msg,
break;
case WM_POINTERLEAVE:
- if (_gdk_win32_tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
+ if (win32_display->tablet_input_api != GDK_WIN32_TABLET_INPUT_API_WINPOINTER ||
gdk_winpointer_should_forward_message (msg))
{
return_val = FALSE;
@@ -3219,7 +3219,7 @@ gdk_event_translate (MSG *msg,
break;
case WM_DESTROY:
- if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
+ if (win32_display->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
gdk_winpointer_finalize_surface (window);
return_val = FALSE;
@@ -3305,7 +3305,7 @@ gdk_event_translate (MSG *msg,
{
gdk_synthesize_surface_state (window, 0, GDK_TOPLEVEL_STATE_FOCUSED);
- if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
+ if (win32_display->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.
@@ -3362,7 +3362,7 @@ gdk_event_translate (MSG *msg,
/* Fall through */
wintab:
- if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
+ if (win32_display->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
{
event = gdk_wintab_make_event (display, msg, window);
if (event)
diff --git a/gdk/win32/gdkglobals-win32.c b/gdk/win32/gdkglobals-win32.c
index 9450830c66..accc3f5d11 100644
--- a/gdk/win32/gdkglobals-win32.c
+++ b/gdk/win32/gdkglobals-win32.c
@@ -37,7 +37,6 @@ 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 67d99a4532..bd27cb5ef1 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -147,12 +147,6 @@ typedef enum
GDK_DRAG_PROTO_OLE2,
} GdkDragProtocol;
-typedef enum {
- GDK_WIN32_TABLET_INPUT_API_NONE = 0,
- GDK_WIN32_TABLET_INPUT_API_WINTAB,
- GDK_WIN32_TABLET_INPUT_API_WINPOINTER
-} GdkWin32TabletInputAPI;
-
GType _gdk_gc_win32_get_type (void);
gulong _gdk_win32_get_next_tick (gulong suggested_tick);
@@ -277,7 +271,6 @@ 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.
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index ee9c3e3477..89a614eac7 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -646,7 +646,7 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
return NULL;
}
- if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
+ if (display_win32->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
gdk_winpointer_initialize_surface (surface);
_gdk_win32_surface_enable_transparency (surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]