winewayland.drv: Avoid transient deactivation of foreground thread.

When updating the foreground window, even if both the old and new active
window belong to the same non-current thread, the win32u code currently
explicitly deactivates the old window. This will cause the transient
deactivation of the foreground thread which can lead to undesirable
side-effects (e.g., some apps may minimize when they become inactive).

Until this is fixed in Wine core, use an internal driver message to
ensure that we call NtUserSetForegroundWindow from the context of
the new foreground window thread, to avoid the problematic behavior.
This commit is contained in:
Alexandros Frantzis 2023-12-08 10:28:39 +02:00 committed by Alexandre Julliard
parent a03cbbdbe2
commit 902884e6db
3 changed files with 11 additions and 2 deletions

View file

@ -717,7 +717,12 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *wl_keyboard,
if ((surface = wayland_surface_lock_hwnd(hwnd)))
{
if (surface->window.managed) NtUserSetForegroundWindow(hwnd);
/* TODO: Drop the internal message and call NtUserSetForegroundWindow
* directly once it's updated to not explicitly deactivate the old
* foreground window when both the old and new foreground windows
* are in the same non-current thread. */
if (surface->window.managed)
NtUserPostMessage(hwnd, WM_WAYLAND_SET_FOREGROUND, 0, 0);
pthread_mutex_unlock(&surface->mutex);
}
}

View file

@ -60,7 +60,8 @@ extern struct wayland process_wayland;
enum wayland_window_message
{
WM_WAYLAND_INIT_DISPLAY_DEVICES = 0x80001000,
WM_WAYLAND_CONFIGURE = 0x80001001
WM_WAYLAND_CONFIGURE = 0x80001001,
WM_WAYLAND_SET_FOREGROUND = 0x80001002,
};
enum wayland_surface_config_state

View file

@ -628,6 +628,9 @@ LRESULT WAYLAND_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
case WM_WAYLAND_CONFIGURE:
wayland_configure_window(hwnd);
return 0;
case WM_WAYLAND_SET_FOREGROUND:
NtUserSetForegroundWindow(hwnd);
return 0;
default:
FIXME("got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, (long)wp, lp);
return 0;