Recent versions of Native Instruments Kontakt 7 introduced some additional HiDPI features. To do this, Kontakt calls 2 functions in `user32.dll` that Wine hasn't implemented yet: `GetWindowDpiHostingBehavior` and `SetThreadDpiHostingBehavior`. This patch adds stubs for these 2 functions and apparently that's enough for Kontakt.
This is my first contribution to Wine, I'm not 100% sure if everything is like it should be.
-- v2: user32: Add stubs for GetWindowDpiHostingBehavior and SetThreadDpiHostingBehavior
From: Paweł Ulita pawelulita@fastmail.com
This prevents Native Instruments Kontakt 7 from crashing on start-up. --- dlls/user32/sysparams.c | 9 +++++++++ dlls/user32/user32.spec | 2 ++ dlls/user32/win.c | 10 ++++++++++ include/windef.h | 6 ++++++ include/winuser.h | 2 ++ 5 files changed, 29 insertions(+)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 5ededfee62a..bc78c1fef88 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -746,6 +746,15 @@ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT return ULongToHandle( prev ); }
+/********************************************************************** + * SetThreadDpiHostingBehavior (USER32.@) + */ +DPI_HOSTING_BEHAVIOR WINAPI SetThreadDpiHostingBehavior( DPI_HOSTING_BEHAVIOR value ) +{ + FIXME("(%d): stub\n", value); + return DPI_HOSTING_BEHAVIOR_DEFAULT; +} + /*********************************************************************** * MonitorFromRect (USER32.@) */ diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 96e6e1a7d6b..9f9f03041b4 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -410,6 +410,7 @@ @ stdcall GetWindowDC(long) NtUserGetWindowDC @ stdcall GetWindowDisplayAffinity(long ptr) @ stdcall GetWindowDpiAwarenessContext(long) +@ stdcall GetWindowDpiHostingBehavior(long) @ stdcall GetWindowInfo(long ptr) @ stdcall GetWindowLongA(long long) @ stdcall -arch=win64 GetWindowLongPtrA(long long) @@ -719,6 +720,7 @@ @ stdcall SetTaskmanWindow (long) @ stdcall SetThreadDesktop(long) NtUserSetThreadDesktop @ stdcall SetThreadDpiAwarenessContext(ptr) +@ stdcall SetThreadDpiHostingBehavior(ptr) @ stdcall SetTimer(long long long ptr) @ stdcall SetUserObjectInformationA(long long ptr long) @ stdcall SetUserObjectInformationW(long long ptr long) NtUserSetObjectInformation diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 6459ddf9f28..b8c04047333 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -616,6 +616,16 @@ DPI_AWARENESS_CONTEXT WINAPI GetWindowDpiAwarenessContext( HWND hwnd ) }
+/*********************************************************************** + * GetWindowDpiHostingBehavior (USER32.@) + */ +DPI_HOSTING_BEHAVIOR WINAPI GetWindowDpiHostingBehavior( HWND hwnd ) +{ + FIXME("(%p): stub\n", hwnd); + return DPI_HOSTING_BEHAVIOR_DEFAULT; +} + + static LONG_PTR get_window_long_ptr( HWND hwnd, int offset, LONG_PTR ret, BOOL ansi ) { if (offset == DWLP_DLGPROC && NtUserGetDialogInfo( hwnd )) diff --git a/include/windef.h b/include/windef.h index b22e15c4dbf..78e4f56052c 100644 --- a/include/windef.h +++ b/include/windef.h @@ -439,4 +439,10 @@ typedef enum DPI_AWARENESS } #endif
+typedef enum { + DPI_HOSTING_BEHAVIOR_INVALID = -1, + DPI_HOSTING_BEHAVIOR_DEFAULT = 0, + DPI_HOSTING_BEHAVIOR_MIXED = 1 +} DPI_HOSTING_BEHAVIOR; + #endif /* _WINDEF_ */ diff --git a/include/winuser.h b/include/winuser.h index 73e7919aaea..ee0f05e1cb8 100644 --- a/include/winuser.h +++ b/include/winuser.h @@ -4296,6 +4296,7 @@ WINUSERAPI DWORD WINAPI GetWindowContextHelpId(HWND); WINUSERAPI HDC WINAPI GetWindowDC(HWND); WINUSERAPI BOOL WINAPI GetWindowDisplayAffinity(HWND,DWORD*); WINUSERAPI DPI_AWARENESS_CONTEXT WINAPI GetWindowDpiAwarenessContext(HWND); +WINUSERAPI DPI_HOSTING_BEHAVIOR WINAPI GetWindowDpiHostingBehavior(HWND); WINUSERAPI BOOL WINAPI GetWindowFeedbackSetting(HWND,FEEDBACK_TYPE,DWORD,UINT32*,void*); WINUSERAPI BOOL WINAPI GetWindowInfo(HWND, PWINDOWINFO); WINUSERAPI LONG WINAPI GetWindowLongA(HWND,INT); @@ -4608,6 +4609,7 @@ WINUSERAPI BOOL WINAPI SetSystemMenu(HWND,HMENU); WINUSERAPI UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,void*); WINUSERAPI BOOL WINAPI SetThreadDesktop(HDESK); WINUSERAPI DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT); +WINUSERAPI DPI_HOSTING_BEHAVIOR WINAPI SetThreadDpiHostingBehavior(DPI_HOSTING_BEHAVIOR); WINUSERAPI UINT_PTR WINAPI SetTimer(HWND,UINT_PTR,UINT,TIMERPROC); WINUSERAPI BOOL WINAPI SetUserObjectInformationA(HANDLE,INT,LPVOID,DWORD); WINUSERAPI BOOL WINAPI SetUserObjectInformationW(HANDLE,INT,LPVOID,DWORD);
I already created a MR for that a while ago: https://gitlab.winehq.org/wine/wine/-/merge_requests/4294
Fabian Maurer (@DarkShadow44) commented about dlls/user32/user32.spec:
@ stdcall SetTaskmanWindow (long) @ stdcall SetThreadDesktop(long) NtUserSetThreadDesktop @ stdcall SetThreadDpiAwarenessContext(ptr) +@ stdcall SetThreadDpiHostingBehavior(ptr)
Pretty sure this should be `long`
On Sun Nov 12 20:47:31 2023 +0000, Fabian Maurer wrote:
Pretty sure this should be `long`
You're right. It should be `long` here and `ptr` for `GetWindowDpiHostingBehavior()`.