Skip to content

fix(tray): hide module when no items are visible#5028

Open
JeremieRodon wants to merge 1 commit into
Alexays:masterfrom
JeremieRodon:fix/tray-hide-when-empty
Open

fix(tray): hide module when no items are visible#5028
JeremieRodon wants to merge 1 commit into
Alexays:masterfrom
JeremieRodon:fix/tray-hide-when-empty

Conversation

@JeremieRodon
Copy link
Copy Markdown

@JeremieRodon JeremieRodon commented May 11, 2026

Problem

When all tray items are in the Passive state, the tray module remains visible as an empty placeholder, taking up space in the bar. See #3721 for one user-visible manifestation.

Root cause

Tray::update() already walked the children and hid the whole module if none should be shown. But update() only ran on construction and in onAdd / onRemove. Item::setStatus toggles the item's own event_box visibility on every Status property change but never notified the Tray, so module visibility was never re-evaluated on an ActivePassive transition.

Fix

Connect each item's Gtk::EventBox::signal_show and signal_hide in Tray::onAdd so dp.emit() fires on every visibility transition. The connections die with the item's widget — no explicit teardown needed.

Simplify Tray::update() to a single std::any_of over child->get_visible(). The previous predicate checked the passive CSS class as a proxy for visibility, which duplicated state already encoded in the widget itself.

Remove Tray::show_passive_ and its config read: Item already reads show-passive-items and applies it when deciding its own visibility, so the Tray-level copy was redundant. The behavior of show-passive-items is unchanged. The .passive CSS selector documented in waybar-tray.5 is still set by Item::setStatus and continues to work for styling.

Fixes #3721

Tray::update() already had logic to hide the module when all child items were passive, but it was only re-run on item add/remove — never on a status change. When the last visible item transitioned to Passive, the item hid itself but the now-empty module remained visible.

Connect Tray to each item's Gtk::EventBox signal_show/signal_hide so update() runs on every visibility transition, and simplify update() to check child->get_visible() directly instead of inspecting the `passive` CSS class. The Tray-level `show-passive-items` read becomes redundant since Item already honours it when deciding its own visibility; remove it along with the now-unused Tray::show_passive_ member.

Fixes: Alexays#3721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hide tray icon when empty

1 participant