On Fri Feb 9 16:01:20 2024 +0000, Gabriel Ivăncescu wrote:
Yes, I tried WS_EX_NOACTIVATE but it doesn't work. It only prevents focus stealing from stuff like user input, not from APIs. I was surprised it sets focus too, but it seems it's by design. The `set_window_pos` in `NtUserSetParent` (line 475) doesn't have SWP_NOACTIVATE. Can you not reproduce it? I mean all you have to do is open a window in a virtual desktop, then launch an app in the same desktop that has a systray like a basic AutoHotkey script. It shouldn't steal focus, but it does. Here's an example of an AutoHotkey script to test this easily:
#NoEnv *$F12:: Sleep 1000 Reload return
Launch notepad in a virtual desktop, then launch the script with AutoHotkey. Focus notepad again. Then press F12. After 1 second Notepad will lose focus (because the ahk systray icon gets removed and re-added). BTW I've no idea what you mean with layered windows. I admit I don't understand this code, but what's the purpose of the `layered` flag? Because by default, the window is created with WS_EX_LAYERED but the layered flag is FALSE… To reproduce the second issue, just launch the virtual desktop with the AutoHotkey script above. You should not see the systray icon, although it is there (you can right click its location for example), the icon is just not visible.
Yeah sorry, I got confused by the Linux WM state which is still showing the window as active somehow (but indeed Wine then doesn't dispatch the input).