Signed-off-by: Paul Gofman pgofman@codeweavers.com --- This is a follow up for commit 78533e9e94d4fcae06dd44d29dbed4755d4ac1f4 porting the same test for ddraw. Altough the test result is different, ddraw doesn't seem to do the same.
What I think is going on in d3d9 (deserves a separate test which I don't have yet ready) is that d3d9 window hook sends WM_ACTIVATEAPP whenever it receives WM_SIZE event (dumping messages in flush_events() show that). Then, WM_ACTIVATEAPP is already processed the way it restores the window size in Wine but it probably should also remeber the "activated" state and then the second resize also won't have an effect.
dlls/ddraw/tests/ddraw1.c | 40 ++++++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw2.c | 40 ++++++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw4.c | 40 ++++++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw7.c | 40 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 156 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index c9f2aead75c..11c14777122 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -14191,7 +14191,7 @@ static void test_vtbl_protection(void) static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *monitor_rect, LPARAM lparam) { - RECT primary_rect, window_rect; + RECT primary_rect, window_rect, new_rect; IDirectDraw *ddraw; HWND window; HRESULT hr; @@ -14214,6 +14214,44 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n", wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
+ new_rect = window_rect; + --new_rect.right; + --new_rect.bottom; + + ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left, + new_rect.bottom - new_rect.top, TRUE); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(EqualRect(&window_rect, &new_rect), + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + /* After processing window events window rectangle gets restored. But only once, the size set + * on the second resize remains. */ + flush_events(); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + /* Both Windows and Wine change the size of the window. On Windows it is exactly the new size but in Wine + * it may get adjusted depending on window manager. */ + ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom, + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + + ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left, + new_rect.bottom - new_rect.top, TRUE); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(EqualRect(&window_rect, &new_rect), + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + flush_events(); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom, + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + /* Window activation should restore the window to fit the whole primary monitor */ ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0, SWP_NOZORDER | SWP_NOSIZE); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 7285c1c3a88..33ad957b644 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -15115,7 +15115,7 @@ done: static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *monitor_rect, LPARAM lparam) { - RECT primary_rect, window_rect; + RECT primary_rect, window_rect, new_rect; IDirectDraw2 *ddraw; HWND window; HRESULT hr; @@ -15138,6 +15138,44 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n", wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
+ new_rect = window_rect; + --new_rect.right; + --new_rect.bottom; + + ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left, + new_rect.bottom - new_rect.top, TRUE); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(EqualRect(&window_rect, &new_rect), + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + /* After processing window events window rectangle gets restored. But only once, the size set + * on the second resize remains. */ + flush_events(); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + /* Both Windows and Wine change the size of the window. On Windows it is exactly the new size but in Wine + * it may get adjusted depending on window manager. */ + ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom, + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + + ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left, + new_rect.bottom - new_rect.top, TRUE); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(EqualRect(&window_rect, &new_rect), + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + flush_events(); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom, + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + /* Window activation should restore the window to fit the whole primary monitor */ ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0, SWP_NOZORDER | SWP_NOSIZE); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 07afc44e519..61828430331 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -18152,7 +18152,7 @@ done: static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *monitor_rect, LPARAM lparam) { - RECT primary_rect, window_rect; + RECT primary_rect, window_rect, new_rect; IDirectDraw4 *ddraw; HWND window; HRESULT hr; @@ -18175,6 +18175,44 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n", wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
+ new_rect = window_rect; + --new_rect.right; + --new_rect.bottom; + + ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left, + new_rect.bottom - new_rect.top, TRUE); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(EqualRect(&window_rect, &new_rect), + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + /* After processing window events window rectangle gets restored. But only once, the size set + * on the second resize remains. */ + flush_events(); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + /* Both Windows and Wine change the size of the window. On Windows it is exactly the new size but in Wine + * it may get adjusted depending on window manager. */ + ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom, + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + + ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left, + new_rect.bottom - new_rect.top, TRUE); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(EqualRect(&window_rect, &new_rect), + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + flush_events(); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom, + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + /* Window activation should restore the window to fit the whole primary monitor */ ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0, SWP_NOZORDER | SWP_NOSIZE); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 29fa3434d4b..fc0f854e125 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -18419,7 +18419,7 @@ done: static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *monitor_rect, LPARAM lparam) { - RECT primary_rect, window_rect; + RECT primary_rect, window_rect, new_rect; IDirectDraw7 *ddraw; HWND window; HRESULT hr; @@ -18442,6 +18442,44 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n", wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
+ new_rect = window_rect; + --new_rect.right; + --new_rect.bottom; + + ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left, + new_rect.bottom - new_rect.top, TRUE); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(EqualRect(&window_rect, &new_rect), + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + /* After processing window events window rectangle gets restored. But only once, the size set + * on the second resize remains. */ + flush_events(); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + /* Both Windows and Wine change the size of the window. On Windows it is exactly the new size but in Wine + * it may get adjusted depending on window manager. */ + ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom, + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + + ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left, + new_rect.bottom - new_rect.top, TRUE); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(EqualRect(&window_rect, &new_rect), + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + flush_events(); + ret = GetWindowRect(window, &window_rect); + ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError()); + ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom, + "Expected window rect %s, got %s.\n", + wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect)); + /* Window activation should restore the window to fit the whole primary monitor */ ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);