From ad73e17418f55f6e80efa24eeb455bbc0ae0491e Mon Sep 17 00:00:00 2001 From: "Carl J. Bialorucki" Date: Tue, 4 Jun 2024 10:19:32 -0600 Subject: [PATCH] [USER32] Introduce user32_vista and stubplement GetDpiForWindow() (#6208) Add user32_vista.dll to introduce new NT6+ User32 features without changing the existing User32.dll when compiled as NT5.x. Also implements a stub for GetDpiForWindow(). The GetDpiForWindow() function will be required to Wine-sync common controls to modern Wine versions. Changes: Expose GetDpiForWindow() function and USER_DEFAULT_SCREEN_DPI to appropriate versions in winuser.h Introduce a basic user32_vista library that can be expanded as needed. --- sdk/include/psdk/winuser.h | 9 +++++ win32ss/CMakeLists.txt | 1 + win32ss/user/user32/CMakeLists.txt | 2 +- win32ss/user/user32/user32.spec | 2 + win32ss/user/user32_vista/CMakeLists.txt | 25 ++++++++++++ win32ss/user/user32_vista/dpi.c | 44 +++++++++++++++++++++ win32ss/user/user32_vista/user32_vista.rc | 5 +++ win32ss/user/user32_vista/user32_vista.spec | 2 + 8 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 win32ss/user/user32_vista/CMakeLists.txt create mode 100644 win32ss/user/user32_vista/dpi.c create mode 100644 win32ss/user/user32_vista/user32_vista.rc create mode 100644 win32ss/user/user32_vista/user32_vista.spec diff --git a/sdk/include/psdk/winuser.h b/sdk/include/psdk/winuser.h index 62253ad597b..9d95a817163 100644 --- a/sdk/include/psdk/winuser.h +++ b/sdk/include/psdk/winuser.h @@ -4924,6 +4924,15 @@ BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO); BOOL WINAPI GetMonitorInfoA(_In_ HMONITOR, _Inout_ LPMONITORINFO); BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO); +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#define USER_DEFAULT_SCREEN_DPI 96 +#endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */ + +#if (_WIN32_WINNT >= 0x0605) /* Windows 10 pre-Threshold */ +UINT WINAPI GetDpiForSystem(VOID); +UINT WINAPI GetDpiForWindow(_In_ HWND hwnd); +#endif /* _WIN32_WINNT >= 0x0605 */ + UINT WINAPI GetWindowModuleFileNameA( diff --git a/win32ss/CMakeLists.txt b/win32ss/CMakeLists.txt index 4f6f7ce4e4d..afe4b35627b 100644 --- a/win32ss/CMakeLists.txt +++ b/win32ss/CMakeLists.txt @@ -19,6 +19,7 @@ add_subdirectory(gdi/gdi32_vista) add_subdirectory(printing) add_subdirectory(reactx) add_subdirectory(user/user32) +add_subdirectory(user/user32_vista) add_subdirectory(user/winsrv) spec2def(win32k.sys win32k.spec ADD_IMPORTLIB) diff --git a/win32ss/user/user32/CMakeLists.txt b/win32ss/user/user32/CMakeLists.txt index 8c938015115..66bbe21f9b8 100644 --- a/win32ss/user/user32/CMakeLists.txt +++ b/win32ss/user/user32/CMakeLists.txt @@ -80,7 +80,7 @@ add_library(user32 MODULE ${CMAKE_CURRENT_BINARY_DIR}/user32.def) set_module_type(user32 win32dll UNICODE ENTRYPOINT DllMain 12) -target_link_libraries(user32 user32_wsprintf wine win32ksys ${PSEH_LIB}) +target_link_libraries(user32 user32_vista_static user32_wsprintf wine win32ksys ${PSEH_LIB}) add_dependencies(user32 asm) if(MSVC AND (ARCH STREQUAL "i386")) diff --git a/win32ss/user/user32/user32.spec b/win32ss/user/user32/user32.spec index a77cfeaf29e..a5b4fd5b4d2 100644 --- a/win32ss/user/user32/user32.spec +++ b/win32ss/user/user32/user32.spec @@ -282,6 +282,8 @@ 279 stdcall GetDlgItemTextA(long long ptr long) 280 stdcall GetDlgItemTextW(long long ptr long) 281 stdcall GetDoubleClickTime() NtUserGetDoubleClickTime +@ stdcall -version=0xA00+ GetDpiForSystem() +@ stdcall -version=0xA00+ GetDpiForWindow(ptr) 282 stdcall GetFocus() 283 stdcall GetForegroundWindow() NtUserGetForegroundWindow 284 stdcall GetGUIThreadInfo(long ptr) NtUserGetGUIThreadInfo diff --git a/win32ss/user/user32_vista/CMakeLists.txt b/win32ss/user/user32_vista/CMakeLists.txt new file mode 100644 index 00000000000..4b05f471946 --- /dev/null +++ b/win32ss/user/user32_vista/CMakeLists.txt @@ -0,0 +1,25 @@ + +spec2def(user32_vista.dll user32_vista.spec ADD_IMPORTLIB) + +include_directories( + include + ${REACTOS_SOURCE_DIR}/win32ss/include) + +list(APPEND SOURCE + dpi.c) + +add_library(user32_vista_static + ${SOURCE}) +target_link_libraries(user32_vista_static win32ksys) +add_dependencies(user32_vista_static psdk) + +add_library(user32_vista MODULE + ${SOURCE} + user32_vista.rc + ${CMAKE_CURRENT_BINARY_DIR}/user32_vista.def) + +set_module_type(user32_vista win32dll UNICODE ENTRYPOINT 0) +add_importlibs(user32_vista user32 gdi32 ntdll) +target_link_libraries(user32_vista user32_vista_static win32ksys) +add_dependencies(user32_vista psdk) +add_cd_file(TARGET user32_vista DESTINATION reactos/system32 FOR all) diff --git a/win32ss/user/user32_vista/dpi.c b/win32ss/user/user32_vista/dpi.c new file mode 100644 index 00000000000..08d73e4e4e5 --- /dev/null +++ b/win32ss/user/user32_vista/dpi.c @@ -0,0 +1,44 @@ +/* + * PROJECT: ReactOS Kernel - Vista+ APIs + * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) + * PURPOSE: DPI functions for user32 and user32_vista. + * COPYRIGHT: Copyright 2024 Carl Bialorucki + */ + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H +#include +#include +#include + +#define NDEBUG +#include + +/* + * @stub + */ +UINT +WINAPI +GetDpiForSystem(VOID) +{ + HDC hDC; + UINT Dpi; + hDC = GetDC(NULL); + Dpi = GetDeviceCaps(hDC, LOGPIXELSY); + ReleaseDC(NULL, hDC); + return Dpi; +} + +/* + * @stub + */ +UINT +WINAPI +GetDpiForWindow( + _In_ HWND hWnd) +{ + UNIMPLEMENTED_ONCE; + UNREFERENCED_PARAMETER(hWnd); + return GetDpiForSystem(); +} diff --git a/win32ss/user/user32_vista/user32_vista.rc b/win32ss/user/user32_vista/user32_vista.rc new file mode 100644 index 00000000000..543d9e4a3a0 --- /dev/null +++ b/win32ss/user/user32_vista/user32_vista.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "User32 Extensions DLL" +#define REACTOS_STR_INTERNAL_NAME "user32_vista" +#define REACTOS_STR_ORIGINAL_FILENAME "user32_vista.dll" +#include diff --git a/win32ss/user/user32_vista/user32_vista.spec b/win32ss/user/user32_vista/user32_vista.spec new file mode 100644 index 00000000000..eaebebabc4e --- /dev/null +++ b/win32ss/user/user32_vista/user32_vista.spec @@ -0,0 +1,2 @@ +@ stdcall GetDpiForSystem() +@ stdcall GetDpiForWindow(ptr)