Hi,
Henri asked me to add my thoughts here because I once wrote most of the focus handling code but so far I am lost. This entire thing is fragile on both Windows and Wine.
I'm just dumping some random thoughts here. Maybe it gives you some idea, or some of your answers help me remember some bits:
*) I am wondering why the SetWindowPos in wined3d_swapchain_activate in the activate=true case doesn't use SWP_SHOWWINDOW or why there's no ShowWindow(SW_RESTORE) call.
*) When testing messages on Windows, be aware that messages that d3d9 generates in response to WM_ACTIVATEAPP appear to be send *before* WM_ACTIVATEAPP because the calls that generate them happen before d3d9 forwards the WM_ACTIVATEAPP message to the original wndproc.
*) The test shows that a WM_WINDOWPOSCHANGED message arrives after the window has been put out of iconic state, but the exact sequence isn't clear. Is this message produced by d3d9 or is it e.g. triggered by the taskbar.
*) Something that may be tricky to answer: What happens if a non-taskbar event brings the window of HOMM 5 back into the foreground, e.g. a separate process calling SetForegroundWindow? I think alt-tab behaves very similarly to the taskbar.
*) Is it possible that there is some WM_SYSCOMMAND specific behavior? d3d9 does hook this particular message.
*) On which Linux environment does the regression happen? There may be window manager specific behavior...
Stefan
Am 30.09.20 um 18:40 schrieb Gabriel Ivăncescu:
Fixes a regression introduced by commit 82c6ec3a32f44e8b3e0cc88b7f10e0c0d7fa1b89, which caused the WM_ACTIVATEAPP to be sent while the window is minimized, if it has been clicked on in the taskbar to be restored. The behavior is correct wrt Windows, but some games expect the window pos change messages to be sent while they are unminimized, but we only sent it during the WM_ACTIVATEAPP hook.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
I've added an interactive test in the next patch that the game depends on, and will fail without this patch.
dlls/wined3d/device.c | 11 ++++++++--- dlls/wined3d/swapchain.c | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index b077d53..343df46 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5845,6 +5845,8 @@ void device_invalidate_state(const struct wined3d_device *device, unsigned int s LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode, UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) {
- unsigned int i;
- if (message == WM_DESTROY) { TRACE("unregister window %p.\n", window);
@@ -5859,13 +5861,11 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL } else if (message == WM_ACTIVATEAPP) {
unsigned int i = device->swapchain_count;
/* Deactivating the implicit swapchain may cause the application * (e.g. Deus Ex: GOTY) to destroy the device, so take care to * deactivate the implicit swapchain last, and to avoid accessing the * "device" pointer afterwards. */
while (i--)
} else if (message == WM_SYSCOMMAND)for (i = device->swapchain_count; i--;) wined3d_swapchain_activate(device->swapchains[i], wparam);
@@ -5876,6 +5876,11 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL DefWindowProcW(window, message, wparam, lparam); else DefWindowProcA(window, message, wparam, lparam);
/* Heroes of Might and Magic V depends on this being
done after the window has been unminimized. */
for (i = device->swapchain_count; i--;)
}wined3d_swapchain_update_window_size(device->swapchains[i]); }
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 8741ed2..32f52b1 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -1839,7 +1839,8 @@ void wined3d_swapchain_update_window_size(struct wined3d_swapchain *swapchain) struct wined3d_output *output; HRESULT hr;
- if (swapchain->device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES)
if (swapchain->device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES ||
IsIconic(swapchain->state.device_window)) return;
output = wined3d_swapchain_get_output(swapchain);