Allow messages after SetForegroundWindow returns. Kwin likes to resize our window some more after d3d9 resized it.
Patch 2 makes the test stricter on Windows to give it some meaning.
From: Stefan Dösinger stefan@codeweavers.com
Allow messages after SetForegroundWindow returns. Kwin likes to resize our window some more after d3d9 resized it. --- dlls/d3d9/tests/device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index a776c112c39..32ea5962ad4 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -4460,12 +4460,14 @@ static void test_wndproc(void) expect_messages = reactivate_messages_filtered; windowposchanged_received = 0; SetForegroundWindow(focus_window); + /* We shouldn't receive any of the messages that tell us that d3d9 changed our window size. + * Unfortunately there are a lot of causes of WM_WINDOWPOSCHANGED messages. kwin likes to + * resize the window behind our back, but does so after SetForegroundWindow returns. */ + ok(!windowposchanged_received || broken(1), + "Received WM_WINDOWPOSCHANGED but did not expect it, i=%u.\n", i); flush_events(); ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n", expect_messages->message, expect_messages->window, i); - /* About 1 in 8 test runs receives WM_WINDOWPOSCHANGED on Vista. */ - ok(!windowposchanged_received || broken(1), - "Received WM_WINDOWPOSCHANGED but did not expect it, i=%u.\n", i); expect_messages = NULL;
/* On Windows 10 style change messages are delivered both on reset and
From: Stefan Dösinger stefan@codeweavers.com
--- dlls/d3d9/tests/device.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 32ea5962ad4..782a00196f6 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -3748,6 +3748,7 @@ static void test_multi_device(void) }
static HWND filter_messages; +static WINDOWPOS last_wp;
enum message_window { @@ -3837,7 +3838,10 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM * message. A WM_WINDOWPOSCHANGED message is not generated, so * just flag WM_WINDOWPOSCHANGED as bad. */ if (message == WM_WINDOWPOSCHANGED) + { InterlockedIncrement(&windowposchanged_received); + last_wp = *(WINDOWPOS *)lparam; + } else if (message == WM_SYSCOMMAND) InterlockedIncrement(&syscommand_received); else if (message == WM_SIZE) @@ -4458,13 +4462,18 @@ static void test_wndproc(void) flush_events();
expect_messages = reactivate_messages_filtered; + memset(&last_wp, 0, sizeof(last_wp)); windowposchanged_received = 0; SetForegroundWindow(focus_window); /* We shouldn't receive any of the messages that tell us that d3d9 changed our window size. * Unfortunately there are a lot of causes of WM_WINDOWPOSCHANGED messages. kwin likes to - * resize the window behind our back, but does so after SetForegroundWindow returns. */ - ok(!windowposchanged_received || broken(1), - "Received WM_WINDOWPOSCHANGED but did not expect it, i=%u.\n", i); + * resize the window behind our back, but does so after SetForegroundWindow returns. On + * Windows Vista or newer the Z order might change, although that seems to be caused by + * SetForegroundWindow itself and not d3d9 (it also happens in the NOWINDOWCHANGES case). */ + ok(!windowposchanged_received || broken(windowposchanged_received == 1 + && (last_wp.flags & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE)), + "Received %lu WM_WINDOWPOSCHANGED but did not expect it, i=%u, flags=%#x.\n", + windowposchanged_received, i, last_wp.flags); flush_events(); ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n", expect_messages->message, expect_messages->window, i);
Lets see what CI says about this. If I can't get it to work I'd rather remove the check for WM_WINDOWPOSCHANGED here entirely rather than try to invoke a recursive reset() because the follow up tests - Reset needs to be called after focus regain - are more important than the window resize details.