From: "Anna (navi) Figueiredo Gomes" <navi@vlhl.dev> --- dlls/win32u/tests/win32u.c | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 19c05a97835..6b5fa2e4e78 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -2949,6 +2949,61 @@ 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; + UINT ret, width, height; + + 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(); + + /* the screen rect is affected by DPI, but the pointer device isn't */ + ctx = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); + width = GetSystemMetrics(SM_CXVIRTUALSCREEN); + height = GetSystemMetrics(SM_CYVIRTUALSCREEN); + SetThreadDpiAwarenessContext(ctx); + + himetric_dev.right = width * 21.166666666666668; + himetric_dev.bottom = height * 21.166666666666668; + + 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; @@ -2978,6 +3033,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(); @@ -3004,6 +3067,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/10649