Make room for other API's than Wintab

This commit is contained in:
Luca Bacci 2021-06-18 11:59:38 +02:00
parent 75cc0710ac
commit ad3995b1b9
No known key found for this signature in database
GPG Key ID: 8E3C8D989C98883D
4 changed files with 56 additions and 21 deletions

View File

@ -685,6 +685,8 @@ gdk_device_manager_win32_constructed (GObject *object)
GdkSeat *seat; GdkSeat *seat;
GdkDisplayManager *display_manager = NULL; GdkDisplayManager *display_manager = NULL;
GdkDisplay *default_display = 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 = GDK_DEVICE_MANAGER_WIN32 (object);
device_manager->core_pointer = device_manager->core_pointer =
@ -725,6 +727,25 @@ gdk_device_manager_win32_constructed (GObject *object)
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), device_manager->system_keyboard); gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), device_manager->system_keyboard);
g_object_unref (seat); g_object_unref (seat);
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;
}
if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
{
/* Only call Wintab init stuff after the default display /* Only call Wintab init stuff after the default display
* is globally known and accessible through the display manager * is globally known and accessible through the display manager
* singleton. Approach lifted from gtkmodules.c. * singleton. Approach lifted from gtkmodules.c.
@ -738,6 +759,7 @@ gdk_device_manager_win32_constructed (GObject *object)
G_CALLBACK (wintab_default_display_notify_cb), G_CALLBACK (wintab_default_display_notify_cb),
NULL); NULL);
} }
}
static void static void
gdk_device_manager_win32_class_init (GdkDeviceManagerWin32Class *klass) gdk_device_manager_win32_class_init (GdkDeviceManagerWin32Class *klass)

View File

@ -3056,6 +3056,8 @@ gdk_event_translate (MSG *msg,
{ {
gdk_synthesize_surface_state (window, 0, GDK_TOPLEVEL_STATE_FOCUSED); gdk_synthesize_surface_state (window, 0, GDK_TOPLEVEL_STATE_FOCUSED);
if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
{
/* Bring any tablet contexts to the top of the overlap order when /* Bring any tablet contexts to the top of the overlap order when
* one of our windows is activated. * one of our windows is activated.
* NOTE: It doesn't seem to work well if it is done in WM_ACTIVATEAPP * NOTE: It doesn't seem to work well if it is done in WM_ACTIVATEAPP
@ -3063,6 +3065,7 @@ gdk_event_translate (MSG *msg,
*/ */
_gdk_wintab_set_tablet_active (); _gdk_wintab_set_tablet_active ();
} }
}
break; break;
@ -3100,12 +3103,15 @@ gdk_event_translate (MSG *msg,
/* Fall through */ /* Fall through */
wintab: wintab:
if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINTAB)
{
event = gdk_wintab_make_event (display, msg, window); event = gdk_wintab_make_event (display, msg, window);
if (event) if (event)
{ {
_gdk_win32_append_event (event); _gdk_win32_append_event (event);
gdk_event_unref (event); gdk_event_unref (event);
} }
}
break; break;
} }

View File

@ -37,6 +37,7 @@ HINSTANCE _gdk_dll_hinstance;
HINSTANCE _gdk_app_hmodule; HINSTANCE _gdk_app_hmodule;
int _gdk_input_ignore_core; int _gdk_input_ignore_core;
GdkWin32TabletInputAPI _gdk_win32_tablet_input_api;
HKL _gdk_input_locale; HKL _gdk_input_locale;
gboolean _gdk_input_locale_is_ime = FALSE; gboolean _gdk_input_locale_is_ime = FALSE;

View File

@ -147,6 +147,11 @@ typedef enum
GDK_DRAG_PROTO_OLE2, GDK_DRAG_PROTO_OLE2,
} GdkDragProtocol; } GdkDragProtocol;
typedef enum {
GDK_WIN32_TABLET_INPUT_API_NONE = 0,
GDK_WIN32_TABLET_INPUT_API_WINTAB
} GdkWin32TabletInputAPI;
GType _gdk_gc_win32_get_type (void); GType _gdk_gc_win32_get_type (void);
gulong _gdk_win32_get_next_tick (gulong suggested_tick); gulong _gdk_win32_get_next_tick (gulong suggested_tick);
@ -267,6 +272,7 @@ extern HINSTANCE _gdk_dll_hinstance;
extern HINSTANCE _gdk_app_hmodule; extern HINSTANCE _gdk_app_hmodule;
extern int _gdk_input_ignore_core; 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 /* These are thread specific, but GDK/win32 works OK only when invoked
* from a single thread anyway. * from a single thread anyway.