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;
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

View 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;

View 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;

View 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.