[PATCH 0/3] MR11574: user32/tests: Add more system aware, initial and child window DPI tests.
This shows that initial window DPI should match the monitor DPI it is created on, and that DPI awareness should not change when window is reparented. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11574
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/user32/tests/monitor.c | 178 ++++++++++++++++++++++++++---------- 1 file changed, 128 insertions(+), 50 deletions(-) diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index e9cf9c13112..5b4c9ba93a0 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -3215,17 +3215,19 @@ 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, device, scaled_device, expect_device; + RECT virtual = {0}, scaled_virtual = {0}, unaware_virtual = {0}, monitor = {0}, unaware = {0}, scaled = {0}; + RECT primary = {0}, scaled_device = {0}, expect_device = {0}, rect, expect_rect, 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; MONITORINFO mi = {.cbSize = sizeof(mi)}; - DPI_AWARENESS_CONTEXT old_ctx = 0, cur_ctx, ctx; - float scale = scales[step], scale_x, scale_y; + DPI_AWARENESS_CONTEXT old_ctx = 0, cur_ctx, ctx, system_ctx = (DPI_AWARENESS_CONTEXT)(((UINT_PTR)system_dpi << 8)|0x11); + float unaware_scale = scales[step], scale, scale_x, scale_y; HDC hdc; scale_x = (info->rect.right - info->rect.left) / (float)(phys->rect.right - phys->rect.left); scale_y = (info->rect.bottom - info->rect.top) / (float)(phys->rect.bottom - phys->rect.top); + scale = unaware_scale * 96.0 / system_dpi; for (i = 0; i < count; i++) { @@ -3238,11 +3240,17 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c if (info != infos + i) { + UnionRect( &unaware_virtual, &unaware_virtual, &infos[i].rect ); UnionRect( &scaled_virtual, &scaled_virtual, &infos[i].rect ); UnionRect( &scaled_device, &scaled_device, &device ); } else { + unaware = infos[i].rect; + unaware.right = unaware.left + MulDiv( unaware.right - unaware.left, 100, unaware_scale ); + unaware.bottom = unaware.top + MulDiv( unaware.bottom - unaware.top, 100, unaware_scale ); + UnionRect( &unaware_virtual, &unaware_virtual, &unaware ); + scaled = monitor = infos[i].rect; scaled.right = scaled.left + MulDiv( scaled.right - scaled.left, 100, scale ); scaled.bottom = scaled.top + MulDiv( scaled.bottom - scaled.top, 100, scale ); @@ -3257,9 +3265,9 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c monitor.top + 100, 100, 100, NULL, NULL, NULL, NULL ); ok( unaware_hwnd != NULL, "CreateWindowW failed, error %lu\n", GetLastError() ); ctx = pGetWindowDpiAwarenessContext( unaware_hwnd ); - ok( ctx == (DPI_AWARENESS_CONTEXT)0x6010, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); + ok( ctx == system_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); ret = pGetDpiForWindow( unaware_hwnd ); - ok( ret == 96, "GetDpiForWindow returned %u\n", ret ); + ok( ret == system_dpi, "GetDpiForWindow returned %u\n", ret ); SetRect( &expect_rect, 0, 0, 100, 100 ); ret = GetClientRect( unaware_hwnd, &rect ); @@ -3282,7 +3290,8 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c check_physical_dpi( unaware_hwnd, monitor.left + 201, monitor.top + 201, monitor.left + 201, monitor.top + 201, FALSE ); check_logical_dpi_( __LINE__, unaware_hwnd, monitor.left + 201, monitor.top + 201, - monitor.left + MulDiv( 201, 100, scale ), monitor.top + MulDiv( 201, 100, scale ), TRUE, TRUE ); + monitor.left + MulDiv( 201, 100, scale ), monitor.top + MulDiv( 201, 100, scale ), + system_dpi == 96, system_dpi == 96 ); 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 ); @@ -3297,10 +3306,13 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c { BOOL monitor_aware = tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE || tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2; + BOOL system_aware = tests[i] != DPI_AWARENESS_CONTEXT_UNAWARE && + tests[i] != DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED; + if (tests[i]) old_ctx = pSetThreadDpiAwarenessContext( tests[i] ); cur_ctx = pGetThreadDpiAwarenessContext(); - winetest_push_context( "ctx %p", tests[i] ); + winetest_push_context( "ctx %Id", (INT_PTR)tests[i] ); ret = GetSystemMetrics( SM_XVIRTUALSCREEN ); ok( ret == virtual.left, "got SM_XVIRTUALSCREEN %d\n", ret ); @@ -3312,11 +3324,16 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c expect_width = virtual.right - virtual.left; expect_height = virtual.bottom - virtual.top; } - else + else if (system_aware) { expect_width = scaled_virtual.right - scaled_virtual.left; expect_height = scaled_virtual.bottom - scaled_virtual.top; } + else + { + expect_width = unaware_virtual.right - unaware_virtual.left; + expect_height = unaware_virtual.bottom - unaware_virtual.top; + } ret = GetSystemMetrics( SM_CXVIRTUALSCREEN ); ok( ret == expect_width, "got SM_CXVIRTUALSCREEN %d\n", ret ); ret = GetSystemMetrics( SM_CYVIRTUALSCREEN ); @@ -3332,11 +3349,16 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c expect_width = monitor.right - monitor.left; expect_height = monitor.bottom - monitor.top; } - else + else if (system_aware) { expect_width = scaled.right - scaled.left; expect_height = scaled.bottom - scaled.top; } + else + { + expect_width = unaware.right - unaware.left; + expect_height = unaware.bottom - unaware.top; + } ret = GetSystemMetrics( SM_CXSCREEN ); ok( ret == expect_width, "got SM_CXSCREEN %d\n", ret ); ret = GetSystemMetrics( SM_CYSCREEN ); @@ -3345,9 +3367,9 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c hdc = GetDC( NULL ); ok( !!hdc, "GetDC failed\n" ); ret = GetDeviceCaps( hdc, LOGPIXELSX ); - ok( ret == system_dpi, "got LOGPIXELSX %d\n", ret ); + ok( ret == (system_aware ? system_dpi : 96), "got LOGPIXELSX %d\n", ret ); ret = GetDeviceCaps( hdc, LOGPIXELSY ); - ok( ret == system_dpi, "got LOGPIXELSY %d\n", ret ); + ok( ret == (system_aware ? system_dpi : 96), "got LOGPIXELSY %d\n", ret ); ret = GetDeviceCaps( hdc, HORZRES ); ok( ret == expect_width, "got HORZRES %u\n", ret ); ret = GetDeviceCaps( hdc, VERTRES ); @@ -3358,7 +3380,8 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c ok( ret, "GetMonitorInfoW failed, error %lu\n", GetLastError() ); ok( mi.dwFlags == (monitor.left || monitor.top ? 0 : MONITORINFOF_PRIMARY), "got dwFlags %#lx\n", mi.dwFlags ); if (monitor_aware) ok( EqualRect( &monitor, &mi.rcMonitor ), "got rect %s\n", wine_dbgstr_rect(&mi.rcMonitor) ); - else ok( EqualRect( &scaled, &mi.rcMonitor ), "got rect %s\n", wine_dbgstr_rect(&mi.rcMonitor) ); + else if (system_aware) ok( EqualRect( &scaled, &mi.rcMonitor ), "got rect %s\n", wine_dbgstr_rect(&mi.rcMonitor) ); + else ok( EqualRect( &unaware, &mi.rcMonitor ), "got rect %s\n", wine_dbgstr_rect(&mi.rcMonitor) ); ok( mi.rcWork.top >= mi.rcMonitor.top, "got rect %s\n", wine_dbgstr_rect(&mi.rcWork) ); ok( mi.rcWork.left >= mi.rcMonitor.left, "got rect %s\n", wine_dbgstr_rect(&mi.rcWork) ); ok( mi.rcWork.right <= mi.rcMonitor.right, "got rect %s\n", wine_dbgstr_rect(&mi.rcWork) ); @@ -3376,8 +3399,8 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c } else { - ok( x == system_dpi, "got MDT_EFFECTIVE_DPI x %d\n", x ); - ok( y == system_dpi, "got MDT_EFFECTIVE_DPI y %d\n", y ); + ok( x == (system_aware ? system_dpi : 96), "got MDT_EFFECTIVE_DPI x %d\n", x ); + ok( y == (system_aware ? system_dpi : 96), "got MDT_EFFECTIVE_DPI y %d\n", y ); } ret = pGetDpiForMonitorInternal( info->handle, MDT_ANGULAR_DPI, &x, &y ); @@ -3394,8 +3417,8 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c } else if (!is_virtual) { - ok( x == MulDiv( phys->ang_x, 100, scale ), "got MDT_ANGULAR_DPI x %d\n", x ); - ok( y == MulDiv( phys->ang_y, 100, scale ), "got MDT_ANGULAR_DPI y %d\n", y ); + ok( x == MulDiv( phys->ang_x, 100, system_aware ? scale : unaware_scale ), "got MDT_ANGULAR_DPI x %d\n", x ); + ok( y == MulDiv( phys->ang_y, 100, system_aware ? scale : unaware_scale ), "got MDT_ANGULAR_DPI y %d\n", y ); } else { @@ -3422,8 +3445,8 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c } else if (!is_virtual) { - ok( x == MulDiv( phys->raw_x, 100, scale ), "got MDT_RAW_DPI x %d\n", x ); - ok( y == MulDiv( phys->raw_y, 100, scale ), "got MDT_RAW_DPI y %d\n", y ); + ok( x == MulDiv( phys->raw_x, 100, system_aware ? scale : unaware_scale ), "got MDT_RAW_DPI x %d\n", x ); + ok( y == MulDiv( phys->raw_y, 100, system_aware ? scale : unaware_scale ), "got MDT_RAW_DPI y %d\n", y ); } else { @@ -3433,18 +3456,21 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c ctx = pGetWindowDpiAwarenessContext( unaware_hwnd ); - ok( ctx == (DPI_AWARENESS_CONTEXT)0x6010, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); + ok( ctx == system_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); ret = pGetDpiForWindow( unaware_hwnd ); - ok( ret == 96, "GetDpiForWindow returned %u\n", ret ); + ok( ret == system_dpi, "GetDpiForWindow returned %u\n", ret ); if (monitor_aware) SetRect( &expect_rect, 0, 0, scale, scale ); - else SetRect( &expect_rect, 0, 0, 100, 100 ); + else if (system_aware) SetRect( &expect_rect, 0, 0, 100, 100 ); + else SetRect( &expect_rect, 0, 0, 100 * 96 / system_dpi, 100 * 96 / system_dpi ); ret = GetClientRect( unaware_hwnd, &rect ); ok( ret, "GetClientRect failed, error %lu\n", GetLastError() ); ok( EqualRect( &rect, &expect_rect ), "GetClientRect returned %s\n", wine_dbgstr_rect(&rect) ); if (monitor_aware) SetRect( &expect_rect, monitor.left + scale, monitor.top + scale, monitor.left + 2 * scale, monitor.top + 2 * scale ); - else SetRect( &expect_rect, monitor.left + 100, monitor.top + 100, monitor.left + 200, monitor.top + 200 ); + else if (system_aware) SetRect( &expect_rect, monitor.left + 100, monitor.top + 100, monitor.left + 200, monitor.top + 200 ); + else SetRect( &expect_rect, monitor.left + 100 * 96 / system_dpi, monitor.top + 100 * 96 / system_dpi, + monitor.left + 200 * 96 / system_dpi, monitor.top + 200 * 96 / system_dpi ); ret = GetWindowRect( unaware_hwnd, &rect ); ok( ret, "GetWindowRect failed, error %lu\n", GetLastError() ); ok( EqualRect( &rect, &expect_rect ), "GetWindowRect returned %s\n", wine_dbgstr_rect(&rect) ); @@ -3458,8 +3484,8 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) ok( ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %p vs %p\n", ctx, cur_ctx ); ret = pGetDpiForWindow( aware_hwnd ); - if (monitor_aware) ok( ret == MulDiv( 96, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); - else ok( ret == 96, "GetDpiForWindow returned %u\n", ret ); + if (monitor_aware) ok( ret == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); + else ok( ret == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", ret ); SetRect( &expect_rect, 0, 0, 100, 100 ); ret = GetClientRect( aware_hwnd, &rect ); @@ -3480,9 +3506,9 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) ok( ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); ret = pGetDpiForWindow( primary_hwnd ); - if (!monitor_aware) ok( ret == 96, "GetDpiForWindow returned %u\n", ret ); - else if (EqualRect( &primary, &monitor )) ok( ret == MulDiv( 96, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); - else ok( ret == 96, "GetDpiForWindow returned %u\n", ret ); + if (!monitor_aware) ok( ret == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", ret ); + else if (EqualRect( &primary, &monitor )) ok( ret == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); + else ok( ret == system_dpi, "GetDpiForWindow returned %u\n", ret ); SetRect( &expect_rect, 0, 0, 100, 100 ); ret = GetClientRect( primary_hwnd, &rect ); @@ -3495,21 +3521,25 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c ok( EqualRect( &rect, &expect_rect ), "GetWindowRect returned %s\n", wine_dbgstr_rect(&rect) ); - check_logical_physical_dpi( unaware_hwnd, monitor.left + 99, monitor.top + 99, - monitor.left + 99, monitor.top + 99, FALSE ); + check_logical_dpi( unaware_hwnd, monitor.left + 99, monitor.top + 99, monitor.left + 99, monitor.top + 99, FALSE ); + check_physical_dpi( unaware_hwnd, monitor.left + 99, monitor.top + 99, monitor.left + 99, monitor.top + 99, + !system_aware && system_dpi != 96 ); + if (monitor_aware) { check_logical_physical_dpi_( __LINE__, unaware_hwnd, monitor.left + 100, monitor.top + 100, - monitor.left + 100, monitor.top + 100, FALSE, TRUE ); + monitor.left + 100, monitor.top + 100, system_dpi != 96, TRUE ); check_logical_physical_dpi( unaware_hwnd, monitor.left + 200, monitor.top + 200, monitor.left + 2 * scale, monitor.top + 2 * scale, TRUE ); /* physical to logical conversion is lossy in the area of the screen where coordinate systems overlap but don't match */ check_physical_dpi_( __LINE__, unaware_hwnd, monitor.left + 201, monitor.top + 201, - monitor.left + MulDiv( 201, scale, 100 ), monitor.top + MulDiv( 201, scale, 100 ), TRUE, TRUE ); + monitor.left + MulDiv( 201, scale, 100 ), monitor.top + MulDiv( 201, scale, 100 ), + system_dpi == 96, system_dpi == 96 ); check_logical_dpi_( __LINE__, unaware_hwnd, monitor.left + 201, monitor.top + 201, - monitor.left + MulDiv( 201, 100, scale ), monitor.top + MulDiv( 201, 100, scale ), TRUE, TRUE ); + monitor.left + MulDiv( 201, 100, scale ), monitor.top + MulDiv( 201, 100, scale ), + system_dpi == 96, system_dpi == 96 ); } - else + else if (system_aware) { check_logical_physical_dpi( unaware_hwnd, monitor.left + 100, monitor.top + 100, monitor.left + 1 * scale, monitor.top + 1 * scale, TRUE ); @@ -3519,7 +3549,23 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c check_physical_dpi( unaware_hwnd, monitor.left + 201, monitor.top + 201, monitor.left + 201, monitor.top + 201, FALSE ); check_logical_dpi_( __LINE__, unaware_hwnd, monitor.left + 201, monitor.top + 201, - monitor.left + MulDiv( 201, 100, scale ), monitor.top + MulDiv( 201, 100, scale ), TRUE, TRUE ); + monitor.left + MulDiv( 201, 100, scale ), monitor.top + MulDiv( 201, 100, scale ), + system_dpi == 96, system_dpi == 96 ); + } + else + { + check_logical_physical_dpi( unaware_hwnd, monitor.left + 100, monitor.top + 100, + monitor.left + 1 * scale, monitor.top + 1 * scale, TRUE ); + check_logical_dpi( unaware_hwnd, monitor.left + 2 * scale, monitor.top + 2 * scale, + monitor.left + 200, monitor.top + 200, TRUE ); + check_physical_dpi( unaware_hwnd, monitor.left + 200, monitor.top + 200, + monitor.left + 2 * scale, monitor.top + 2 * scale, system_dpi == 96 ); + /* physical to logical conversion is lossy in the area of the screen where coordinate systems overlap but don't match */ + check_physical_dpi( unaware_hwnd, monitor.left + 201, monitor.top + 201, + monitor.left + 201, monitor.top + 201, FALSE ); + check_logical_dpi_( __LINE__, unaware_hwnd, monitor.left + 201, monitor.top + 201, + monitor.left + MulDiv( 201, 100, scale ), monitor.top + MulDiv( 201, 100, scale ), + system_dpi == 96, system_dpi == 96 ); } check_logical_physical_dpi( unaware_hwnd, monitor.left + 2 * scale + 1, monitor.top + 2 * scale + 1, @@ -3536,8 +3582,10 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c mi.rcWork.left + 300, mi.rcWork.top + 300, TRUE ); check_logical_physical_dpi( aware_hwnd, mi.rcWork.left + 301, mi.rcWork.top + 301, mi.rcWork.left + 301, mi.rcWork.top + 301, FALSE ); + check_logical_physical_dpi( aware_hwnd, mi.rcWork.left + 3 * scale + 1, mi.rcWork.top + 3 * scale + 1, + mi.rcWork.left + 3 * scale + 1, mi.rcWork.top + 3 * scale + 1, FALSE ); } - else + else if (system_aware) { check_logical_physical_dpi( aware_hwnd, mi.rcWork.left + 200, mi.rcWork.top + 200, mi.rcWork.left + 2 * scale, mi.rcWork.top + 2 * scale, TRUE ); @@ -3546,11 +3594,23 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c /* physical to logical conversion is lossy in the area of the screen where coordinate systems overlap but don't match */ check_physical_dpi( aware_hwnd, mi.rcWork.left + 301, mi.rcWork.top + 301, mi.rcWork.left + 301, mi.rcWork.top + 301, FALSE ); check_logical_dpi_( __LINE__, aware_hwnd, mi.rcWork.left + 301, mi.rcWork.top + 301, mi.rcWork.left + MulDiv( 301, 100, scale ), - mi.rcWork.top + MulDiv( 301, 100, scale ), TRUE, TRUE ); + mi.rcWork.top + MulDiv( 301, 100, scale ), system_dpi == 96, system_dpi == 96 ); + check_logical_physical_dpi( aware_hwnd, mi.rcWork.left + 3 * scale + 1, mi.rcWork.top + 3 * scale + 1, + mi.rcWork.left + 3 * scale + 1, mi.rcWork.top + 3 * scale + 1, FALSE ); + } + else + { + check_logical_physical_dpi( aware_hwnd, mi.rcWork.left + 200, mi.rcWork.top + 200, + mi.rcWork.left + 2 * unaware_scale, mi.rcWork.top + 2 * unaware_scale, TRUE ); + check_logical_physical_dpi( aware_hwnd, mi.rcWork.left + 300, mi.rcWork.top + 300, + mi.rcWork.left + 3 * unaware_scale, mi.rcWork.top + 3 * unaware_scale, TRUE ); + /* physical to logical conversion is lossy in the area of the screen where coordinate systems overlap but don't match */ + check_physical_dpi( aware_hwnd, mi.rcWork.left + 301, mi.rcWork.top + 301, mi.rcWork.left + 301, mi.rcWork.top + 301, FALSE ); + check_logical_dpi_( __LINE__, aware_hwnd, mi.rcWork.left + 301, mi.rcWork.top + 301, mi.rcWork.left + MulDiv( 301, 100, unaware_scale ), + mi.rcWork.top + MulDiv( 301, 100, unaware_scale ), TRUE, TRUE ); + check_logical_physical_dpi( aware_hwnd, mi.rcWork.left + 3 * unaware_scale + 1, mi.rcWork.top + 3 * unaware_scale + 1, + mi.rcWork.left + 3 * unaware_scale + 1, mi.rcWork.top + 3 * unaware_scale + 1, FALSE ); } - - check_logical_physical_dpi( aware_hwnd, mi.rcWork.left + 3 * scale + 1, mi.rcWork.top + 3 * scale + 1, - mi.rcWork.left + 3 * scale + 1, mi.rcWork.top + 3 * scale + 1, FALSE ); check_logical_physical_dpi( primary_hwnd, primary.left + 299, primary.top + 299, @@ -3563,8 +3623,10 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c primary.left + 400, primary.top + 400, TRUE ); check_logical_physical_dpi( primary_hwnd, primary.left + 401, primary.top + 401, primary.left + 401, primary.top + 401, FALSE ); + 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 ); } - else + else if (system_aware) { check_logical_physical_dpi( primary_hwnd, primary.left + 300, primary.top + 300, primary.left + 3 * scale, primary.top + 3 * scale, TRUE ); @@ -3573,22 +3635,36 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c /* physical to logical conversion is lossy in the area of the screen where coordinate systems overlap but don't match */ check_physical_dpi( primary_hwnd, primary.left + 401, primary.top + 401, primary.left + 401, primary.top + 401, FALSE ); check_logical_dpi_( __LINE__, primary_hwnd, primary.left + 401, primary.top + 401, primary.left + MulDiv( 401, 100, scale ), - primary.top + MulDiv( 401, 100, scale ), TRUE, TRUE ); + primary.top + MulDiv( 401, 100, scale ), system_dpi == 96, system_dpi == 96 ); + 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 ); + } + else + { + check_logical_physical_dpi( primary_hwnd, primary.left + 300, primary.top + 300, + primary.left + 3 * unaware_scale, primary.top + 3 * unaware_scale, TRUE ); + check_logical_physical_dpi( primary_hwnd, primary.left + 400, primary.top + 400, + primary.left + 4 * unaware_scale, primary.top + 4 * unaware_scale, TRUE ); + /* physical to logical conversion is lossy in the area of the screen where coordinate systems overlap but don't match */ + check_physical_dpi( primary_hwnd, primary.left + 401, primary.top + 401, primary.left + 401, primary.top + 401, FALSE ); + check_logical_dpi_( __LINE__, primary_hwnd, primary.left + 401, primary.top + 401, primary.left + MulDiv( 401, 100, unaware_scale ), + primary.top + MulDiv( 401, 100, unaware_scale ), TRUE, TRUE ); + check_logical_physical_dpi( primary_hwnd, primary.left + 4 * unaware_scale + 1, primary.top + 4 * unaware_scale + 1, + primary.left + 4 * unaware_scale + 1, primary.top + 4 * unaware_scale + 1, FALSE ); } - - 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 ); ok( ret, "GetPointerDeviceRects failed, error %lu.\n", GetLastError() ); - ok( EqualRect( &rect, monitor_aware ? &virtual : &scaled_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); + if (monitor_aware) ok( EqualRect( &rect, &virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); + else if (system_aware) ok( EqualRect( &rect, &scaled_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); + else ok( EqualRect( &rect, &unaware_virtual ), "got %s\n", wine_dbgstr_rect(&rect) ); ok( EqualRect( &device, &expect_device ) /* w10 */ || EqualRect( &device, &scaled_device ) /* w11 */, "got %s vs %s / %s\n", wine_dbgstr_rect(&device), wine_dbgstr_rect(&expect_device), wine_dbgstr_rect(&scaled_device) ); DestroyWindow( primary_hwnd ); DestroyWindow( aware_hwnd ); - if (tests[i]) pSetThreadDpiAwarenessContext( old_ctx ); + if (tests[i] && old_ctx) pSetThreadDpiAwarenessContext( old_ctx ); winetest_pop_context(); } @@ -3661,7 +3737,7 @@ static void test_monitor_dpi(void) return; } - old_ctx = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE ); + old_ctx = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); system_dpi = pGetDpiForSystem(); count = GetSystemMetrics( SM_CMONITORS ); @@ -3681,6 +3757,7 @@ static void test_monitor_dpi(void) { for (j = 0; j < ARRAY_SIZE(tests); j++) { + DPI_AWARENESS_CONTEXT prev_ctx; RECT virtual = {0}; if (tests[j].width && tests[j].height && !set_display_settings( infos[i].handle, tests[j].width, tests[j].height )) continue; @@ -3735,7 +3812,7 @@ static void test_monitor_dpi(void) virtual.bottom * HIMETRIC_PER_INCH / system_dpi ); ok( EqualRect( &device, &expect_rect ), "got %s\n", wine_dbgstr_rect( &device ) ); - pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ); + prev_ctx = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ); ret = pGetDpiForMonitorInternal( infos[i].handle, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y ); ok( ret, "GetDpiForMonitorInternal failed, error %lu\n", GetLastError() ); @@ -3782,12 +3859,11 @@ static void test_monitor_dpi(void) virtual.bottom * HIMETRIC_PER_INCH / system_dpi ); ok( EqualRect( &device, &expect_rect ), "got %s\n", wine_dbgstr_rect( &device ) ); - pSetThreadDpiAwarenessContext( old_ctx ); + pSetThreadDpiAwarenessContext( prev_ctx ); } } ChangeDisplaySettingsExW( NULL, NULL, 0, 0, NULL ); - pSetThreadDpiAwarenessContext( old_ctx ); for (i = 0; i < count; i++) { @@ -3812,6 +3888,8 @@ static void test_monitor_dpi(void) } ChangeDisplaySettingsExW( NULL, NULL, 0, 0, NULL ); + + pSetThreadDpiAwarenessContext( old_ctx ); } START_TEST(monitor) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11574
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/user32/tests/monitor.c | 69 +++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index 5b4c9ba93a0..71e42696e7c 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -3201,6 +3201,37 @@ static void check_logical_physical_dpi_( int line, HWND hwnd, UINT log_x, UINT l check_physical_dpi_( line, hwnd, log_x, log_y, phy_x, phy_y, expect_ret, todo_ret ); } +static DPI_AWARENESS_CONTEXT cbt_ctx; +static UINT cbt_dpi; + +static LRESULT CALLBACK test_monitor_dpi_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + if (msg == WM_NCCREATE) + { + DPI_AWARENESS_CONTEXT ctx; + UINT dpi; + + ctx = pGetWindowDpiAwarenessContext( hwnd ); + ok( ctx == cbt_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); + dpi = pGetDpiForWindow( hwnd ); + ok( dpi == cbt_dpi, "GetDpiForWindow returned %u\n", dpi ); + } + + return DefWindowProcW( hwnd, msg, wparam, lparam ); +} + +static LRESULT WINAPI test_monitor_dpi_cbtproc( int code, WPARAM wparam, LPARAM lparam ) +{ + if (code == HCBT_CREATEWND) + { + HWND hwnd = (HWND)wparam; + cbt_ctx = pGetWindowDpiAwarenessContext( hwnd ); + cbt_dpi = pGetDpiForWindow( hwnd ); + } + + return CallNextHookEx( NULL, code, wparam, lparam ); +} + static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT count, int step, UINT system_dpi, const struct monitor_info *info, struct monitor_info *phys, BOOL is_virtual ) { @@ -3223,6 +3254,7 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c MONITORINFO mi = {.cbSize = sizeof(mi)}; DPI_AWARENESS_CONTEXT old_ctx = 0, cur_ctx, ctx, system_ctx = (DPI_AWARENESS_CONTEXT)(((UINT_PTR)system_dpi << 8)|0x11); float unaware_scale = scales[step], scale, scale_x, scale_y; + HHOOK hook; HDC hdc; scale_x = (info->rect.right - info->rect.left) / (float)(phys->rect.right - phys->rect.left); @@ -3261,9 +3293,14 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c } } - unaware_hwnd = CreateWindowW( L"static", NULL, WS_POPUP | WS_VISIBLE, monitor.left + 100, + hook = SetWindowsHookExW( WH_CBT, test_monitor_dpi_cbtproc, 0, GetCurrentThreadId() ); + unaware_hwnd = CreateWindowW( L"test_monitor_dpi", NULL, WS_POPUP | WS_VISIBLE, monitor.left + 100, monitor.top + 100, 100, 100, NULL, NULL, NULL, NULL ); ok( unaware_hwnd != NULL, "CreateWindowW failed, error %lu\n", GetLastError() ); + ok( cbt_ctx == system_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)cbt_ctx ); + ok( cbt_dpi == system_dpi, "GetDpiForWindow returned %u\n", cbt_dpi ); + UnhookWindowsHookEx( hook ); + ctx = pGetWindowDpiAwarenessContext( unaware_hwnd ); ok( ctx == system_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); ret = pGetDpiForWindow( unaware_hwnd ); @@ -3476,9 +3513,15 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c ok( EqualRect( &rect, &expect_rect ), "GetWindowRect returned %s\n", wine_dbgstr_rect(&rect) ); - aware_hwnd = CreateWindowW( L"static", NULL, WS_POPUP | WS_VISIBLE, mi.rcWork.left + 200, + hook = SetWindowsHookExW( WH_CBT, test_monitor_dpi_cbtproc, 0, GetCurrentThreadId() ); + aware_hwnd = CreateWindowW( L"test_monitor_dpi", NULL, WS_POPUP | WS_VISIBLE, mi.rcWork.left + 200, mi.rcWork.top + 200, 100, 100, NULL, NULL, NULL, NULL ); ok( aware_hwnd != NULL, "CreateWindowW failed, error %lu\n", GetLastError() ); + todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) + ok( cbt_ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %p vs %p\n", cbt_ctx, cur_ctx ); + if (monitor_aware) ok( cbt_dpi == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", cbt_dpi ); + else ok( cbt_dpi == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", cbt_dpi ); + UnhookWindowsHookEx( hook ); ctx = pGetWindowDpiAwarenessContext( aware_hwnd ); todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) @@ -3498,9 +3541,16 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c ok( EqualRect( &rect, &expect_rect ), "GetWindowRect returned %s\n", wine_dbgstr_rect(&rect) ); - primary_hwnd = CreateWindowW( L"static", NULL, WS_POPUP | WS_VISIBLE, primary.left + 300, + hook = SetWindowsHookExW( WH_CBT, test_monitor_dpi_cbtproc, 0, GetCurrentThreadId() ); + primary_hwnd = CreateWindowW( L"test_monitor_dpi", NULL, WS_POPUP | WS_VISIBLE, primary.left + 300, primary.top + 300, 100, 100, NULL, NULL, NULL, NULL ); ok( primary_hwnd != NULL, "CreateWindowW failed, error %lu\n", GetLastError() ); + todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) + ok( cbt_ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)cbt_ctx ); + if (!monitor_aware) ok( cbt_dpi == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", cbt_dpi ); + else if (EqualRect( &primary, &monitor )) ok( cbt_dpi == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", cbt_dpi ); + else ok( cbt_dpi == system_dpi, "GetDpiForWindow returned %u\n", cbt_dpi ); + UnhookWindowsHookEx( hook ); ctx = pGetWindowDpiAwarenessContext( primary_hwnd ); todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) @@ -3730,6 +3780,13 @@ static void test_monitor_dpi(void) DPI_AWARENESS_CONTEXT old_ctx; float scale_x, scale_y; BOOL ret, is_virtual; + WNDCLASSW cls = + { + .lpfnWndProc = test_monitor_dpi_wndproc, + .hInstance = GetModuleHandleW( NULL ), + .hbrBackground = GetStockObject( WHITE_BRUSH ), + .lpszClassName = L"test_monitor_dpi", + }; if (!pGetDpiForMonitorInternal || !pSetThreadDpiAwarenessContext) { @@ -3737,6 +3794,9 @@ static void test_monitor_dpi(void) return; } + ret = RegisterClassW( &cls ); + ok( ret, "RegisterClassW failed, error %lu\n", GetLastError() ); + old_ctx = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ); system_dpi = pGetDpiForSystem(); @@ -3889,6 +3949,9 @@ static void test_monitor_dpi(void) ChangeDisplaySettingsExW( NULL, NULL, 0, 0, NULL ); + ret = UnregisterClassW( cls.lpszClassName, cls.hInstance ); + ok( ret, "UnregisterClassW failed, error %lu\n", GetLastError() ); + pSetThreadDpiAwarenessContext( old_ctx ); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11574
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/user32/tests/monitor.c | 160 +++++++++++++++++++++++++++++++++++- 1 file changed, 159 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index 71e42696e7c..8f82b328653 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -3201,11 +3201,21 @@ static void check_logical_physical_dpi_( int line, HWND hwnd, UINT log_x, UINT l check_physical_dpi_( line, hwnd, log_x, log_y, phy_x, phy_y, expect_ret, todo_ret ); } +static UINT dpichanged_count; +static WPARAM dpichanged_dpis; +static RECT dpichanged_rect; + static DPI_AWARENESS_CONTEXT cbt_ctx; static UINT cbt_dpi; static LRESULT CALLBACK test_monitor_dpi_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { + if (msg == WM_DPICHANGED) + { + dpichanged_dpis = wparam; + dpichanged_rect = *(RECT *)lparam; + dpichanged_count++; + } if (msg == WM_NCCREATE) { DPI_AWARENESS_CONTEXT ctx; @@ -3250,10 +3260,11 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c RECT primary = {0}, scaled_device = {0}, expect_device = {0}, rect, expect_rect, 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; + HWND unaware_hwnd, aware_hwnd, primary_hwnd, child; MONITORINFO mi = {.cbSize = sizeof(mi)}; DPI_AWARENESS_CONTEXT old_ctx = 0, cur_ctx, ctx, system_ctx = (DPI_AWARENESS_CONTEXT)(((UINT_PTR)system_dpi << 8)|0x11); float unaware_scale = scales[step], scale, scale_x, scale_y; + BOOL same_monitor; HHOOK hook; HDC hdc; @@ -3530,6 +3541,153 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c if (monitor_aware) ok( ret == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); else ok( ret == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", ret ); + ok( MonitorFromWindow( unaware_hwnd, MONITOR_DEFAULTTONEAREST ) == MonitorFromWindow( aware_hwnd, MONITOR_DEFAULTTONEAREST ), + "got different monitor\n" ); + + + /* if window was created as a child of DPI unaware window, it can never become DPI aware */ + child = CreateWindowW( L"static", NULL, WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, unaware_hwnd, NULL, NULL, NULL ); + ok( child != NULL, "CreateWindowW failed, error %lu\n", GetLastError() ); + SetWindowLongPtrW( child, GWLP_WNDPROC, (LONG_PTR)test_monitor_dpi_wndproc ); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + ok( ctx == system_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); + ret = pGetDpiForWindow( child ); + ok( ret == system_dpi, "GetDpiForWindow returned %u\n", ret ); + + SetParent( child, NULL ); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + ok( ctx == system_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); + ret = pGetDpiForWindow( child ); + ok( ret == system_dpi, "GetDpiForWindow returned %u\n", ret ); + + SetParent( child, aware_hwnd ); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + todo_wine_if( tests[i] && tests[i] != DPI_AWARENESS_CONTEXT_SYSTEM_AWARE && tests[i] != (DPI_AWARENESS_CONTEXT)0x7811 ) + ok( ctx == system_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); + ret = pGetDpiForWindow( child ); + ok( ret == system_dpi, "GetDpiForWindow returned %u\n", ret ); + + SetParent( child, NULL ); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + todo_wine_if( tests[i] && tests[i] != DPI_AWARENESS_CONTEXT_SYSTEM_AWARE && tests[i] != (DPI_AWARENESS_CONTEXT)0x7811 ) + ok( ctx == system_ctx, "GetWindowDpiAwarenessContext returned %#Ix\n", (UINT_PTR)ctx ); + ret = pGetDpiForWindow( child ); + ok( ret == system_dpi, "GetDpiForWindow returned %u\n", ret ); + + DestroyWindow( child ); + + + /* if window is created as a child of DPI aware window, it is always DPI aware */ + child = CreateWindowW( L"static", NULL, WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, aware_hwnd, NULL, NULL, NULL ); + ok( child != NULL, "CreateWindowW failed, error %lu\n", GetLastError() ); + SetWindowLongPtrW( child, GWLP_WNDPROC, (LONG_PTR)test_monitor_dpi_wndproc ); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) + ok( ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %p vs %p\n", ctx, cur_ctx ); + ret = pGetDpiForWindow( child ); + if (monitor_aware) ok( ret == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); + else ok( ret == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", ret ); + + /* WM_DPICHANGED is only sent if window was child of monitor aware window, and if + * reparenting makes the window toplevel and changes its monitor */ + SetParent( child, NULL ); + same_monitor = MonitorFromWindow( aware_hwnd, MONITOR_DEFAULTTONEAREST ) == MonitorFromWindow( child, MONITOR_DEFAULTTONEAREST ); + if (!monitor_aware || same_monitor) ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + else + { + ok( dpichanged_count == 1, "got dpichanged_count %u\n", dpichanged_count ); + ok( dpichanged_dpis == MAKELONG(system_dpi, system_dpi), "got dpichanged_dpis %Ix\n", dpichanged_dpis ); + ok( !IsRectEmpty( &dpichanged_rect ), "got dpichanged_rect %s\n", wine_dbgstr_rect( &dpichanged_rect ) ); + dpichanged_count = dpichanged_dpis = 0; + SetRect( &dpichanged_rect, 0, 0, 0, 0 ); + } + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) + ok( ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %p vs %p\n", ctx, cur_ctx ); + ret = pGetDpiForWindow( child ); + if (monitor_aware && same_monitor) ok( ret == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); + else ok( ret == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", ret ); + + SetParent( child, unaware_hwnd ); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + todo_wine_if( tests[i] && tests[i] != DPI_AWARENESS_CONTEXT_SYSTEM_AWARE && tests[i] != (DPI_AWARENESS_CONTEXT)0x7811 ) + ok( ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %p vs %p\n", ctx, cur_ctx ); + ret = pGetDpiForWindow( child ); + if (monitor_aware && same_monitor) ok( ret == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); + else ok( ret == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", ret ); + + /* WM_DPICHANGED is only sent if window was child of monitor aware window, and if + * reparenting makes the window toplevel and changes its monitor */ + SetParent( child, NULL ); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + todo_wine_if( tests[i] && tests[i] != DPI_AWARENESS_CONTEXT_SYSTEM_AWARE && tests[i] != (DPI_AWARENESS_CONTEXT)0x7811 ) + ok( ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %p vs %p\n", ctx, cur_ctx ); + ret = pGetDpiForWindow( child ); + if (monitor_aware && same_monitor) ok( ret == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); + else ok( ret == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", ret ); + + SetParent( child, aware_hwnd ); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + ctx = pGetWindowDpiAwarenessContext( child ); + todo_wine_if(tests[i] == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) + ok( ctx == cur_ctx, "GetWindowDpiAwarenessContext returned %p vs %p\n", ctx, cur_ctx ); + ret = pGetDpiForWindow( child ); + if (monitor_aware) ok( ret == MulDiv( system_dpi, scale, 100 ), "GetDpiForWindow returned %u\n", ret ); + else ok( ret == (system_aware ? system_dpi : 96), "GetDpiForWindow returned %u\n", ret ); + + /* WM_DPICHANGED is only sent if window was children of monitor aware window, and if + * reparenting makes the window toplevel and changes its monitor */ + SetParent( child, NULL ); + same_monitor = MonitorFromWindow( aware_hwnd, MONITOR_DEFAULTTONEAREST ) == MonitorFromWindow( child, MONITOR_DEFAULTTONEAREST ); + if (!monitor_aware || same_monitor) ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + else + { + ok( dpichanged_count == 1, "got dpichanged_count %u\n", dpichanged_count ); + ok( dpichanged_dpis == MAKELONG(system_dpi, system_dpi), "got dpichanged_dpis %Ix\n", dpichanged_dpis ); + ok( !IsRectEmpty( &dpichanged_rect ), "got dpichanged_rect %s\n", wine_dbgstr_rect( &dpichanged_rect ) ); + dpichanged_count = dpichanged_dpis = 0; + SetRect( &dpichanged_rect, 0, 0, 0, 0 ); + } + flush_events(); + ok( dpichanged_count == 0, "got dpichanged_count %u\n", dpichanged_count ); + + DestroyWindow( child ); + + SetRect( &expect_rect, 0, 0, 100, 100 ); ret = GetClientRect( aware_hwnd, &rect ); ok( ret, "GetClientRect failed, error %lu\n", GetLastError() ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11574
participants (2)
-
Rémi Bernon -
Rémi Bernon (@rbernon)