[PATCH 0/6] MR11166: win32u: Implement GetPointerDeviceRects for INVALID_HANDLE_VALUE
Supersedes https://gitlab.winehq.org/wine/wine/-/merge_requests/11163 with more tests and some fixes. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11166
From: "Anna (navi) Figueiredo Gomes" <navi@vlhl.dev> --- dlls/win32u/input.c | 10 ++++++++++ dlls/win32u/main.c | 5 +++++ dlls/win32u/win32syscalls.h | 5 ++--- dlls/win32u/win32u.spec | 2 +- dlls/wow64win/user.c | 8 ++++++++ include/ntuser.h | 1 + 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 733eb604fdc..10c563d197a 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -2876,3 +2876,13 @@ BOOL WINAPI NtUserInitializeTouchInjection( UINT max_count, UINT mode ) FIXME( "max_count %u, mode %#x stub!\n", max_count, mode ); return TRUE; } + +/********************************************************************** + * NtUserGetPointerType (win32u.@) + */ +BOOL WINAPI NtUserGetPointerType( UINT32 id, POINTER_INPUT_TYPE *type ) +{ + FIXME( "id %u, type %p stub!\n", id, type ); + RtlSetLastWin32Error( ERROR_CALL_NOT_IMPLEMENTED ); + return FALSE; +} diff --git a/dlls/win32u/main.c b/dlls/win32u/main.c index edb1d98b3f0..69f36a815a1 100644 --- a/dlls/win32u/main.c +++ b/dlls/win32u/main.c @@ -1748,6 +1748,11 @@ BOOL SYSCALL_API NtUserGetPointerInfoList( UINT32 id, POINTER_INPUT_TYPE type, U SYSCALL_FUNC( NtUserGetPointerInfoList ); } +BOOL SYSCALL_API NtUserGetPointerType( UINT32 id, POINTER_INPUT_TYPE *type ) +{ + SYSCALL_FUNC( NtUserGetPointerType ); +} + INT SYSCALL_API NtUserGetPriorityClipboardFormat( UINT *list, INT count ) { SYSCALL_FUNC( NtUserGetPriorityClipboardFormat ); diff --git a/dlls/win32u/win32syscalls.h b/dlls/win32u/win32syscalls.h index 3e631c74da1..66043201b29 100644 --- a/dlls/win32u/win32syscalls.h +++ b/dlls/win32u/win32syscalls.h @@ -1074,7 +1074,7 @@ SYSCALL_ENTRY( 0x142e, NtUserGetPointerInfoList, 32 ) \ SYSCALL_ENTRY( 0x142f, NtUserGetPointerInputTransform, 0 ) \ SYSCALL_ENTRY( 0x1430, NtUserGetPointerProprietaryId, 0 ) \ - SYSCALL_ENTRY( 0x1431, NtUserGetPointerType, 0 ) \ + SYSCALL_ENTRY( 0x1431, NtUserGetPointerType, 8 ) \ SYSCALL_ENTRY( 0x1432, NtUserGetPrecisionTouchPadConfiguration, 0 ) \ SYSCALL_ENTRY( 0x1433, NtUserGetPriorityClipboardFormat, 8 ) \ SYSCALL_ENTRY( 0x1434, NtUserGetProcessDefaultLayout, 4 ) \ @@ -2616,7 +2616,7 @@ SYSCALL_ENTRY( 0x142e, NtUserGetPointerInfoList, 64 ) \ SYSCALL_ENTRY( 0x142f, NtUserGetPointerInputTransform, 0 ) \ SYSCALL_ENTRY( 0x1430, NtUserGetPointerProprietaryId, 0 ) \ - SYSCALL_ENTRY( 0x1431, NtUserGetPointerType, 0 ) \ + SYSCALL_ENTRY( 0x1431, NtUserGetPointerType, 16 ) \ SYSCALL_ENTRY( 0x1432, NtUserGetPrecisionTouchPadConfiguration, 0 ) \ SYSCALL_ENTRY( 0x1433, NtUserGetPriorityClipboardFormat, 16 ) \ SYSCALL_ENTRY( 0x1434, NtUserGetProcessDefaultLayout, 8 ) \ @@ -3836,7 +3836,6 @@ SYSCALL_STUB( NtUserGetPointerFrameTimes ) \ SYSCALL_STUB( NtUserGetPointerInputTransform ) \ SYSCALL_STUB( NtUserGetPointerProprietaryId ) \ - SYSCALL_STUB( NtUserGetPointerType ) \ SYSCALL_STUB( NtUserGetPrecisionTouchPadConfiguration ) \ SYSCALL_STUB( NtUserGetProcessUIContextInformation ) \ SYSCALL_STUB( NtUserGetProp2 ) \ diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index a58fda6af9c..05ddbd85478 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1072,7 +1072,7 @@ @ stdcall -syscall NtUserGetPointerInfoList(long long long long long ptr ptr ptr) @ stub -syscall NtUserGetPointerInputTransform @ stub -syscall NtUserGetPointerProprietaryId -@ stub -syscall NtUserGetPointerType +@ stdcall -syscall NtUserGetPointerType(long ptr) @ stub -syscall NtUserGetPrecisionTouchPadConfiguration @ stdcall -syscall NtUserGetPriorityClipboardFormat(ptr long) @ stdcall -syscall NtUserGetProcessDefaultLayout(ptr) diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 61c2da3e228..a07966c2ae4 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -2834,6 +2834,14 @@ NTSTATUS WINAPI wow64_NtUserGetPointerInfoList( UINT *args ) return NtUserGetPointerInfoList( id, type, unk0, unk1, size, entry_count, pointer_count, pointer_info ); } +NTSTATUS WINAPI wow64_NtUserGetPointerType( UINT *args ) +{ + UINT id = get_ulong( &args ); + POINTER_INPUT_TYPE *type = get_ptr( &args ); + + return NtUserGetPointerType( id, type ); +} + NTSTATUS WINAPI wow64_NtUserGetPriorityClipboardFormat( UINT *args ) { UINT *list = get_ptr( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index 2bbf77a4cf1..a5aeb28123e 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -881,6 +881,7 @@ W32KAPI BOOL WINAPI NtUserGetObjectInformation( HANDLE handle, INT index, voi W32KAPI HWND WINAPI NtUserGetOpenClipboardWindow(void); W32KAPI BOOL WINAPI NtUserGetPointerInfoList( UINT32 id, POINTER_INPUT_TYPE type, UINT_PTR, UINT_PTR, SIZE_T size, UINT32 *entry_count, UINT32 *pointer_count, void *pointer_info ); +W32KAPI BOOL WINAPI NtUserGetPointerType( UINT32 id, POINTER_INPUT_TYPE *type ); W32KAPI INT WINAPI NtUserGetPriorityClipboardFormat( UINT *list, INT count ); W32KAPI BOOL WINAPI NtUserGetProcessDefaultLayout( ULONG *layout ); W32KAPI ULONG WINAPI NtUserGetProcessDpiAwarenessContext( HANDLE process ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11166
From: "Anna (navi) Figueiredo Gomes" <navi@vlhl.dev> --- dlls/user32/input.c | 8 -------- dlls/user32/user32.spec | 2 +- dlls/win32u/input.c | 10 ++++++++++ dlls/win32u/main.c | 5 +++++ dlls/win32u/win32syscalls.h | 5 ++--- dlls/win32u/win32u.spec | 2 +- dlls/wow64win/user.c | 9 +++++++++ include/ntuser.h | 1 + 8 files changed, 29 insertions(+), 13 deletions(-) diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 48b38166b75..623fab14d11 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -750,14 +750,6 @@ BOOL WINAPI GetPointerDeviceProperties( HANDLE device, UINT32 *count, return FALSE; } -BOOL WINAPI GetPointerDeviceRects( HANDLE device, RECT *device_rect, RECT *display_rect ) -{ - FIXME( "device %p, device_rect %p, display_rect %p stub!\n", - device, device_rect, display_rect ); - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); - return FALSE; -} - BOOL WINAPI GetPointerPenInfo( UINT32 id, POINTER_PEN_INFO *info ) { FIXME( "id %u, info %p stub!\n", id, info ); diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index fe41f9cb2e7..93ced8d8f3d 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -630,7 +630,7 @@ # @ stub GetPointerDeviceInputSpace # @ stub GetPointerDeviceOrientation @ stdcall GetPointerDeviceProperties(ptr ptr ptr) -@ stdcall GetPointerDeviceRects(ptr ptr ptr) +@ stdcall GetPointerDeviceRects(ptr ptr ptr) NtUserGetPointerDeviceRects @ stdcall GetPointerDevices(ptr ptr) # @ stub GetPointerFrameInfo # @ stub GetPointerFrameInfoHistory diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 10c563d197a..41d871958f6 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -2886,3 +2886,13 @@ BOOL WINAPI NtUserGetPointerType( UINT32 id, POINTER_INPUT_TYPE *type ) RtlSetLastWin32Error( ERROR_CALL_NOT_IMPLEMENTED ); return FALSE; } + +/********************************************************************** + * NtUserGetPointerDeviceRects (win32u.@) + */ +BOOL WINAPI NtUserGetPointerDeviceRects( HANDLE handle, RECT *device_rect, RECT *display_rect ) +{ + FIXME( "handle %p, device_rect %p, display_rect %p stub!\n", handle, device_rect, display_rect ); + RtlSetLastWin32Error( ERROR_CALL_NOT_IMPLEMENTED ); + return FALSE; +} diff --git a/dlls/win32u/main.c b/dlls/win32u/main.c index 69f36a815a1..22e5368b132 100644 --- a/dlls/win32u/main.c +++ b/dlls/win32u/main.c @@ -1753,6 +1753,11 @@ BOOL SYSCALL_API NtUserGetPointerType( UINT32 id, POINTER_INPUT_TYPE *type ) SYSCALL_FUNC( NtUserGetPointerType ); } +BOOL SYSCALL_API NtUserGetPointerDeviceRects( HANDLE handle, RECT *device_rect, RECT *display_rect ) +{ + SYSCALL_FUNC( NtUserGetPointerDeviceRects ); +} + INT SYSCALL_API NtUserGetPriorityClipboardFormat( UINT *list, INT count ) { SYSCALL_FUNC( NtUserGetPriorityClipboardFormat ); diff --git a/dlls/win32u/win32syscalls.h b/dlls/win32u/win32syscalls.h index 66043201b29..132ac47836b 100644 --- a/dlls/win32u/win32syscalls.h +++ b/dlls/win32u/win32syscalls.h @@ -1068,7 +1068,7 @@ SYSCALL_ENTRY( 0x1428, NtUserGetPointerDeviceInputSpace, 0 ) \ SYSCALL_ENTRY( 0x1429, NtUserGetPointerDeviceOrientation, 0 ) \ SYSCALL_ENTRY( 0x142a, NtUserGetPointerDeviceProperties, 0 ) \ - SYSCALL_ENTRY( 0x142b, NtUserGetPointerDeviceRects, 0 ) \ + SYSCALL_ENTRY( 0x142b, NtUserGetPointerDeviceRects, 12 ) \ SYSCALL_ENTRY( 0x142c, NtUserGetPointerDevices, 0 ) \ SYSCALL_ENTRY( 0x142d, NtUserGetPointerFrameTimes, 0 ) \ SYSCALL_ENTRY( 0x142e, NtUserGetPointerInfoList, 32 ) \ @@ -2610,7 +2610,7 @@ SYSCALL_ENTRY( 0x1428, NtUserGetPointerDeviceInputSpace, 0 ) \ SYSCALL_ENTRY( 0x1429, NtUserGetPointerDeviceOrientation, 0 ) \ SYSCALL_ENTRY( 0x142a, NtUserGetPointerDeviceProperties, 0 ) \ - SYSCALL_ENTRY( 0x142b, NtUserGetPointerDeviceRects, 0 ) \ + SYSCALL_ENTRY( 0x142b, NtUserGetPointerDeviceRects, 24 ) \ SYSCALL_ENTRY( 0x142c, NtUserGetPointerDevices, 0 ) \ SYSCALL_ENTRY( 0x142d, NtUserGetPointerFrameTimes, 0 ) \ SYSCALL_ENTRY( 0x142e, NtUserGetPointerInfoList, 64 ) \ @@ -3831,7 +3831,6 @@ SYSCALL_STUB( NtUserGetPointerDeviceInputSpace ) \ SYSCALL_STUB( NtUserGetPointerDeviceOrientation ) \ SYSCALL_STUB( NtUserGetPointerDeviceProperties ) \ - SYSCALL_STUB( NtUserGetPointerDeviceRects ) \ SYSCALL_STUB( NtUserGetPointerDevices ) \ SYSCALL_STUB( NtUserGetPointerFrameTimes ) \ SYSCALL_STUB( NtUserGetPointerInputTransform ) \ diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 05ddbd85478..2c409010cd2 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1066,7 +1066,7 @@ @ stub -syscall NtUserGetPointerDeviceInputSpace @ stub -syscall NtUserGetPointerDeviceOrientation @ stub -syscall NtUserGetPointerDeviceProperties -@ stub -syscall NtUserGetPointerDeviceRects +@ stdcall -syscall NtUserGetPointerDeviceRects(long ptr ptr) @ stub -syscall NtUserGetPointerDevices @ stub -syscall NtUserGetPointerFrameTimes @ stdcall -syscall NtUserGetPointerInfoList(long long long long long ptr ptr ptr) diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index a07966c2ae4..5506c9fc5b0 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -2842,6 +2842,15 @@ NTSTATUS WINAPI wow64_NtUserGetPointerType( UINT *args ) return NtUserGetPointerType( id, type ); } +NTSTATUS WINAPI wow64_NtUserGetPointerDeviceRects( UINT *args ) +{ + HANDLE device = get_handle( &args ); + RECT *device_rect = get_ptr( &args ); + RECT *display_rect = get_ptr( &args ); + + return NtUserGetPointerDeviceRects( device, device_rect, display_rect ); +} + NTSTATUS WINAPI wow64_NtUserGetPriorityClipboardFormat( UINT *args ) { UINT *list = get_ptr( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index a5aeb28123e..c3c4c8cdcf2 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -882,6 +882,7 @@ W32KAPI HWND WINAPI NtUserGetOpenClipboardWindow(void); W32KAPI BOOL WINAPI NtUserGetPointerInfoList( UINT32 id, POINTER_INPUT_TYPE type, UINT_PTR, UINT_PTR, SIZE_T size, UINT32 *entry_count, UINT32 *pointer_count, void *pointer_info ); W32KAPI BOOL WINAPI NtUserGetPointerType( UINT32 id, POINTER_INPUT_TYPE *type ); +W32KAPI BOOL WINAPI NtUserGetPointerDeviceRects( HANDLE handle, RECT *device_rect, RECT *display_rect ); W32KAPI INT WINAPI NtUserGetPriorityClipboardFormat( UINT *list, INT count ); W32KAPI BOOL WINAPI NtUserGetProcessDefaultLayout( ULONG *layout ); W32KAPI ULONG WINAPI NtUserGetProcessDpiAwarenessContext( HANDLE process ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11166
From: "Anna (navi) Figueiredo Gomes" <navi@vlhl.dev> --- dlls/win32u/tests/win32u.c | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 4481ffa1b32..479d0532461 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -3004,6 +3004,59 @@ static void test_NtUserRegisterWindowMessage(void) ok( !wcscmp( buf, L"#0xabc" ), "buf = %s\n", debugstr_w(buf) ); } +static BOOL CALLBACK get_virtual_screen_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp ) +{ + RECT *virtual_rect = (RECT *)lp; + UnionRect( virtual_rect, virtual_rect, rect ); + return TRUE; +} + +static RECT get_virtual_screen_rect(void) +{ + RECT rect = {0}; + EnumDisplayMonitors( 0, NULL, get_virtual_screen_proc, (LPARAM)&rect ); + return rect; +} + +void test_NtUserGetPointerDeviceRects( const char *arg ) +{ + RECT screen, himetric_dev = {0}, device = {0}, display = {0}; + DPI_AWARENESS_CONTEXT ctx = 0; + const UINT himetric = 2540; + UINT ret, dpi; + + if (!strcmp( arg, "unaware" )) ctx = DPI_AWARENESS_CONTEXT_UNAWARE; + else if (!strcmp( arg, "system" )) ctx = DPI_AWARENESS_CONTEXT_SYSTEM_AWARE; + else if (!strcmp( arg, "monitor" )) ctx = DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE; + + if (ctx) + { + ret = SetProcessDpiAwarenessContext( ctx ); + ok( ret, "SetProcessDpiAwarenessContext failed, error %lu.\n", GetLastError() ); + } + + screen = get_virtual_screen_rect(); + + /* operating on unaware scaled values returns wrong values */ + ctx = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); + + dpi = GetDpiForSystem(); + himetric_dev.right = GetSystemMetrics( SM_CXVIRTUALSCREEN ) * himetric / dpi; + himetric_dev.bottom = GetSystemMetrics( SM_CYVIRTUALSCREEN ) * himetric / dpi; + + SetThreadDpiAwarenessContext( ctx ); + + ret = NtUserGetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &display ); + todo_wine + { + ok( ret, "NtUserGetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + ok( EqualRect( &device, &himetric_dev ), "device %s, expected %s\n", + wine_dbgstr_rect( &device ), wine_dbgstr_rect( &himetric_dev ) ); + ok( EqualRect( &display, &screen ), "display %s, expected %s\n", + wine_dbgstr_rect( &display ), wine_dbgstr_rect( &screen ) ); + } +} + START_TEST(win32u) { char **argv; @@ -3033,6 +3086,14 @@ START_TEST(win32u) return; } + if (argc > 3 && !strcmp( argv[2], "NtUserGetPointerDeviceRects" )) + { + winetest_push_context( "dpi context %s", argv[3] ); + test_NtUserGetPointerDeviceRects( argv[3] ); + winetest_pop_context(); + return; + } + test_NtUserEnumDisplayDevices(); test_window_props(); test_class(); @@ -3059,6 +3120,10 @@ START_TEST(win32u) run_in_process( argv, "NtUserEnableMouseInPointer 0" ); run_in_process( argv, "NtUserEnableMouseInPointer 1" ); + run_in_process( argv, "NtUserGetPointerDeviceRects unaware" ); + run_in_process( argv, "NtUserGetPointerDeviceRects system" ); + run_in_process( argv, "NtUserGetPointerDeviceRects monitor" ); + run_in_process( argv, "NtUserSetProcessDpiAwarenessContext 0x6010" ); run_in_process( argv, "NtUserSetProcessDpiAwarenessContext 0x11" ); run_in_process( argv, "NtUserSetProcessDpiAwarenessContext 0x12" ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11166
From: Rémi Bernon <rbernon@codeweavers.com> Native doesn't support DPI scaling otherwise and the tests are skipped. --- dlls/user32/tests/monitor.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index 69a46faba28..eaf3d268469 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -3755,7 +3755,10 @@ static void test_monitor_dpi(void) { int min = 0, max = 0, cur = 0; - set_display_settings( infos[i].handle, 800, 600 ); + /* native disables DPI scaling when resolution is below 1024x768, but Wine default CI resolution is 1024x768 */ + if (winetest_platform_is_wine) set_display_settings( infos[i].handle, 800, 600 ); + else set_display_settings( infos[i].handle, 1024, 768 ); + get_monitor_infos( infos ); /* refresh infos as changing display settings may invalidate HMONITOR */ get_monitor_dpi_scale( infos[i].handle, &min, &cur, &max ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11166
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/user32/tests/monitor.c | 40 ++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index eaf3d268469..d781bcde815 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -38,6 +38,8 @@ #include <stdio.h> #include <math.h> +#define HIMETRIC_PER_INCH 2540 + DEFINE_DEVPROPKEY(DEVPROPKEY_MONITOR_GPU_LUID, 0xca085853, 0x16ce, 0x48aa, 0xb1, 0x14, 0xde, 0x9c, 0x72, 0x33, 0x42, 0x23, 1); DEFINE_DEVPROPKEY(DEVPROPKEY_MONITOR_OUTPUT_ID, 0xca085853, 0x16ce, 0x48aa, 0xb1, 0x14, 0xde, 0x9c, 0x72, 0x33, 0x42, 0x23, 2); @@ -3217,7 +3219,7 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED, (DPI_AWARENESS_CONTEXT)0x7811, }; - RECT virtual = {0}, scaled_virtual = {0}, monitor = {0}, scaled = {0}, primary = {0}, rect, expect_rect; + RECT virtual = {0}, scaled_virtual = {0}, monitor = {0}, scaled = {0}, primary = {0}, rect, expect_rect, device, scaled_device, expect_device; struct monitor_info tmp_info = {.handle = info->handle}; UINT ret, i, x, y, expect_width, expect_height; HWND unaware_hwnd, aware_hwnd, primary_hwnd; @@ -3279,6 +3281,18 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c check_logical_physical_dpi( unaware_hwnd, monitor.left + 2 * scale + 1, monitor.top + 2 * scale + 1, monitor.left + 2 * scale + 1, monitor.top + 2 * scale + 1, FALSE ); + todo_wine ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &rect ); + todo_wine ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + todo_wine ok( EqualRect( &rect, &scaled_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); + + SetRect( &expect_device, 0, 0, virtual.right * HIMETRIC_PER_INCH / system_dpi, + virtual.bottom * HIMETRIC_PER_INCH / system_dpi ); + scaled_device = expect_device; + scaled_device.right = MulDiv( scaled_device.right, 100, scale ); + scaled_device.bottom = MulDiv( scaled_device.bottom, 100, scale ); + todo_wine ok( EqualRect( &device, &expect_device ) /* w10 */ || EqualRect( &device, &scaled_device ) /* w11 */, + "got %s vs %s\n", wine_dbgstr_rect(&device), wine_dbgstr_rect(&expect_device) ); + for (i = 0; i < ARRAY_SIZE(tests); i++) { BOOL monitor_aware = tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE || @@ -3565,6 +3579,12 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c check_logical_physical_dpi( primary_hwnd, primary.left + 4 * scale + 1, primary.top + 4 * scale + 1, primary.left + 4 * scale + 1, primary.top + 4 * scale + 1, FALSE ); + ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &rect ); + todo_wine ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + todo_wine ok( EqualRect( &rect, monitor_aware ? &virtual : &scaled_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); + todo_wine ok( EqualRect( &device, &expect_device ) /* w10 */ || EqualRect( &device, &scaled_device ) /* w11 */, + "got %s vs %s\n", wine_dbgstr_rect(&device), wine_dbgstr_rect(&expect_device) ); + DestroyWindow( primary_hwnd ); DestroyWindow( aware_hwnd ); @@ -3630,6 +3650,7 @@ static void test_monitor_dpi(void) {1024, 768}, }; UINT i, j, count, system_dpi, dpi_x, dpi_y; + RECT expect_rect, device, display; DPI_AWARENESS_CONTEXT old_ctx; float scale_x, scale_y; BOOL ret, is_virtual; @@ -3660,11 +3681,14 @@ static void test_monitor_dpi(void) { for (j = 0; j < ARRAY_SIZE(tests); j++) { + RECT virtual = {0}; + if (tests[j].width && tests[j].height && !set_display_settings( infos[i].handle, tests[j].width, tests[j].height )) continue; get_monitor_infos( infos ); /* refresh infos as changing display settings may invalidate HMONITOR */ scale_x = (infos[i].rect.right - infos[i].rect.left) / (float)(phys_infos[i].rect.right - phys_infos[i].rect.left); scale_y = (infos[i].rect.bottom - infos[i].rect.top) / (float)(phys_infos[i].rect.bottom - phys_infos[i].rect.top); + for (UINT i = 0; i < count; i++) UnionRect( &virtual, &virtual, &infos[i].rect ); ret = pGetDpiForMonitorInternal( infos[i].handle, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y ); ok( ret, "GetDpiForMonitorInternal failed, error %lu\n", GetLastError() ); @@ -3704,6 +3728,13 @@ static void test_monitor_dpi(void) ok( fabs( dpi_y - system_dpi * scale_y ) < system_dpi * 0.05, "got MDT_RAW_DPI y %u\n", dpi_y ); } + ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &display ); + todo_wine ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + todo_wine ok( EqualRect( &display, &virtual ), "got %s\n", wine_dbgstr_rect( &display ) ); + SetRect( &expect_rect, 0, 0, virtual.right * HIMETRIC_PER_INCH / system_dpi, + virtual.bottom * HIMETRIC_PER_INCH / system_dpi ); + todo_wine ok( EqualRect( &device, &expect_rect ), "got %s\n", wine_dbgstr_rect( &device ) ); + pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ); ret = pGetDpiForMonitorInternal( infos[i].handle, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y ); @@ -3744,6 +3775,13 @@ static void test_monitor_dpi(void) ok( fabs( dpi_y - system_dpi * scale_y ) < system_dpi * 0.05, "got MDT_RAW_DPI y %u\n", dpi_y ); } + ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &display ); + todo_wine ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + todo_wine ok( EqualRect( &display, &virtual ), "got %s\n", wine_dbgstr_rect( &display ) ); + SetRect( &expect_rect, 0, 0, virtual.right * HIMETRIC_PER_INCH / system_dpi, + virtual.bottom * HIMETRIC_PER_INCH / system_dpi ); + todo_wine ok( EqualRect( &device, &expect_rect ), "got %s\n", wine_dbgstr_rect( &device ) ); + pSetThreadDpiAwarenessContext( old_ctx ); } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11166
From: "Anna (navi) Figueiredo Gomes" <navi@vlhl.dev> --- dlls/user32/tests/monitor.c | 26 +++++++++++++------------- dlls/win32u/input.c | 21 ++++++++++++++++++--- dlls/win32u/tests/win32u.c | 13 +++++-------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index d781bcde815..6c386bd1e39 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -3281,16 +3281,16 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c check_logical_physical_dpi( unaware_hwnd, monitor.left + 2 * scale + 1, monitor.top + 2 * scale + 1, monitor.left + 2 * scale + 1, monitor.top + 2 * scale + 1, FALSE ); - todo_wine ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &rect ); - todo_wine ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); - todo_wine ok( EqualRect( &rect, &scaled_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); + ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &rect ); + ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + ok( EqualRect( &rect, &scaled_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); SetRect( &expect_device, 0, 0, virtual.right * HIMETRIC_PER_INCH / system_dpi, virtual.bottom * HIMETRIC_PER_INCH / system_dpi ); scaled_device = expect_device; scaled_device.right = MulDiv( scaled_device.right, 100, scale ); scaled_device.bottom = MulDiv( scaled_device.bottom, 100, scale ); - todo_wine ok( EqualRect( &device, &expect_device ) /* w10 */ || EqualRect( &device, &scaled_device ) /* w11 */, + ok( EqualRect( &device, &expect_device ) /* w10 */ || EqualRect( &device, &scaled_device ) /* w11 */, "got %s vs %s\n", wine_dbgstr_rect(&device), wine_dbgstr_rect(&expect_device) ); for (i = 0; i < ARRAY_SIZE(tests); i++) @@ -3580,9 +3580,9 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c primary.left + 4 * scale + 1, primary.top + 4 * scale + 1, FALSE ); ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &rect ); - todo_wine ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); - todo_wine ok( EqualRect( &rect, monitor_aware ? &virtual : &scaled_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); - todo_wine ok( EqualRect( &device, &expect_device ) /* w10 */ || EqualRect( &device, &scaled_device ) /* w11 */, + ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + ok( EqualRect( &rect, monitor_aware ? &virtual : &scaled_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); + ok( EqualRect( &device, &expect_device ) /* w10 */ || EqualRect( &device, &scaled_device ) /* w11 */, "got %s vs %s\n", wine_dbgstr_rect(&device), wine_dbgstr_rect(&expect_device) ); DestroyWindow( primary_hwnd ); @@ -3729,11 +3729,11 @@ static void test_monitor_dpi(void) } ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &display ); - todo_wine ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); - todo_wine ok( EqualRect( &display, &virtual ), "got %s\n", wine_dbgstr_rect( &display ) ); + ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + ok( EqualRect( &display, &virtual ), "got %s\n", wine_dbgstr_rect( &display ) ); SetRect( &expect_rect, 0, 0, virtual.right * HIMETRIC_PER_INCH / system_dpi, virtual.bottom * HIMETRIC_PER_INCH / system_dpi ); - todo_wine ok( EqualRect( &device, &expect_rect ), "got %s\n", wine_dbgstr_rect( &device ) ); + ok( EqualRect( &device, &expect_rect ), "got %s\n", wine_dbgstr_rect( &device ) ); pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ); @@ -3776,11 +3776,11 @@ static void test_monitor_dpi(void) } ret = GetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &display ); - todo_wine ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); - todo_wine ok( EqualRect( &display, &virtual ), "got %s\n", wine_dbgstr_rect( &display ) ); + ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + ok( EqualRect( &display, &virtual ), "got %s\n", wine_dbgstr_rect( &display ) ); SetRect( &expect_rect, 0, 0, virtual.right * HIMETRIC_PER_INCH / system_dpi, virtual.bottom * HIMETRIC_PER_INCH / system_dpi ); - todo_wine ok( EqualRect( &device, &expect_rect ), "got %s\n", wine_dbgstr_rect( &device ) ); + ok( EqualRect( &device, &expect_rect ), "got %s\n", wine_dbgstr_rect( &device ) ); pSetThreadDpiAwarenessContext( old_ctx ); } diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 41d871958f6..048950345b3 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -40,6 +40,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(win); WINE_DECLARE_DEBUG_CHANNEL(keyboard); +#define HIMETRIC_PER_INCH 2540 + static const WCHAR keyboard_layouts_keyW[] = { '\\','R','e','g','i','s','t','r','y', @@ -2892,7 +2894,20 @@ BOOL WINAPI NtUserGetPointerType( UINT32 id, POINTER_INPUT_TYPE *type ) */ BOOL WINAPI NtUserGetPointerDeviceRects( HANDLE handle, RECT *device_rect, RECT *display_rect ) { - FIXME( "handle %p, device_rect %p, display_rect %p stub!\n", handle, device_rect, display_rect ); - RtlSetLastWin32Error( ERROR_CALL_NOT_IMPLEMENTED ); - return FALSE; + RECT rect; + + if (handle != INVALID_HANDLE_VALUE) + { + FIXME( "Pointer devices are not implemented!\n" ); + RtlSetLastWin32Error( ERROR_NO_DATA ); + return FALSE; + } + + rect = get_virtual_screen_rect( 0, MDT_DEFAULT ); + SetRect( device_rect, 0, 0, (rect.right - rect.left) * HIMETRIC_PER_INCH / get_system_dpi(), + (rect.bottom - rect.top) * HIMETRIC_PER_INCH / get_system_dpi() ); + *display_rect = get_virtual_screen_rect( get_thread_dpi(), MDT_DEFAULT ); + + TRACE( "returning device %s, display %s\n", wine_dbgstr_rect(device_rect), wine_dbgstr_rect(display_rect) ); + return TRUE; } diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 479d0532461..a67b918626d 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -3047,14 +3047,11 @@ void test_NtUserGetPointerDeviceRects( const char *arg ) SetThreadDpiAwarenessContext( ctx ); ret = NtUserGetPointerDeviceRects( INVALID_HANDLE_VALUE, &device, &display ); - todo_wine - { - ok( ret, "NtUserGetPointerDeviceRects failed, error %lu.\n", GetLastError() ); - ok( EqualRect( &device, &himetric_dev ), "device %s, expected %s\n", - wine_dbgstr_rect( &device ), wine_dbgstr_rect( &himetric_dev ) ); - ok( EqualRect( &display, &screen ), "display %s, expected %s\n", - wine_dbgstr_rect( &display ), wine_dbgstr_rect( &screen ) ); - } + ok( ret, "NtUserGetPointerDeviceRects failed, error %lu.\n", GetLastError() ); + ok( EqualRect( &device, &himetric_dev ), "device %s, expected %s\n", + wine_dbgstr_rect( &device ), wine_dbgstr_rect( &himetric_dev ) ); + ok( EqualRect( &display, &screen ), "display %s, expected %s\n", + wine_dbgstr_rect( &display ), wine_dbgstr_rect( &screen ) ); } START_TEST(win32u) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11166
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11166
participants (3)
-
Anna (navi) Figueiredo Gomes -
Rémi Bernon -
Rémi Bernon (@rbernon)