Skip to content

feat(wlr/taskbar): expose active toplevel state on the bar window#5126

Open
iamcheyan wants to merge 1 commit into
Alexays:masterfrom
iamcheyan:feat/wlr-taskbar-bar-css-states
Open

feat(wlr/taskbar): expose active toplevel state on the bar window#5126
iamcheyan wants to merge 1 commit into
Alexays:masterfrom
iamcheyan:feat/wlr-taskbar-bar-css-states

Conversation

@iamcheyan

Copy link
Copy Markdown

Description

Add an opt-in bar-css-states option to the wlr/taskbar module that exposes window state as CSS classes on the Waybar window (window#waybar).

When enabled, the module tracks the active workspace and updates these CSS classes:

  • toplevel-active: when a window is focused
  • toplevel-maximized: when any non-minimized window on the active workspace is maximized
  • toplevel-minimized: when the active window is minimized
  • toplevel-fullscreen: when any non-minimized window on the active workspace is fullscreen

Motivation

Compositor-specific window modules like sway/window and hyprland/window can add state classes to window#waybar, but generic wlroots compositors such as labwc lack an equivalent. This prevents users from styling the whole bar based on the active window state (e.g., making the bar fully opaque when a window is maximized).

This feature bridges that gap for all wlroots compositors using the standard wlr-foreign-toplevel-management protocol.

Design

  • The toplevel- prefix avoids collisions with classes managed by existing compositor-specific modules
  • toplevel-active and toplevel-minimized describe the active task
  • toplevel-maximized and toplevel-fullscreen are aggregated across all non-minimized tasks on the active workspace
  • Task-to-workspace membership is learned when a task becomes active via ext-workspace-v1 protocol
  • Falls back to active task state only if ext-workspace-v1 is unavailable
  • Defaults to false for backward compatibility

Changes

  • Add ext-workspace-v1 protocol support for workspace tracking
  • Implement WorkspaceState tracking in Taskbar class
  • Add workspace management lifecycle (create/remove/done)
  • Add bar CSS class update logic with state aggregation
  • Add visible() getter to Task class
  • Implement active-only task visibility control (included in this PR)
  • Update man page with documentation and CSS examples

Configuration

"wlr/taskbar": {
    "bar-css-states": true,
    "format": "{icon} {title}"
}
window#waybar {
    background-color: rgba(0, 0, 0, 0.45);
}

window#waybar.toplevel-maximized,
window#waybar.toplevel-fullscreen {
    background-color: rgba(0, 0, 0, 1);
}

Testing

Environment:

  • Fedora 43
  • GCC 15.2.1
  • Meson 1.8.5
  • labwc compositor

Verification:

  • Built with meson setup -Dman-pages=enabled -Dcpp_std=c++20 build
  • All test suites pass
  • Clang-format and whitespace checks pass
  • Runtime validation:
    • Starting Waybar with active window adds toplevel-active
    • Maximizing active window immediately adds toplevel-maximized
    • Focusing another window on same workspace keeps toplevel-maximized
    • Restoring window immediately removes toplevel-maximized
    • Stopping Waybar removes remaining state classes during teardown

Notes

This PR includes the active-only feature from PR #5125 as both features modify similar code paths. If preferred, I can separate them.

Signed-off-by: iamcheyan iamcheyan@users.noreply.github.com

Add opt-in bar-css-states option to wlr/taskbar module.

When enabled, the module tracks the active workspace and updates CSS
classes on window#waybar to reflect the current window state:
- toplevel-active: when a window is focused
- toplevel-maximized: when any non-minimized window on active workspace is maximized
- toplevel-minimized: when the active window is minimized
- toplevel-fullscreen: when any non-minimized window on active workspace is fullscreen

This feature requires compositor support for ext-workspace-v1 protocol
to correctly track workspace membership. Without it, classes fall back
to the active application state only.

Also includes active-only option implementation.

Changes:
- Add ext-workspace-v1 protocol support for workspace tracking
- Implement WorkspaceState tracking in Taskbar class
- Add workspace management lifecycle (create/remove/done)
- Add bar CSS class update logic with aggregation
- Add visible() getter to Task class
- Implement active-only task visibility control
- Update man page with documentation and CSS examples

Signed-off-by: iamcheyan <iamcheyan@users.noreply.github.com>
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.

1 participant