[PATCH 0/3] MR10671: wintab32: Create the internal window on demand and make it message-only.
Split from !10627. If the window isn't message-only it comes back from EnumWindows, and since it responds 0 to WM_QUERYENDSESSION, it prevented macdrv from quitting via Cocoa. I don't see a reason why it can't be message-only. Also it seems risky to register a class and create a window from PROCESS_ATTACH; see !9822. Adding @bshanks since he looked at !10627. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10671
From: Tim Clem <tclem@codeweavers.com> --- dlls/wintab32/wintab32.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dlls/wintab32/wintab32.c b/dlls/wintab32/wintab32.c index 15040b9ca9c..2939673c9fe 100644 --- a/dlls/wintab32/wintab32.c +++ b/dlls/wintab32/wintab32.c @@ -73,8 +73,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved) TRACE("Initialization\n"); DisableThreadLibraryCalls(hInstDLL); TABLET_Register(); - hwndDefault = CreateWindowW(L"WineTabletClass", L"Tablet", - WS_POPUPWINDOW,0,0,0,0,0,0,hInstDLL,0); + hwndDefault = CreateWindowW(L"WineTabletClass", L"Tablet", 0, + 0, 0, 0, 0, HWND_MESSAGE, 0, hInstDLL, 0); if (!hwndDefault) return FALSE; break; @@ -101,9 +101,6 @@ static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, switch(uMsg) { - case WM_NCCREATE: - return TRUE; - case WT_PACKET: { WTPACKET packet; @@ -116,7 +113,7 @@ static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, (WPARAM)packet.pkSerialNumber, (LPARAM)handler->handle, FALSE); } - break; + return 0; } case WT_PROXIMITY: { @@ -129,8 +126,9 @@ static LRESULT WINAPI TABLET_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, TABLET_PostTabletMessage(handler, WT_PROXIMITY, (WPARAM)handler->handle, lParam, TRUE); } - break; + return 0; } } - return 0; + + return DefWindowProcW(hwnd, uMsg, wParam, lParam); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10671
From: Tim Clem <tclem@codeweavers.com> --- dlls/wintab32/wintab32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/wintab32/wintab32.c b/dlls/wintab32/wintab32.c index 2939673c9fe..1bb8ccdf800 100644 --- a/dlls/wintab32/wintab32.c +++ b/dlls/wintab32/wintab32.c @@ -33,6 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wintab32); +static HINSTANCE wintab_instance; HWND hwndDefault = NULL; static CRITICAL_SECTION_DEBUG csTablet_debug = { @@ -51,6 +52,7 @@ static VOID TABLET_Register(void) ZeroMemory(&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS; wndClass.lpfnWndProc = TABLET_WindowProc; + wndClass.hInstance = wintab_instance; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hCursor = NULL; @@ -71,6 +73,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved) { case DLL_PROCESS_ATTACH: TRACE("Initialization\n"); + wintab_instance = hInstDLL; DisableThreadLibraryCalls(hInstDLL); TABLET_Register(); hwndDefault = CreateWindowW(L"WineTabletClass", L"Tablet", 0, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10671
From: Tim Clem <tclem@codeweavers.com> Rather than from PROCESS_ATTACH, which is a risky time to do it. --- dlls/wintab32/context.c | 8 +++++--- dlls/wintab32/wintab32.c | 29 ++++++++++++++++++++++------- dlls/wintab32/wintab_internal.h | 2 +- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/dlls/wintab32/context.c b/dlls/wintab32/context.c index 4e19a93cc37..3d79d136f85 100644 --- a/dlls/wintab32/context.c +++ b/dlls/wintab32/context.c @@ -149,14 +149,16 @@ static inline BOOL LoadTablet(void) if (loaded == TI_START) { - if (NtUserMessageCall(hwndDefault, NtUserWintabInit, 0, 0, NULL, NtUserWintabDriverCall, FALSE)) + HWND hwndInternal = TABLET_GetInternalWindow(); + if (hwndInternal && + NtUserMessageCall(hwndInternal, NtUserWintabInit, 0, 0, NULL, NtUserWintabDriverCall, FALSE)) { - TRACE("Initialized the tablet to hwnd %p\n", hwndDefault); + TRACE("Initialized the tablet to hwnd %p\n", hwndInternal); loaded = TI_OK; } else { - TRACE("Failed to initialize the tablet to hwnd %p\n", hwndDefault); + TRACE("Failed to initialize the tablet to hwnd %p\n", hwndInternal); loaded = TI_FAIL; } } diff --git a/dlls/wintab32/wintab32.c b/dlls/wintab32/wintab32.c index 1bb8ccdf800..1f1e720c721 100644 --- a/dlls/wintab32/wintab32.c +++ b/dlls/wintab32/wintab32.c @@ -34,7 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wintab32); static HINSTANCE wintab_instance; -HWND hwndDefault = NULL; +static HWND hwndTablet = NULL; static CRITICAL_SECTION_DEBUG csTablet_debug = { 0, 0, &csTablet, @@ -66,6 +66,26 @@ static VOID TABLET_Unregister(void) UnregisterClassW(L"WineTabletClass", NULL); } +static BOOL WINAPI create_internal_window(INIT_ONCE *once, void *param, void **context) +{ + TABLET_Register(); + hwndTablet = CreateWindowW(L"WineTabletClass", L"Tablet", 0, + 0, 0, 0, 0, HWND_MESSAGE, 0, wintab_instance, 0); + + if (!hwndTablet) + ERR("error creating internal window: %lu\n", GetLastError()); + + return TRUE; +} + +HWND TABLET_GetInternalWindow(void) +{ + static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; + InitOnceExecuteOnce(&init_once, create_internal_window, NULL, NULL); + + return hwndTablet; +} + BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved) { TRACE("%p, %lx, %p\n",hInstDLL,fdwReason,lpReserved); @@ -75,16 +95,11 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved) TRACE("Initialization\n"); wintab_instance = hInstDLL; DisableThreadLibraryCalls(hInstDLL); - TABLET_Register(); - hwndDefault = CreateWindowW(L"WineTabletClass", L"Tablet", 0, - 0, 0, 0, 0, HWND_MESSAGE, 0, hInstDLL, 0); - if (!hwndDefault) - return FALSE; break; case DLL_PROCESS_DETACH: if (lpReserved) break; TRACE("Detaching\n"); - if (hwndDefault) DestroyWindow(hwndDefault); + if (hwndTablet) DestroyWindow(hwndTablet); TABLET_Unregister(); DeleteCriticalSection(&csTablet); break; diff --git a/dlls/wintab32/wintab_internal.h b/dlls/wintab32/wintab_internal.h index b4b76c69a98..e230f0c1389 100644 --- a/dlls/wintab32/wintab_internal.h +++ b/dlls/wintab32/wintab_internal.h @@ -146,11 +146,11 @@ typedef struct tagOPENCONTEXT struct tagOPENCONTEXT *next; } OPENCONTEXT, *LPOPENCONTEXT; +HWND TABLET_GetInternalWindow(void); int TABLET_PostTabletMessage(LPOPENCONTEXT newcontext, UINT msg, WPARAM wParam, LPARAM lParam, BOOL send_always); LPOPENCONTEXT AddPacketToContextQueue(LPWTPACKET packet, HWND hwnd); -extern HWND hwndDefault; extern CRITICAL_SECTION csTablet; #endif /* __WINE_WINTAB_INTERNAL_H */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10671
This merge request was approved by Brendan Shanks. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10671
participants (3)
-
Brendan Shanks (@bshanks) -
Tim Clem -
Tim Clem (@tclem)