Module: wine
Branch: master
Commit: c964f1f93a16a959b1e17891a1fa3201990d1a8f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c964f1f93a16a959b1e17891…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Sat Oct 13 16:13:55 2018 -0700
d3d9/tests: Test when the device gets occluded during d3d9ex focus loss.
Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/d3d9/tests/d3d9ex.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 63b7c5a..bd2687f 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -2470,12 +2470,14 @@ struct message
enum message_window window;
BOOL check_wparam;
WPARAM expect_wparam;
+ HRESULT device_state;
WINDOWPOS *store_wp;
};
static const struct message *expect_messages;
static HWND device_window, focus_window;
static LONG windowposchanged_received, syscommand_received;
+static IDirect3DDevice9Ex *focus_test_device;
struct wndproc_thread_param
{
@@ -2487,6 +2489,8 @@ struct wndproc_thread_param
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
+ HRESULT hr;
+
if (filter_messages && filter_messages == hwnd)
{
if (message != WM_DISPLAYCHANGE && message != WM_IME_NOTIFY)
@@ -2522,6 +2526,15 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
if (expect_messages->store_wp)
*expect_messages->store_wp = *(WINDOWPOS *)lparam;
+ if (focus_test_device)
+ {
+ hr = IDirect3DDevice9Ex_CheckDeviceState(focus_test_device, device_window);
+ todo_wine_if(message != WM_ACTIVATEAPP && message != WM_DISPLAYCHANGE)
+ ok(hr == expect_messages->device_state,
+ "Got device state %#x on message %#x, expected %#x.\n",
+ hr, message, expect_messages->device_state);
+ }
+
++expect_messages;
}
}
@@ -2610,23 +2623,31 @@ static void test_wndproc(void)
* not reliable on X11 WMs. When the window focus follows the
* mouse pointer the message is not sent.
* {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE}, */
- {WM_DISPLAYCHANGE, DEVICE_WINDOW, FALSE, 0},
+
+ /* The S_PRESENT_MODE_CHANGED state is only there because we change the mode
+ * before dropping focus. From the base d3d9 tests one might expect d3d9ex to
+ * pick up the mode change by the time we receive WM_DISPLAYCHANGE, but as
+ * the tests below show, a present call is needed for that to happen. I don't
+ * want to call present in a focus loss message handler until we have an app
+ * that does that. Without the previous change (+present) the state would be
+ * D3D_OK all the way until the WM_ACTIVATEAPP message. */
+ {WM_DISPLAYCHANGE, DEVICE_WINDOW, FALSE, 0, S_PRESENT_MODE_CHANGED},
/* WM_DISPLAYCHANGE is sent to the focus window too, but the order is
* not deterministic. */
- {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0, S_PRESENT_MODE_CHANGED},
/* Windows sends WM_ACTIVATE to the device window, indicating that
* SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
* the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
* leaves the device window active, breaking re-activation in the
* lost device test.
* {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
- {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
- {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
- {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0, S_PRESENT_MODE_CHANGED},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED, S_PRESENT_MODE_CHANGED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE, S_PRESENT_OCCLUDED},
/* WM_ACTIVATEAPP is sent to the device window too, but the order is
* not deterministic. It may be sent after the focus window handling
* or before. */
- {0, 0, FALSE, 0},
+ {0, 0, FALSE, 0, 0},
};
static const struct message focus_loss_messages_nowc[] =
{
@@ -2704,7 +2725,7 @@ static void test_wndproc(void)
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
{WM_SIZE, DEVICE_WINDOW, FALSE, 0},
{WM_SHOWWINDOW, DEVICE_WINDOW, FALSE, 0},
- {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0, &windowpos},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0, ~0U, &windowpos},
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
/* TODO: WM_DISPLAYCHANGE is sent to the focus window too, but the order is
* differs between Wine and Windows. */
Module: wine
Branch: master
Commit: 222d30754e55ac32939e0689dcb027e7a4518150
URL: https://source.winehq.org/git/wine.git/?a=commit;h=222d30754e55ac32939e0689…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Sat Oct 13 16:13:51 2018 -0700
wined3d: Deactivate the device before minimizing the window.
This fixes tabbing out of Deus Ex Game of the Year edition.
Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/wined3d/device.c | 2 --
dlls/wined3d/swapchain.c | 14 ++++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index abb2a89..70d43e0 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5319,8 +5319,6 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
for (i = 0; i < device->swapchain_count; i++)
wined3d_swapchain_activate(device->swapchains[i], wparam);
-
- device->device_parent->ops->activate(device->device_parent, wparam);
}
else if (message == WM_SYSCOMMAND)
{
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index b068cf1..9c48de2 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -1162,6 +1162,9 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa
device->adapter->ordinal, &swapchain->d3d_mode)))
ERR("Failed to set display mode.\n");
}
+
+ if (swapchain == device->swapchains[0])
+ device->device_parent->ops->activate(device->device_parent, TRUE);
}
else
{
@@ -1171,6 +1174,17 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa
swapchain->reapply_mode = TRUE;
+ /* Some DDraw apps (Deus Ex: GOTY, and presumably all UT 1 based games) destroy the device
+ * during window minimization. Do our housekeeping now, as the device may not exist after
+ * the ShowWindow call.
+ *
+ * In d3d9, the device is marked lost after the window is minimized. If we find an app
+ * that needs this behavior (e.g. because it calls TestCooperativeLevel in the window proc)
+ * we'll have to control this via a create flag. Note that the device and swapchain are not
+ * safe to access after the ShowWindow call. */
+ if (swapchain == device->swapchains[0])
+ device->device_parent->ops->activate(device->device_parent, FALSE);
+
if (!(device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES)
&& IsWindowVisible(swapchain->device_window))
ShowWindow(swapchain->device_window, SW_MINIMIZE);