Skip to content

sidebar: Fix window controls shifting when the sidebar is open - #64381

Merged
smitbarmase merged 4 commits into
zed-industries:mainfrom
Piyushrathoree:sidebar-window-controls-offset
Sep 24, 2026
Merged

smitbarmase merged 4 commits into
zed-industries:mainfrom
Piyushrathoree:sidebar-window-controls-offset

Conversation

@Piyushrathoree

Copy link
Copy Markdown
Contributor

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_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:

before

After:

after

Self-Review Checklist

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed window controls shifting by 1px when the agent sidebar is open on Linux.

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
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Sep 17, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Sep 17, 2026
@dinocosta dinocosta added platform:linux happens only on linux, not other OS platform:linux/wayland happens only on Linux Wayland area:title bar Issues suitable for title bar. and removed platform:linux happens only on linux, not other OS labels Sep 18, 2026
@legregz

legregz commented Sep 21, 2026

Copy link
Copy Markdown

I noticed that the corner of the window moves, too, but maybe you've already noticed that?

@Piyushrathoree

Copy link
Copy Markdown
Contributor Author

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 smitbarmase self-assigned this Sep 23, 2026

@smitbarmase smitbarmase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@smitbarmase
smitbarmase added this pull request to the merge queue Sep 24, 2026
Merged via the queue into zed-industries:main with commit 6fae7f3 Sep 24, 2026
37 checks passed
@Piyushrathoree

Copy link
Copy Markdown
Contributor Author

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

tidely pushed a commit to tidely/zed that referenced this pull request Sep 28, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:title bar Issues suitable for title bar. cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions platform:linux/wayland happens only on Linux Wayland

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Window close button moves

4 participants