From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/user32/tests/monitor.c | 18 ++++++++---------- dlls/user32/tests/sysparams.c | 4 ++-- server/window.c | 11 +++++++++++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index de0b73dfb42..550108f720c 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -3575,28 +3575,26 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c else if (!tests[i]) ok( hwnd == GetDesktopWindow(), "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); else { - todo_wine ok( hwnd == NULL, "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); - todo_wine ok( GetLastError() == ERROR_INVALID_STATE, "SetParent failed err %lu\n", GetLastError() ); + ok( hwnd == NULL, "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); + ok( GetLastError() == ERROR_INVALID_STATE, "SetParent failed err %lu\n", GetLastError() ); } 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 ); hwnd = SetParent( child, NULL ); if (system_aware && !monitor_aware) ok( hwnd == aware_hwnd, "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); - else todo_wine ok( hwnd == GetDesktopWindow(), "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); + else ok( hwnd == GetDesktopWindow(), "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); 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 ); @@ -3649,15 +3647,15 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c else if (!tests[i]) ok( hwnd == GetDesktopWindow(), "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); else { - todo_wine ok( hwnd == NULL, "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); - todo_wine ok( GetLastError() == ERROR_INVALID_STATE, "SetParent failed err %lu\n", GetLastError() ); + ok( hwnd == NULL, "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); + ok( GetLastError() == ERROR_INVALID_STATE, "SetParent failed err %lu\n", GetLastError() ); } 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 ) + 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 ); @@ -3667,13 +3665,13 @@ static void test_monitor_dpi_awareness( const struct monitor_info *infos, UINT c * reparenting makes the window toplevel and changes its monitor */ hwnd = SetParent( child, NULL ); if (system_aware && !monitor_aware) ok( hwnd == unaware_hwnd, "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); - else todo_wine ok( hwnd == GetDesktopWindow(), "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); + else ok( hwnd == GetDesktopWindow(), "SetParent returned %p, error %lu\n", hwnd, GetLastError() ); 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 ) + 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 ); diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c index 31b125ae1d0..1c296448265 100644 --- a/dlls/user32/tests/sysparams.c +++ b/dlls/user32/tests/sysparams.c @@ -4596,8 +4596,8 @@ static void test_dpi_window(void) if (i == j) ok( !!ret, "SetParent failed err %lu\n", GetLastError() ); else { - todo_wine ok( !ret, "SetParent succeeded\n" ); - todo_wine ok( GetLastError() == ERROR_INVALID_STATE, "SetParent failed err %lu\n", GetLastError() ); + ok( !ret, "SetParent succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_STATE, "SetParent failed err %lu\n", GetLastError() ); } context = pGetWindowDpiAwarenessContext( child ); awareness = pGetAwarenessFromDpiAwarenessContext( context ); diff --git a/server/window.c b/server/window.c index 88f906cb746..b97eb2aa1c4 100644 --- a/server/window.c +++ b/server/window.c @@ -2118,6 +2118,13 @@ static void set_window_region( struct window *win, struct region *region, int re clear_error(); /* we ignore out of memory errors since the region has been set */ } +/* check if DPI awareness contexts are compatible */ +static bool is_dpi_awareness_compatible( struct window *win, struct window *other ) +{ + unsigned int awareness = NTUSER_DPI_CONTEXT_GET_AWARENESS( win->shared->dpi_context ); + return awareness == NTUSER_DPI_CONTEXT_GET_AWARENESS( other->shared->dpi_context ); +} + /* destroy a window */ void free_window_handle( struct window *win ) @@ -2303,6 +2310,10 @@ DECL_HANDLER(set_parent) if (!(win = get_window( req->handle ))) return; if (req->parent && !(parent = get_window( req->parent ))) return; + /* reparenting to a window with a different DPI awareness isn't allowed */ + if (parent && !is_desktop_window( parent ) && !is_dpi_awareness_compatible( win, parent )) + return set_error( STATUS_INVALID_STATE_TRANSITION ); + if (is_desktop_window(win) || is_orphan_window( win ) || (parent && is_orphan_window( parent ))) { set_error( STATUS_INVALID_PARAMETER ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11592