Repository navigation
fix(titlebar): keep title bar buttons clear of Linux window controls - #2113
Merged
Merged
Conversation
Since Electron 43 a Linux window with a title bar overlay gets its minimize, maximize and close buttons where the desktop's button layout puts them: left, right or both, and only the buttons the desktop shows. Up to Electron 42 they were always three buttons on the right. The title bar reserved a fixed 140px on the right and 12px on the left, so after the move to Electron 45 (#2107): - with the buttons on the left, they covered the menu button; - with elementary's layout (close left, maximize right), close covered it; - on default GNOME (close only), 101px next to the button stayed empty. On Linux the title bar now pads each side by the width Electron reports as taken by window controls (the titlebar-area environment variables, which also reach the title bar's own view) plus the usual 12px. The centre pill stays centred in the window whichever side is wider. Windows keeps its fixed 140px and macOS its traffic-light inset; their rules only gained a "not Linux" condition. Validation, in an Ubuntu 24.04 container running the real app on Electron 45.3.2 under Xvfb: - Measured and screenshotted four layouts (Ubuntu, GNOME default, all left, elementary) at 1280px and at the 800px minimum, before and after. After the change every title bar button is inside the free area on all of them. - e2e/title-bar-linux-window-controls.test.ts starts the app with controls on both sides and checks the buttons against the area Electron reports, at the opening size and at the minimum width. It passes on this change and fails on the previous title bar with "the leftmost title bar button sits under the window controls on the left". - TitleBarApp.test.ts passes. Not checked: a real GNOME, KDE or Wayland session, and right-to-left locales. Electron 43 also rounds the corners of frameless windows where the desktop supports it; under X11 in the container, with and without a compositor, the window kept square corners, so that was not observed.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2107 (Electron 40 → 45).
What broke
Since Electron 43, a Linux window with a title bar overlay gets its minimize, maximize and close buttons where the desktop's button layout puts them: left, right or both, and only the buttons the desktop shows. Up to Electron 42 they were always three buttons on the right.
The title bar reserved a fixed 140px on the right and 12px on the left. Measured on Electron 45.3.2 at a 1280px window:
The fix
On Linux the title bar pads each side by the width Electron reports as taken by window controls, plus the usual 12px. It reads that from the
titlebar-area-xandtitlebar-area-widthenvironment variables, which also reach the title bar's ownWebContentsView, so no main-process code is involved. The centre pill stays centred in the window whichever side is wider.Windows keeps its fixed 140px and macOS its traffic-light inset. Their rules only gained a "not Linux" condition.
Before and after
The real app on Electron 45.3.2 in an Ubuntu 24.04 container, 1280px window, one pair per layout.
Validation
Run in an Ubuntu 24.04 container with the real app on Electron 45.3.2 under Xvfb.
e2e/title-bar-linux-window-controls.test.tsstarts the app with controls on both sides and checks the buttons against the area Electron reports, at the opening size and at the minimum width. It passes on this branch and fails on the previous title bar with "the leftmost title bar button sits under the window controls on the left".TitleBarApp.test.tspasses. The commit hook ran typecheck, lint and format. The rest of the suite is left to CI.Not checked