Repository navigation
sidebar: Fix window controls shifting when the sidebar is open - #64381
smitbarmase merged 4 commits into
Conversation
With client-side decorations on Linux, the title bar insets its content by 1px on every side via a self-colored border. The sidebar header rendered the same window controls without that inset, so the close button shifted 1px up and outward whenever the sidebar was opened. Mirror the title bar's inset in the sidebar header for client-side decorations so the controls land on the same pixel in both states. Fixes zed-industries#63954
|
I noticed that the corner of the window moves, too, but maybe you've already noticed that? |
hey actually I checked your issue , and then reproduce and raised the pr |
smitbarmase
left a comment
There was a problem hiding this comment.
Thanks! Upon testing this, I noticed the window controls were still shifting by a pixel when switching to the threads archive view, so I applied the same fix there as well.
I also moved the insets into an apply_title_bar_insets helper so all the headers stay in sync with the title bar.
Thanks again.
thanks |
…ndustries#64381) ## Objective Fixes zed-industries#63954 On Linux with client-side decorations, the window controls (close / minimize / maximize) move 1px up and outward when the agent sidebar is opened, and move back when it is closed. ## Solution The title bar draws a 1px border in its own color to cover the window border at the rounded corners, so the controls it renders sit 1px in from the edge. When the sidebar is open, `Sidebar::render_sidebar_header` renders the same controls without that inset. Added the matching 1px padding to the sidebar header under `Decorations::Client`: top always, bottom only when no project is open (otherwise the header's bottom border already accounts for it), and left/right only on the side that renders the controls. ## Testing Compared the close button position with the sidebar closed and open, on stable 1.20.2 and on this branch, in a floating and a maximized window. Before: moves by (-1, -1) px. After: stays on the same pixel in both cases. Tested on Fedora 44, GNOME on Wayland, with window buttons on the left. Not tested with buttons on the right. Validated with: * `cargo build` * `cargo test -p sidebar` * `./script/clippy -p sidebar` * `cargo fmt -p sidebar` Before: <img width="960" height="176" alt="before" src="https://github.com/user-attachments/assets/c2b7dede-4c4c-4466-ba34-7666144e9cc1" /> After: <img width="960" height="176" alt="after" src="https://github.com/user-attachments/assets/d54172ca-be8e-4bb6-b5b3-ab193ac96423" /> ## Self-Review Checklist * [x] I've reviewed my own diff for quality, security, and reliability * [x] Unsafe blocks (if any) have justifying comments * [x] The content adheres to Zed's UI standards * [ ] Tests cover the new/changed behavior * [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed window controls shifting by 1px when the agent sidebar is open on Linux. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
Objective
Fixes #63954
On Linux with client-side decorations, the window controls (close / minimize / maximize) move 1px up and outward when the agent sidebar is opened, and move back when it is closed.
Solution
The title bar draws a 1px border in its own color to cover the window border at the rounded corners, so the controls it renders sit 1px in from the edge. When the sidebar is open,
Sidebar::render_sidebar_headerrenders the same controls without that inset.Added the matching 1px padding to the sidebar header under
Decorations::Client: top always, bottom only when no project is open (otherwise the header's bottom border already accounts for it), and left/right only on the side that renders the controls.Testing
Compared the close button position with the sidebar closed and open, on stable 1.20.2 and on this branch, in a floating and a maximized window. Before: moves by (-1, -1) px. After: stays on the same pixel in both cases.
Tested on Fedora 44, GNOME on Wayland, with window buttons on the left. Not tested with buttons on the right.
Validated with:
cargo buildcargo test -p sidebar./script/clippy -p sidebarcargo fmt -p sidebarBefore:
After:
Self-Review Checklist
Release Notes: