diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a9649c..043bf14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ commit-message convention that feeds this file. ### Fixed +- Keep maximized windows clear of the right stack panel while preserving + full-width Waybar, including after panel toggles and Waybar restarts. +- Give every bar module a black resting background and the same subtle hover + highlight, including power, clock and workspace buttons. + - **Silence stopped being indexed as content.** 150 of the 4 132 `telegram-voice` points were not speech: whisper answers a silent round video with `""`, one of its own labels (`[Music]`, `(footsteps)`), or a diff --git a/configs/niri/config.kdl b/configs/niri/config.kdl index 6e72342..f12fba4 100644 --- a/configs/niri/config.kdl +++ b/configs/niri/config.kdl @@ -60,7 +60,8 @@ layout { struts { left 0 - right 28 + // The stack panel reserves its own layer-shell exclusive zone. + right 0 top 0 bottom 0 } @@ -328,3 +329,6 @@ binds { Mod+Print { screenshot-screen write-to-disk=true; } Mod+Shift+Print { screenshot-window write-to-disk=true; } } + +// Preserve window rules supplied by the ASUS DialPad driver when installed. +include optional=true "../asus-dialpad-driver/niri-dialpad.kdl" diff --git a/configs/systemd/user/sy-stack-bar.service b/configs/systemd/user/sy-stack-bar.service index cf046c5..5d03ebd 100644 --- a/configs/systemd/user/sy-stack-bar.service +++ b/configs/systemd/user/sy-stack-bar.service @@ -33,17 +33,9 @@ Type=notify NotifyAccess=main WatchdogSec=300s TimeoutStartSec=300s -# Wait for waybar -# to register its top exclusive zone before our wlr-layer-shell -# surface attaches. Otherwise niri hasn't deducted waybar's 24-px -# strip yet, and the bar's `Right | Top | Bottom` anchor straddles -# the top edge — producing the "right panel disappeared" symptom -# (the bar is actually drawn beneath waybar). The pgrep loop -# mirrors what the legacy niri spawn-at-startup did before the bar -# was promoted to a unit; folding it into the unit lets us drop -# the niri-side spawn so there is exactly one owner with -# `Restart=on-failure` supervision. -ExecStartPre=/usr/bin/bash -c 'until pgrep -x waybar >/dev/null; do sleep 0.05; done; sleep 0.3' +# Wait for Waybar's layer surface, not merely its process. Mapping it +# first gives Waybar the full top edge before our right reservation. +ExecStartPre=/usr/bin/bash -c 'until niri msg --json layers | jq -e ".[] | select(.namespace == \\"top\\")" >/dev/null 2>&1; do sleep 0.05; done' ExecStart=%h/.local/bin/sy stack bar Restart=on-failure RestartSec=2s diff --git a/configs/systemd/user/sy-waybar.service b/configs/systemd/user/sy-waybar.service index 2766cb5..dfe1188 100644 --- a/configs/systemd/user/sy-waybar.service +++ b/configs/systemd/user/sy-waybar.service @@ -6,6 +6,10 @@ After=graphical-session.target [Service] Type=simple ExecStart=/usr/bin/waybar +# Re-map the right panel after every Waybar start, including crash recovery. +# Its exclusive zone must be registered after Waybar's full-width top zone. +# Do not wait here: the panel is ordered After=this service. +ExecStartPost=/usr/bin/systemctl --user --no-block try-restart sy-stack-bar.service Restart=on-failure RestartSec=2s diff --git a/configs/waybar/style.css b/configs/waybar/style.css index 2685258..da51839 100644 --- a/configs/waybar/style.css +++ b/configs/waybar/style.css @@ -26,7 +26,7 @@ } window#waybar { - background: @bg_soft; + background: @bg; color: @fg; border: none; } @@ -44,13 +44,11 @@ tooltip { #workspaces button { padding: 0 8px; color: @fg; - background: transparent; border-bottom: 2px solid transparent; transition: all 150ms ease; } #workspaces button:hover { - background: @bg1; color: @fg; box-shadow: none; text-shadow: none; @@ -63,8 +61,7 @@ tooltip { } #workspaces button.urgent { - color: @bg; - background: @red; + color: @red; border-bottom: 2px solid @red; } @@ -103,21 +100,16 @@ tooltip { color: @yellow; padding: 0 12px; margin-left: 8px; - background: @bg1; } -#network:hover, -#custom-agents:hover, -#custom-notif:hover, -#custom-bt:hover, -#custom-sy-gpu:hover, -#custom-sy-npu:hover, -#custom-sy-disk:hover, -#custom-sy-silent:hover, -#custom-sy-vol:hover, -#custom-sy-bl:hover, -#custom-sy-profile:hover, -#custom-sy-knowledge:hover { +/* Workspace buttons are controls; their parent is only a container. */ +.module:not(#workspaces), +#workspaces button { + background: @bg; +} + +.module:not(#workspaces):hover, +#workspaces button:hover { background: @bg1; } @@ -224,7 +216,6 @@ tooltip { color: @fg; padding: 0 12px; margin-right: 4px; - background: @bg1; } #cpu, @@ -245,7 +236,6 @@ tooltip { /* --- Bottom cheatsheet bar ---------------------------------------------- */ window#waybar.cheatsheet { - background: alpha(@bg_soft, 0.85); color: @fg_dim; border: none; border-top: 1px solid @bg1; diff --git a/crates/sy-desktop-shell/README.md b/crates/sy-desktop-shell/README.md index 494b887..d59b392 100644 --- a/crates/sy-desktop-shell/README.md +++ b/crates/sy-desktop-shell/README.md @@ -24,5 +24,18 @@ for the runtime session, including after a drop or clipboard-history refresh. The receiving application handles insertion, quoting, or attaching the file. Dragging uses copy semantics and retains the source item. +The panel reserves 28 logical pixels through layer-shell, so maximized windows +leave its controls visible. Hiding the panel releases that space. Waybar maps +first to keep the full top edge; its service remaps the panel after each restart. + +With the black theme, every bar module and workspace button is black at rest +and uses the same subtle hover highlight. Text and borders retain status colors. + +To check geometry without changing the live desktop, build the executable and +run `python3 scripts/check-stack-panel-layout.py` from the repository root. +This requires Niri, Waybar, Foot, Xvfb, jq and a systemd user manager. It starts +disposable services and a nested compositor, checks maximize, hide/show, +fullscreen and repeated Waybar restarts, then stops its test processes. + Verification: `cargo test -p sy-desktop-shell --all-targets` and `cargo clippy -p sy-desktop-shell --all-targets -- -D warnings`. diff --git a/crates/sy-desktop-shell/src/stack/bar/app.rs b/crates/sy-desktop-shell/src/stack/bar/app.rs index 7e1bc40..cec425c 100644 --- a/crates/sy-desktop-shell/src/stack/bar/app.rs +++ b/crates/sy-desktop-shell/src/stack/bar/app.rs @@ -53,9 +53,21 @@ use crate::stack::{ }; /// Width of the bar's vertical strip on the right edge. -/// Niri's right strut reserves this width for tiled windows. The surface -/// itself does not reserve a layer-shell zone, so Waybar spans the top edge. +/// A layer-shell exclusive zone protects this strip from tiled and +/// maximized-to-edges windows. Waybar must register before this surface. const BAR_WIDTH: u32 = 28; + +fn bar_settings(visible: bool) -> LayerShellSettings { + LayerShellSettings { + size: Some(if visible { (BAR_WIDTH, 0) } else { (1, 1) }), + exclusive_zone: if visible { BAR_WIDTH as i32 } else { 0 }, + anchor: Anchor::Right | Anchor::Top | Anchor::Bottom, + margin: (WAYBAR_TOP_MARGIN, 0, 0, 0), + layer: Layer::Top, + start_mode: StartMode::Active, + ..Default::default() + } +} /// Waybar's `"height"` from `configs/waybar/config.jsonc`. Used by /// the hover-preview surface to translate the bar-local cursor y /// back to screen-space (the bar's surface starts at y=24). @@ -80,6 +92,8 @@ const HOVER_POPUP_WIDTH: u32 = 320; /// Height of the hover preview popup. Sized to fit a 256×256 image /// thumbnail plus a 32-px header strip. const HOVER_POPUP_HEIGHT: u32 = 300; +/// Hover margins are screen coordinates, including the panel and Waybar offsets. +const HOVER_EXCLUSIVE_ZONE: i32 = -1; /// Edge length of the thumbnail rendered inside the hover popup /// (vs. the 20-px inline thumbnails on the bar itself). const HOVER_THUMB_PX: f32 = 256.0; @@ -362,21 +376,7 @@ pub fn run() -> anyhow::Result<()> { .subscription(subscription) .settings(Settings { with_connection: Some(connection.into()), - layer_settings: LayerShellSettings { - size: Some((BAR_WIDTH, 0)), - // Niri's right strut reserves tiled space. Reserving a - // layer-shell zone here would shorten Waybar at the top. - exclusive_zone: 0, - anchor: Anchor::Right | Anchor::Top | Anchor::Bottom, - // (top, right, bottom, left) per layershellev's - // `LayerSurface::set_margin` signature. - // `WAYBAR_TOP_MARGIN = 0` defers vertical positioning - // to niri's deduction of waybar's top exclusive zone. - margin: (WAYBAR_TOP_MARGIN, 0, 0, 0), - layer: Layer::Top, - start_mode: StartMode::Active, - ..Default::default() - }, + layer_settings: bar_settings(true), ..Default::default() }) .run() @@ -480,15 +480,12 @@ fn update(bar: &mut Bar, msg: Msg) -> Task { bar.visible = !bar.visible; // Resize the bar surface; note: needs the bar's Id. if let Some(bid) = bar.bar_id { - let (anchor, size, zone) = if bar.visible { - ( - Anchor::Right | Anchor::Top | Anchor::Bottom, - (BAR_WIDTH, 0), - 0, - ) - } else { - (Anchor::Right | Anchor::Top | Anchor::Bottom, (1, 1), 0) - }; + let settings = bar_settings(bar.visible); + let (anchor, size, zone) = ( + settings.anchor, + settings.size.unwrap(), + settings.exclusive_zone, + ); return Task::done(Msg::AnchorSizeChange { id: bid, anchor, @@ -710,7 +707,7 @@ fn update(bar: &mut Bar, msg: Msg) -> Task { size: Some((HOVER_POPUP_WIDTH, HOVER_POPUP_HEIGHT)), layer: Layer::Overlay, anchor: Anchor::Top | Anchor::Right, - exclusive_zone: Some(0), + exclusive_zone: Some(HOVER_EXCLUSIVE_ZONE), margin: Some((margin_top, BAR_WIDTH as i32 + 4, 0, 0)), keyboard_interactivity: KeyboardInteractivity::None, output_option: OutputOption::LastOutput, @@ -1434,6 +1431,22 @@ mod tests { } use std::path::PathBuf; + #[test] + fn visible_panel_reserves_its_width_for_maximized_windows() { + assert_eq!(bar_settings(true).exclusive_zone, BAR_WIDTH as i32); + } + + #[test] + fn hidden_panel_releases_its_reserved_space() { + assert_eq!(bar_settings(false).exclusive_zone, 0); + assert_eq!(bar_settings(false).size, Some((1, 1))); + } + + #[test] + fn hover_preview_does_not_count_panel_reservations_twice() { + assert_eq!(HOVER_EXCLUSIVE_ZONE, -1); + } + #[test] fn waybar_top_margin_does_not_double_count_niri_deduction() { // Niri deducts waybar's 24-px top exclusive zone from this diff --git a/crates/sy-desktop-shell/src/waybar.rs b/crates/sy-desktop-shell/src/waybar.rs index cedf151..060b9d7 100644 --- a/crates/sy-desktop-shell/src/waybar.rs +++ b/crates/sy-desktop-shell/src/waybar.rs @@ -24,17 +24,6 @@ pub fn reload() { .status(); if matches!(restart, Ok(status) if status.success()) { println!(" ↻ waybar restarted"); - let stack_active = Command::new("systemctl") - .args(["--user", "is-active", "--quiet", "sy-stack-bar.service"]) - .status(); - if matches!(stack_active, Ok(status) if status.success()) { - let stack_restart = Command::new("systemctl") - .args(["--user", "restart", "sy-stack-bar.service"]) - .status(); - if !matches!(stack_restart, Ok(status) if status.success()) { - eprintln!(" ! could not restart sy-stack-bar.service"); - } - } } else { eprintln!(" ! could not restart sy-waybar.service"); } diff --git a/llms-full.txt b/llms-full.txt index 62a922b..5cc7e9c 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -5996,6 +5996,11 @@ commit-message convention that feeds this file. #### Fixed +- Keep maximized windows clear of the right stack panel while preserving + full-width Waybar, including after panel toggles and Waybar restarts. +- Give every bar module a black resting background and the same subtle hover + highlight, including power, clock and workspace buttons. + - **Silence stopped being indexed as content.** 150 of the 4 132 `telegram-voice` points were not speech: whisper answers a silent round video with `""`, one of its own labels (`[Music]`, `(footsteps)`), or a diff --git a/packaging/sy.spec b/packaging/sy.spec index 5543488..fd67037 100644 --- a/packaging/sy.spec +++ b/packaging/sy.spec @@ -30,7 +30,8 @@ Requires: sy = %{version}-%{release} Requires: sy-desktop-shell = %{version}-%{release} Requires: fuzzel Requires: foot -Requires: niri +Requires: niri >= 26.04 +Requires: jq Requires: swaylock Requires: waybar Requires: python3 diff --git a/scripts/check-stack-panel-layout.py b/scripts/check-stack-panel-layout.py new file mode 100644 index 0000000..98ebc8e --- /dev/null +++ b/scripts/check-stack-panel-layout.py @@ -0,0 +1,183 @@ +#!/usr/bin/env python3 +"""Exercise the real panel in disposable Niri, Xvfb and systemd user units.""" + +import argparse +import json +import os +from pathlib import Path +import re +import select +import subprocess +import tempfile +import time + +REPO = Path(__file__).resolve().parent.parent +PANEL_WIDTH = 28 +TOP_HEIGHT = 24 + + +def wait_for(check): + deadline = time.monotonic() + 15 + while time.monotonic() < deadline: + result = check() + if result: + return result + time.sleep(0.05) + raise AssertionError("timed out waiting for desktop geometry") + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--binary", type=Path, default=REPO / "target/debug/sy-desktop-shell") + parser.add_argument("--scale", type=int, choices=(1, 2), default=2) + args = parser.parse_args() + root = Path(tempfile.mkdtemp(prefix="sy-panel-layout-")) + print(f"Logs: {root}", flush=True) + env = os.environ.copy() + for key in ("WAYLAND_DISPLAY", "WAYLAND_SOCKET", "NIRI_SOCKET", "NOTIFY_SOCKET", + "WATCHDOG_USEC", "WATCHDOG_PID"): + env.pop(key, None) + for suffix in ("RUNTIME_DIR", "CONFIG_HOME", "STATE_HOME", "DATA_HOME", "CACHE_HOME"): + path = root / suffix.lower() + path.mkdir(mode=0o700) + env[f"XDG_{suffix}"] = str(path) + env["GDK_BACKEND"] = "wayland" + children, units = [], [] + prefix = f"sy-panel-layout-{os.getpid()}" + waybar_unit, panel_unit = f"{prefix}-waybar", f"{prefix}-stack" + + def spawn(command, **kwargs): + with (root / f"{Path(command[0]).name}.log").open("a") as log: + process = subprocess.Popen(command, env=env, stdout=log, stderr=log, **kwargs) + children.append(process) + return process + + def msg(*command): + return json.loads(subprocess.check_output( + ["niri", "msg", "--json", *command], env=env, timeout=5)) + + def action(name, window_id): + subprocess.run(["niri", "msg", "action", name, "--id", str(window_id)], + env=env, check=True, timeout=5, stdout=subprocess.DEVNULL) + + def start_unit(name, command, properties): + units.append(name) + options = ["systemd-run", "--user", "--quiet", "--collect", "--no-block", f"--unit={name}"] + bus = os.environ.get("DBUS_SESSION_BUS_ADDRESS", f"unix:path=/run/user/{os.getuid()}/bus") + options.append(f"--setenv=DBUS_SESSION_BUS_ADDRESS={bus}") + for key, value in env.items(): + if key.startswith("XDG_") or key in ("DISPLAY", "WAYLAND_DISPLAY", "NIRI_SOCKET", "GDK_BACKEND"): + options.append(f"--setenv={key}={value}") + properties += [f"StandardOutput=append:{root / (name + '.log')}", "StandardError=inherit"] + subprocess.run(options + [f"--property={p}" for p in properties] + command, + check=True, timeout=20) + + def panel_present(): + return any(layer["namespace"] == "sy-stack" for layer in msg("layers")) + + try: + read_fd, write_fd = os.pipe() + try: + spawn(["Xvfb", "-displayfd", str(write_fd), "-screen", "0", "1920x1200x24", + "-nolisten", "tcp"], pass_fds=(write_fd,)) + os.close(write_fd) + if not select.select([read_fd], [], [], 15)[0]: + raise AssertionError("Xvfb did not start") + display = os.read(read_fd, 100).decode().strip() + assert display, "Xvfb failed to allocate a display" + env["DISPLAY"] = f":{display}" + finally: + os.close(read_fd) + template = (REPO / "configs/niri/config.kdl").read_text() + struts = re.search(r"struts\s*\{([^}]+)\}", template).group(1) + config = root / "niri.kdl" + config.write_text(f"layout {{ gaps 0; struts {{ {struts} }}; }}\n" + "hotkey-overlay { skip-at-startup; }\n" + f'output "winit" {{ scale {args.scale}; }}\n') + spawn(["niri", "-c", str(config)]) + runtime = Path(env["XDG_RUNTIME_DIR"]) + # systemctl uses the user manager's private socket under XDG_RUNTIME_DIR. + (runtime / "systemd").symlink_to(Path(os.environ["XDG_RUNTIME_DIR"]) / "systemd") + socket = wait_for(lambda: next(runtime.glob("niri.*.sock"), None)) + env["NIRI_SOCKET"] = str(socket) + env["WAYLAND_DISPLAY"] = socket.name.split(".")[1] + width = next(iter(msg("outputs").values()))["logical"]["width"] + css = root / "waybar.css" + css.write_text("* { font-size: 10px; min-height: 0; }") + config = root / "waybar.json" + config.write_text(json.dumps({"name": "top", "layer": "top", "position": "top", + "height": TOP_HEIGHT, "modules-left": ["clock"]})) + waybar_source = (REPO / "configs/systemd/user/sy-waybar.service").read_text() + post = next(line.split("=", 1)[1] for line in waybar_source.splitlines() + if line.startswith("ExecStartPost=")) + post = post.replace("sy-stack-bar.service", panel_unit + ".service") + panel_source = (REPO / "configs/systemd/user/sy-stack-bar.service").read_text() + pre = next(line.split("=", 1)[1] for line in panel_source.splitlines() + if line.startswith("ExecStartPre=")) + start_unit(panel_unit, [str(args.binary.resolve()), "stack", "bar"], + [f"ExecStartPre={pre}", f"After={waybar_unit}.service", "TimeoutStartSec=15s", "Type=notify"]) + start_unit(waybar_unit, ["/usr/bin/waybar", "-c", str(config), "-s", str(css)], + [f"ExecStartPost={post}"]) + wait_for(panel_present) + wait_for(lambda: subprocess.run(["systemctl", "--user", "is-active", "--quiet", panel_unit]).returncode == 0) + spawn(["foot", "--app-id=sy-panel-test", "sleep", "600"]) + window = wait_for(lambda: next((w for w in msg("windows") + if w["app_id"] == "sy-panel-test"), None)) + window_id = window["id"] + + def window_layout(): + return next(w for w in msg("windows") if w["id"] == window_id)["layout"] + + def window_width(): + return window_layout()["window_size"][0] + + action("focus-window", window_id) + subprocess.run(["niri", "msg", "action", "maximize-column"], env=env, + check=True, timeout=5, stdout=subprocess.DEVNULL) + # Foot may round a regular tiled window down to whole terminal cells. + wait_for(lambda: (width - PANEL_WIDTH) / 2 < window_layout()["tile_size"][0] + <= width - PANEL_WIDTH) + action("maximize-window-to-edges", window_id) + wait_for(lambda: window_width() == width - PANEL_WIDTH) + print(f"Maximized: {width - PANEL_WIDTH}/{width} pixels", flush=True) + for expected in (width, width - PANEL_WIDTH): + subprocess.run([str(args.binary.resolve()), "stack", "toggle"], + env=env, check=True, timeout=5, stdout=subprocess.DEVNULL) + wait_for(lambda: window_width() == expected) + print("Hide/show: reservation released and restored", flush=True) + action("fullscreen-window", window_id) + wait_for(lambda: window_width() == width) + action("fullscreen-window", window_id) + wait_for(lambda: window_width() == width - PANEL_WIDTH) + def panel_pid(): + return subprocess.check_output( + ["systemctl", "--user", "show", "-p", "MainPID", "--value", panel_unit], + text=True, timeout=5).strip() + + for _ in range(2): + previous_pid = panel_pid() + log = root / f"{waybar_unit}.log" + log_offset = log.stat().st_size + subprocess.run(["systemctl", "--user", "restart", waybar_unit], check=True, timeout=20) + wait_for(lambda: panel_pid() not in ("0", previous_pid)) + wait_for(panel_present) + wait_for(lambda: window_width() == width - PANEL_WIDTH) + wait_for(lambda: re.findall(r"Bar configured \(width: (\d+), height: (\d+)\)", + log.read_text()[log_offset:])[-1:] + == [(str(width), str(TOP_HEIGHT))]) + print("Fullscreen and repeated Waybar restart: passed", flush=True) + finally: + for unit in reversed(units): + subprocess.run(["systemctl", "--user", "stop", unit], check=False, timeout=20, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + for child in reversed(children): + child.terminate() + try: + child.wait(timeout=5) + except subprocess.TimeoutExpired: + child.kill() + child.wait() + + +if __name__ == "__main__": + main() diff --git a/specs/bugs/BUG-20261101-0511.md b/specs/bugs/BUG-20261101-0511.md new file mode 100644 index 0000000..63652b8 --- /dev/null +++ b/specs/bugs/BUG-20261101-0511.md @@ -0,0 +1,96 @@ +# BUG-20261101-0511: Maximized windows extend behind the right panel + +## Summary + +The right stack panel reserves space for ordinary tiled windows but does not +reserve space for windows maximized to edges. + +## Reproduction + +- Method: live desktop inspection and the user's screenshot. +- Environment: Niri 26.04, eDP-1, 3840 × 2400 physical pixels at scale 2; + logical size 1920 × 1200. +- Commands: `niri msg --json outputs`, `niri msg --json windows`, + `niri msg windows`, and `niri msg layers`. +- Evidence: Firefox window 19 (`org.mozilla.firefox`) has tile and window + size 1920 × 1176 with offset 0 × 0. Ordinary full-width terminal tiles + measure 1892 × 1176, with windows 1890 × 1174 and offset 1 × 1. +- The 1176-pixel height leaves Waybar's 24-pixel top reservation intact; + the browser consumes the right panel's 28-pixel strip. +- Both `sy-stack` and Waybar namespace `top` are on the Top layer. + +## Expected + +Ordinary and maximized windows leave the visible right panel unobstructed. +Waybar continues to span the full top edge. Fullscreen behavior remains a +separate compositor state. + +## Actual + +The browser extends underneath the panel, hiding its rightmost controls and +content. Ordinary tiled terminals leave the panel's strip clear. + +## Root Cause + +Before the fix, `configs/niri/config.kdl` reserved `right 28` through layout +struts, while `crates/sy-desktop-shell/src/stack/bar/app.rs` set `exclusive_zone: 0` +both at startup and when showing the panel again. + +Niri's maximize-to-edges mode deliberately ignores layout struts, gaps and +borders, while respecting layer-shell exclusive zones. Firefox's measured +geometry matches that mode; the inspected IPC window record does not expose +an explicit maximized-state flag. This explains the difference from the +ordinary full-width terminal columns. + +Upstream references: + +- [Niri fullscreen and maximize](https://niri-wm.github.io/niri/Fullscreen-and-Maximize.html) +- [Niri 26.04 layout source](https://github.com/niri-wm/niri/blob/v26.04/src/layout/scrolling.rs) + +The zero exclusive zone was deliberate in +[BUG-20261017-2340](BUG-20261017-2340.md): a positive right reservation +previously shortened Waybar. Replacing that reservation with a strut fixed +the top-bar geometry but left maximized windows unprotected. + +## Fix + +The panel now reserves its 28 logical pixels with a layer-shell exclusive zone +at startup and when shown. Hiding it releases the zone. The Niri right strut +is zero, avoiding double reservation. Hover previews ignore exclusive zones +because their existing margins already include the panel and Waybar offsets. + +The stack service waits for Waybar's actual `top` layer surface via Niri IPC +and jq, replacing the process check and arbitrary delay. Every Waybar service +start asynchronously remaps an active stack panel, including crash recovery. +This ensures Waybar registers its full-width top reservation first. The +asynchronous request avoids waiting on a panel ordered after Waybar. +The apply path delegates panel remapping to that service hook instead of +restarting it twice. The desktop RPM declares the jq dependency. + +## Traceability + +- Manual evidence: supplied screenshot and live Niri IPC geometry above. +- Failing unit test: `visible_panel_reserves_its_width_for_maximized_windows` + reported actual zone 0, expected 28 before the fix. +- Regression coverage: `crates/sy-desktop-shell/src/stack/bar/app.rs` unit tests + and `tests/stack_panel_layout.rs` cover reservations and service ordering. +- End-to-end recipe: build `sy-desktop-shell`, then run + `python3 scripts/check-stack-panel-layout.py` from the repository root. + It uses real Niri, Waybar, Foot and panel processes in Xvfb and disposable + user services; the live desktop is untouched. It checks tiled-column and + maximize-to-edges geometry, hide/show, fullscreen, full-width Waybar and + panel remapping after two Waybar restarts. `--scale 1` checks unscaled output; + the default is scale 2, matching the reported host. +- Negative end-to-end control: running the recipe with + `--binary /usr/libexec/sy/sy-desktop-shell` against the installed older binary + failed the expected maximized-width check. +- Fixed files: `configs/niri/config.kdl`, both panel user units, + `crates/sy-desktop-shell/src/{stack/bar/app.rs,waybar.rs}`, and + `packaging/sy.spec`. Usage and verification are documented in the shell README. +- Gates: `make lint`, `make test`, `make lint-spark`, and `make test-spark` + passed after the implementation changes. The end-to-end recipe passed at + scale 2 (612/640 logical pixels) and scale 1 (1252/1280), including repeated + Waybar restarts and full-width Waybar in both cases. +- Activation requires installing the updated desktop RPMs and applying the + managed desktop configuration. Live verification measured Firefox at + 1892 × 1176 logical pixels while Waybar retained its full 1920-pixel width. diff --git a/specs/bugs/BUG-20261101-1515.md b/specs/bugs/BUG-20261101-1515.md new file mode 100644 index 0000000..4acc3bf --- /dev/null +++ b/specs/bugs/BUG-20261101-1515.md @@ -0,0 +1,57 @@ +# BUG-20261101-1515: Inconsistent Waybar backgrounds and hover feedback + +## Summary + +Top-bar modules should have black backgrounds at rest and the same slightly +brighter background on hover, including power, clock and workspace buttons. + +## Reproduction + +- Move the pointer away from the power button and clock: both retain a brighter + background. Hover CPU, memory, battery or authentication: they lack the shared + highlight used by network and other controls. +- The supplied screenshot shows the permanent power-button background. +- Render `waybar/style.css` with sy and inspect it through GTK 3: power and + clock retain `@bg1` in the normal state. An isolated GTK check across configured + modules and their status classes found 108 inconsistent normal/hover colors. + +## Expected + +Every module and individual workspace button uses the theme's black background +at rest and `@bg1` on hover. Focus, active and urgent states do not introduce +different backgrounds. Status foreground colors remain useful. + +## Actual + +Power and clock are permanently bright, some modules never highlight, and +urgent workspace buttons use a red background. + +## Root Cause + +`configs/waybar/style.css` mixes permanent per-ID backgrounds with an incomplete +list of hover selectors. The bar's base background is also lighter than black. + +## Fix + +Use shared module and workspace-button background rules. The workspace module +is a container: highlight each workspace button rather than the entire group. +Remove permanent power/clock backgrounds and the urgent workspace fill; retain +urgent foreground and border indicators. Apply the same base to the legacy +cheatsheet bar. + +## Traceability + +- Source: `configs/waybar/style.css`. +- Verification: load sy's rendered CSS in GTK 3 and check normal and prelight + colors for every module listed in the top-bar configuration, each declared + status class, and normal/active/focused/urgent workspace buttons. +- Live check: move the pointer over and away from power, clock, workspace, + CPU, memory, battery and authentication; backgrounds must follow the same rule. + +## Verification + +The GTK 3 color check passed across configured modules and status classes: +normal backgrounds are `#000000`, and prelight backgrounds are `#161616` +under the black theme. Workspace checks include normal, active, focused and +urgent button classes. A live capture confirms black resting backgrounds +for power and clock. Lint, workspace tests and Spark bridge checks passed. diff --git a/tests/stack_panel_layout.rs b/tests/stack_panel_layout.rs new file mode 100644 index 0000000..c060f79 --- /dev/null +++ b/tests/stack_panel_layout.rs @@ -0,0 +1,35 @@ +//! The panel owns its reservation; Waybar must map before it on every start. + +#[test] +fn panel_reservation_is_not_duplicated_by_a_niri_strut() { + let config = include_str!("../configs/niri/config.kdl"); + let struts = config + .split("struts {") + .nth(1) + .unwrap() + .split('}') + .next() + .unwrap(); + assert!(struts.lines().any(|line| line.trim() == "right 0")); +} + +#[test] +fn waybar_restarts_reorder_the_stack_panel() { + let unit = include_str!("../configs/systemd/user/sy-waybar.service"); + assert!(unit.contains( + "ExecStartPost=/usr/bin/systemctl --user --no-block try-restart sy-stack-bar.service" + )); +} + +#[test] +fn stack_waits_for_waybars_surface_instead_of_a_startup_delay() { + let unit = include_str!("../configs/systemd/user/sy-stack-bar.service"); + assert!(unit.contains("niri msg --json layers")); + assert!(!unit.contains("pgrep")); +} + +#[test] +fn panel_apply_preserves_optional_dialpad_window_rules() { + let config = include_str!("../configs/niri/config.kdl"); + assert!(config.contains("include optional=true \"../asus-dialpad-driver/niri-dialpad.kdl\"")); +}