-- v2: explorer: Prevent apps from showing Wine specific shell tray window with no icons.
From: Paul Gofman pgofman@codeweavers.com
--- programs/explorer/systray.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index 9ae7e1698c9..ae0d66b2901 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -1110,6 +1110,18 @@ static LRESULT WINAPI shell_traywnd_proc( HWND hwnd, UINT msg, WPARAM wparam, LP else do_show_systray(); break;
+ case WM_WINDOWPOSCHANGING: + { + WINDOWPOS *p = (WINDOWPOS *)lparam; + + if (p->flags & SWP_SHOWWINDOW && (!show_systray || (!nb_displayed && !enable_taskbar))) + { + TRACE( "WM_WINDOWPOSCHANGING clearing SWP_SHOWWINDOW.\n" ); + p->flags &= ~SWP_SHOWWINDOW; + } + break; + } + case WM_MOVE: update_systray_balloon_position(); break;
It seems a bit brittle to make these changes only if there's no systray icons. The problem will be back whenever there is one for whatever reason (AutoHotkey, Steam, or any other application).
What about using NOACTIVATE instead, possibly unconditionally like we do already for icon windows. The systray should also perhaps be created with WS_EX_NOACTIVATE, I don't know exactly what difference it makes but the taskbar tray has it.
Note that it possibly won't solve the issue, I don't think we handle NOACTIVATE very well at the moment (ie: it might get focused nonetheless because mapped windows get focused by default), or maybe at least it will help when WM_TAKE_FOCUS is used.
WRT WS_EX_NOACTIVATE, there is your patch in Proton currently which does that, it helps this very game with Gamescope (because it won't show a window with WS_EX_NOACTIVATE) but doesn't help on KDE / Gnome. Input focus is only part of the issue, if the window is getting shown on top when made visible (which is probably designed behaviour of this systray window) even without input that still breaks things here.
I know this is not a complete solution, but maybe we may have it to fix at least some cases? Not sure how that can be solved in general without getting rid of this systray popup entirely which would probably be not great as otherwise it is useful.
If the problem isn't about focus but about z-order, you should probably just set the SWP_NOZORDER flag instead. Probably unconditionally, I don't think we really want the systray to brought to the front in any case.
Unfortunately it doesn't seem to work this way. SWP_NOZORDER is already set when showing the window in SetWindowPos, but clearing it instead and setting hwndInsertAfter to HWND_BOTTOM doesn't change anything. I am not sure if we have any good way to make a displayed window go to bottom at least on x11. It could in theory be done with setting stack mode to Below but it is intentionally avoided in winex11.drv in sync_window_position(): ``` /* should use stack_mode Below but most window managers don't get it right */ ```
Do you maybe have some way of sending it to back in mind which I am missing?
I don't have a precise way do to that, but it still looks like something to fix in winex11 if it doesn't work, rather than in explorer.exe. Using SWP_NOZORDER on windows is enough to make sure the window isn't raised.
There are ways with X11 to map a window without activating (EWMH documents how _NET_WM_USER_TIME should be set to 0 prior to mapping it), and perhaps without raising it, or some other way to restack the windows correctly, we should use them.
Of course, this is the long way because of how bad winex11 still is at keeping states consistent with the client/host but hopefully that can be improved.
I still think this isn't the right change to prevent the systray window from stealing focus and other fixes are required for that, but I'm approving this nonetheless as it fixes https://bugs.winehq.org/show_bug.cgi?id=56056.
IrfanView calls ShowWindow( tray_window, SW_SHOW ) when exiting fullscreen view. The systray window should stay hidden if it doesn't have any icons, even when the application tries to explicitly show it.
This merge request was approved by Rémi Bernon.
Yes, there can be more lower level things involved here, it is just that this whole systray window (in the "no-toolbar" mode at least) is Wine specific and is already a workaround, based on that I thought we might do a bit of voluntary handling to fix a regression from its changes.