fix: prevent WM-managed windows from being embedded during tray restart recovery#59
Draft
fix: prevent WM-managed windows from being embedded during tray restart recovery#59
Conversation
When stalonetray is restarted, applications previously in the system tray should re-dock by responding to the MANAGER broadcast. However, some apps miss this broadcast (race conditions, implementation bugs, etc.), leaving the tray empty after restart. Add find_unmanaged_icons() which scans all top-level windows at startup for _XEMBED_INFO property. Any such window is an XEMBED client that wants to be embedded; passing it to add_icon() recovers icons that failed to re-request docking. This mirrors the existing find_unmanaged_chromium_icons() approach. The function is called in tray_main() after xembed_init() (which initialises xa_xembed_info), right after the Chromium-specific scan. Co-authored-by: d3adb5 <8827351+d3adb5@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix stalonetray app visibility after restart
Recover tray icons with _XEMBED_INFO on startup to fix missing icons after restart
Mar 8, 2026
The previous implementation scanned ALL top-level windows for _XEMBED_INFO with no filtering, causing blank icons to appear from GTK plug windows, browser XEMBED clients, and other WM-managed windows that carry the property. Two filters are now applied, mirroring the logic in kde_tray_init(): 1. old_selection_owner != None guard: skip the scan entirely on a fresh start. Tray clients respond to the MANAGER broadcast on their own; the recovery scan is only needed when restarting over an existing session. 2. _NET_CLIENT_LIST exclusion: fetch the list of WM-managed windows and skip any window present in it. System tray icons are not managed by the WM and therefore never appear in _NET_CLIENT_LIST, while the spurious windows that caused blank icons do. Co-authored-by: d3adb5 <8827351+d3adb5@users.noreply.github.com>
Copilot
AI
changed the title
Recover tray icons with _XEMBED_INFO on startup to fix missing icons after restart
Recover unembedded tray icons on restart without false positives
Mar 8, 2026
…d on restart The _NET_CLIENT_LIST filter silently did nothing on WMs that don't maintain that root property (non-EWMH tiling WMs, etc.): XInternAtom(..., True) returns None when the atom was never interned, nclient_wins stays 0, and every window with _XEMBED_INFO — including fullscreen app windows — passed through and was embedded as a blank tray icon. Add an ICCCM WM_STATE check as an additional guard. Every ICCCM-compliant WM sets WM_STATE to NormalState (1) or IconicState (3) on every window it manages. System tray icons must be in WithdrawnState (0) and are not managed by the WM. If WM_STATE is absent the window is also unmanaged. This check works with all WMs, including non-EWMH tiling WMs (i3, bspwm, sway, etc.), and acts as the primary gate. _NET_CLIENT_LIST is retained as a supplementary EWMH filter. Co-authored-by: d3adb5 <8827351+d3adb5@users.noreply.github.com>
Copilot
AI
changed the title
Recover unembedded tray icons on restart without false positives
fix: prevent WM-managed windows from being embedded during tray restart recovery
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
find_unmanaged_icons()was embedding regular application windows (including fullscreen ones) as blank tray icons on restart. The_NET_CLIENT_LISTfilter silently became a no-op on any WM that doesn't maintain that property —XInternAtom(..., True)returnsNone, the fetch is skipped,nclient_winsstays 0, and every window with_XEMBED_INFOpasses through unchecked.Changes
WM_STATEfilter (primary gate): Skip any window whoseWM_STATEisNormalState(1) orIconicState(3). Per the system tray protocol, tray icons must be inWithdrawnState(0) and are never managed by the WM. This works universally — EWMH and non-EWMH WMs alike (i3, bspwm, sway, openbox, etc.)._NET_CLIENT_LISTfilter (supplementary): Still useful as a secondary guard on EWMH-compliant WMs; now clearly documented as such rather than the sole line of defence.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.