Better window detection for when a window regains focus.

This commit is contained in:
Storm Dragon committed 2026-10-15 13:25:47 -04:00
1 parent e3de71e594
commit ea509509e4
6 files changed
+67 -14

No files matched your search

+32
View File
@@ -130,6 +130,38 @@ int main(int argc, char **argv) {
focus(linuxWindow, linuxWindow);
focus(desktop, desktop);
ok &= check(restore_virtual_desktop_focus(), "later workspace return recovers again");
pump();
ShowWindow(launcher, SW_HIDE);
pump();
ShowWindow(launcher, SW_SHOWNOACTIVATE);
acknowledge(launcher);
focus(linuxWindow, linuxWindow);
const auto launcherXid = static_cast<xcb_window_t>(reinterpret_cast<uintptr_t>(
GetPropW(launcher, L"__wine_x11_whole_window")));
focus(launcherXid, linuxWindow);
ok &= check(!restore_virtual_desktop_focus(), "focused child requires window manager desktop ownership");
ShowWindow(other, SW_SHOWNOACTIVATE);
acknowledge(other);
focus(launcherXid, desktop);
ok &= check(!restore_virtual_desktop_focus(), "focused child does not bypass ambiguous applications");
ShowWindow(other, SW_HIDE);
const auto siblingXid = xcb_generate_id(connection);
xcb_create_window(connection, XCB_COPY_FROM_PARENT, siblingXid, desktop,
0, 0, 20, 20, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, 0, nullptr);
xcb_map_window(connection, siblingXid);
focus(siblingXid, desktop);
ok &= check(!restore_virtual_desktop_focus(), "unrelated desktop child is never redirected to launcher");
xcb_destroy_window(connection, siblingXid);
focus(launcherXid, desktop);
EnableWindow(launcher, FALSE);
ok &= check(!restore_virtual_desktop_focus(), "focused child does not bypass disabled application guard");
EnableWindow(launcher, TRUE);
ok &= check(!GetForegroundWindow(), "reproduce focused X11 child without Win32 foreground");
ok &= check(restore_virtual_desktop_focus(), "focused launcher child recovers foreground");
pump();
GetGUIThreadInfo(GetWindowThreadProcessId(launcher, nullptr), &gui);
ok &= check(GetForegroundWindow() == launcher && gui.hwndFocus == button,
"focused launcher child restores its control focus");
DestroyWindow(other);
PostMessageW(launcher, WM_CLOSE, 0, 0);
WaitForSingleObject(process.hProcess, 5000);