From: Zhiyi Zhang <zzhang@codeweavers.com> Fix a regression from be60f77909fc9ce2c9b6f1abd005e3b4aabaafec, the intent of which was to restore the win32 window position to the current host window position. However, NtUserSetInternalWindowPos() eventually calls NtUserSetWindowPos() and NtUserShowWindow(). We don't want that because they might generate window position change messages that applications might not expect. Fix Homeworld Remastered Collection (244160) Homeworld 2 Classic black screen after restoring from the minimized state in fullscreen mode due to an unexpected window size. --- dlls/win32u/message.c | 5 ++++- dlls/win32u/win32u_private.h | 1 + dlls/win32u/window.c | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 81e7fde1212..a0eb097896b 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2235,7 +2235,10 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR { case SC_RESTORE: if (HIWORD(state_cmd)) NtUserSetActiveWindow( hwnd ); - NtUserSetInternalWindowPos( hwnd, SW_SHOW, &window_rect, NULL ); + + /* make the win32 window restore to the current host window config */ + set_window_normal_placement( hwnd, window_rect ); + /* fallthrough */ default: send_message( hwnd, WM_SYSCOMMAND, LOWORD(state_cmd), 0 ); diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 3bc6765d35e..031e1afec70 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -305,6 +305,7 @@ extern void map_window_region( HWND from, HWND to, HRGN hrgn ); extern BOOL screen_to_client( HWND hwnd, POINT *pt ); extern LONG_PTR set_window_long( HWND hwnd, INT offset, UINT size, LONG_PTR newval, BOOL ansi ); +extern void set_window_normal_placement( HWND hwnd, RECT rect ); extern BOOL set_window_pos( WINDOWPOS *winpos, int parent_x, int parent_y ); extern UINT set_window_style_bits( HWND hwnd, UINT set_bits, UINT clear_bits ); extern void update_window_state( HWND hwnd ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 682a9bad5a2..6cba020e6f3 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -3075,6 +3075,18 @@ static void make_point_onscreen( POINT *pt ) pt->y = rect.top; } +void set_window_normal_placement( HWND hwnd, RECT rect ) +{ + WND *win = get_win_ptr( hwnd ); + + if (win && win != WND_OTHER_PROCESS && win != WND_DESKTOP) + { + make_rect_onscreen( &rect ); + win->normal_rect = rect_thread_to_win_dpi( hwnd, rect ); + release_win_ptr( win ); + } +} + static BOOL set_window_placement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT flags ) { WND *win = get_win_ptr( hwnd ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10725