On 04/01/2022 15:53, Stefan Dösinger wrote:
Am Montag, 3. Jänner 2022, 15:08:07 CET schrieb Gabriel Ivăncescu:
- ret = SetForegroundWindow(GetDesktopWindow());
- ok(ret, "Failed to set foreground window.\n");
- device_desc.device_window = device_window;
- device_desc.flags = CREATE_DEVICE_FULLSCREEN;
- device = create_device(d3d8, focus_window, &device_desc);
- ok(!!device, "Failed to create a D3D device.\n");
- ShowWindow(device_window, SW_SHOWNOACTIVATE);
- /* 32-bit tests ran under Windows 8 and 10 testbots have pretty
inconsistent behavior but topmost is set even when inactive. */
- style = GetWindowLongA(device_window, GWL_EXSTYLE);
Is it a matter of the active window, foreground window or the current thread being foreground? The active Window (Get/SetActiveWindow) is a per-thread property and the foreground window the desktop-global properly. Afaiu a window can be active for the current thread without being the foreground window.
One way to test this would be to create a third window on the same thread and make it the foreground window instead of the desktop window. I don't remember exactly what happens when you call SetForegroundWindow(desktop); SetActiveWindow(device_window). I assume it makes the test behave differently, which is why you use SW_SHOWNOACTIVATE.
If what I wrote is complete junk ignore me. It's been a few years since I worked on the alt-tab stuff...
I see what you mean, I'll have to test it. The reason I do ShowWindow(device_window, SW_SHOWNOACTIVATE) though is because on some Windows versions it seems to have it minimized when created inactive—I don't think it's worth replicating this though.