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/user32/tests/win.c | 2 -- dlls/win32u/tests/win32u.c | 12 ++++++------ dlls/win32u/window.c | 4 +++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 6ef13eaeaa3..b6b90116017 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -12060,7 +12060,6 @@ static void reset_window_state(HWND *state, int n) if (state[i]) { swp_after(state[i], HWND_NOTOPMOST); - todo_wine_if(i == 5) /* FIXME: remove once Wine is fixed */ ok(!is_topmost(state[i]), "%d: hwnd %p is still topmost\n", i, state[i]); swp_after(state[i], HWND_TOP); } @@ -12287,7 +12286,6 @@ static void test_topmost(void) ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n"); ok(!is_topmost(hwnd_child), "child should NOT be topmost\n"); ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n"); - todo_wine ok(!is_topmost(hwnd_grandchild), "grandchild should NOT be topmost\n"); check_z_order(hwnd, hwnd2, 0, owner, FALSE); check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE); diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 240bc802f22..7e8a5b99c34 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