From: Zhiyi Zhang <zzhang@codeweavers.com> For example, Homeworld Remastered Collection (244160) Homeworld 2 Classic changes the display mode after NtUserSetActiveWindow(), then the following NtUserSetInternalWindowPos() call sets the window rect to the window rect before the display mode change. Thus, the game window can end up having an unexpected rect. There is a similar problem when LOWORD(state_cmd) == 0. Fix a regression from be60f77909fc9ce2c9b6f1abd005e3b4aabaafec. --- dlls/win32u/message.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 81e7fde1212..43c2855eff4 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2235,12 +2235,26 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR { case SC_RESTORE: if (HIWORD(state_cmd)) NtUserSetActiveWindow( hwnd ); + + /* window config might have been changed by set_foreground_window() or NtUserSetActiveWindow(), check again */ + if (foreground || HIWORD(state_cmd)) + { + user_driver->pGetWindowStateUpdates( hwnd, &state_cmd, &swp_flags, &window_rect, &foreground ); + window_rect = map_rect_raw_to_virt( window_rect, get_thread_dpi() ); + } + NtUserSetInternalWindowPos( hwnd, SW_SHOW, &window_rect, NULL ); /* fallthrough */ default: send_message( hwnd, WM_SYSCOMMAND, LOWORD(state_cmd), 0 ); break; case 0: + /* window config might have been changed by set_foreground_window(), check again */ + if (foreground) + { + user_driver->pGetWindowStateUpdates( hwnd, &state_cmd, &swp_flags, &window_rect, &foreground ); + window_rect = map_rect_raw_to_virt( window_rect, get_thread_dpi() ); + } if (!swp_flags) break; NtUserSetWindowPos( hwnd, 0, window_rect.left, window_rect.top, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, swp_flags ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10725