Removing WS_VISIBLE without updating the window state with SWP_FRAMECHANGED is enough to trigger d3d9's hidden window codepath (native and in Wine), but doesn't actually hide the window. This prevents unpredictable focus changes on focus follows mouse WMs.
Signed-off-by: Stefan Dösinger stefan@codeweavers.com --- dlls/d3d9/tests/d3d9ex.c | 6 +++++- dlls/d3d9/tests/device.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index c965af7264..702fea001d 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -2952,7 +2952,11 @@ static void test_wndproc(void) hr = reset_device(device, &device_desc); ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
- ShowWindow(device_window, SW_HIDE); + /* Remove the WS_VISIBLE flag to test hidden windows. This is enough to trigger d3d's hidden + * window codepath, but does not actually hide the window without a SetWindowPos(SWP_FRAMECHANGED) + * call. This way we avoid focus changes and random failures on focus follows mouse WMs. */ + device_style = GetWindowLongA(device_window, GWL_STYLE); + SetWindowLongA(device_window, GWL_STYLE, device_style & ~WS_VISIBLE); flush_events();
expect_messages = focus_loss_messages_hidden; diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 3bf9c10f20..790e98ae4d 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -3907,7 +3907,11 @@ static void test_wndproc(void) hr = reset_device(device, &device_desc); ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
- ShowWindow(device_window, SW_HIDE); + /* Remove the WS_VISIBLE flag to test hidden windows. This is enough to trigger d3d's hidden + * window codepath, but does not actually hide the window without a SetWindowPos(SWP_FRAMECHANGED) + * call. This way we avoid focus changes and random failures on focus follows mouse WMs. */ + device_style = GetWindowLongA(device_window, GWL_STYLE); + SetWindowLongA(device_window, GWL_STYLE, device_style & ~WS_VISIBLE); flush_events();
expect_messages = focus_loss_messages_hidden;
Signed-off-by: Stefan Dösinger stefan@codeweavers.com --- dlls/d3d8/tests/device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 915ab8b0c3..8743a24a9a 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -2888,7 +2888,11 @@ static void test_wndproc(void) hr = reset_device(device, &device_desc); ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
- ShowWindow(device_window, SW_HIDE); + /* Remove the WS_VISIBLE flag to test hidden windows. This is enough to trigger d3d's hidden + * window codepath, but does not actually hide the window without a SetWindowPos(SWP_FRAMECHANGED) + * call. This way we avoid focus changes and random failures on focus follows mouse WMs. */ + device_style = GetWindowLongA(device_window, GWL_STYLE); + SetWindowLongA(device_window, GWL_STYLE, device_style & ~WS_VISIBLE); flush_events();
expect_messages = focus_loss_messages_hidden;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com