On Fri Feb 9 16:01:21 2024 +0000, Rémi Bernon wrote:
I find a bit surprising that changing a window parent would activate it (actually, activate its parent?). There was a discussion elsewhere, about whether the standalone systray window should be created with WS_EX_NOACTIVATE, to avoid it stealing focus (although I believe winex11 has trouble handling NOACTIVATE anyway), would that be enough? Maybe it should be the same for the icons? Do you have a specific scenario where this happens? Is this with the taskbar or with the standalone systray? Regarding the layered windows, I think it should be able to draw layered windows regardless of whether they are in the host dock or not?
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.