From: Jiajin Cui <cuijiajin@uniontech.com> If the after parameter was changed to the window itself during z-order processing, restore it to the initial value before returning. This prevents self-referencing z-order values that could cause issues in subsequent window positioning operations. Signed-off-by: Jiajin Cui <cuijiajin@uniontech.com> --- dlls/win32u/tests/win32u.c | 12 ++++++------ dlls/win32u/window.c | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 8eff33c381f..ebfcf82a48e 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -3086,19 +3086,19 @@ static void test_swp_owner_popups(void) ok( ret, "[case1] SetWindowPos(popup1, owner) failed\n" ); /* Verify that hwndInsertAfter is not the window itself, should be owner */ - todo_wine ok( test_swp_owner_captured_insert_after == owner, + ok( test_swp_owner_captured_insert_after == owner, "hwndInsertAfter should be owner (%p), got %p\n", owner, test_swp_owner_captured_insert_after); /* Verify z-order: popup2 should still be the topmost owned popup above owner */ prev = GetWindow(owner, GW_HWNDPREV); - todo_wine ok( prev == popup2, + ok( prev == popup2, "[case1] window above owner should be popup2 (%p), got %p\n", popup2, prev); /* popup1 was inserted right after owner, so owner should be directly above popup1 */ prev = GetWindow(popup1, GW_HWNDPREV); - todo_wine ok( prev == owner, + ok( prev == owner, "[case1] window above popup1 should be owner (%p), got %p\n", owner, prev); @@ -3112,7 +3112,7 @@ static void test_swp_owner_popups(void) ok( ret, "[case2] SetWindowPos(popup1, other) failed\n" ); /* hwndInsertAfter should be adjusted to popup2 to keep popup1 above owner */ - todo_wine ok( test_swp_owner_captured_insert_after == popup2, + ok( test_swp_owner_captured_insert_after == popup2, "[case2] captured hwndInsertAfter should be popup2 (%p), got %p\n", popup2, test_swp_owner_captured_insert_after); @@ -3131,13 +3131,13 @@ static void test_swp_owner_popups(void) ok( ret, "[case3] SetWindowPos(popup1, other) failed\n" ); /* hwndInsertAfter should again be adjusted to other */ - todo_wine ok( test_swp_owner_captured_insert_after == other2, + ok( test_swp_owner_captured_insert_after == other2, "[case3] captured hwndInsertAfter should still be other2 (%p), got %p\n", other2, test_swp_owner_captured_insert_after); /* Verify z-order: popup2 should still be above owner */ prev = GetWindow(owner, GW_HWNDPREV); - todo_wine ok( prev == popup2, + ok( prev == popup2, "[case3] window above owner should still be popup2 (%p), got %p\n", popup2, prev); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index c3a32dde6cf..900f6cf61f4 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -3787,7 +3787,7 @@ static BOOL fixup_swp_flags( WINDOWPOS *winpos, const RECT *old_window_rect, int */ static HWND swp_owner_popups( HWND hwnd, HWND after ) { - HWND owner, *list = NULL; + HWND owner, *list = NULL, initial_after = after; unsigned int i; TRACE( "(%p) after = %p\n", hwnd, after ); @@ -3857,6 +3857,8 @@ static HWND swp_owner_popups( HWND hwnd, HWND after ) done: free( list ); + + if(after == hwnd) after = initial_after; /* restore initial after value if it was changed to the window itself */ return after; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11135