Skip to content

fix(titlebar): keep title bar buttons clear of Linux window controls - #2113

Merged
benceruleanlu merged 1 commit into
mainfrom
bl/linux-titlebar-controls
Nov 15, 2026
Merged

benceruleanlu merged 1 commit into
mainfrom
bl/linux-titlebar-controls

Conversation

@benceruleanlu

@benceruleanlu benceruleanlu commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

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:

Desktop layout Controls take Before
Ubuntu (minimize, maximize, close right) 113px right Fine, 27px of spare gap
GNOME default (close only) 39px right Fine, 101px of empty space
All buttons on the left 113px left Controls cover the menu button
elementary (close left, maximize right) 39px each side Close covers the menu button

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-x and titlebar-area-width environment variables, which also reach the title bar's own WebContentsView, 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.

Title bar before and after on four Linux button layouts

Validation

Run in an Ubuntu 24.04 container with the real app on Electron 45.3.2 under Xvfb.

  • The four layouts above were measured and screenshotted at 1280px and at the 800px minimum width, 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 branch 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. The commit hook ran typecheck, lint and format. The rest of the suite is left to CI.

Not checked

  • A real GNOME, KDE or Wayland session, and right-to-left locales. The container had Xvfb with openbox.
  • Electron 43 also rounds the corners of frameless windows where the desktop supports it. In the container, with and without a compositor, the window kept square corners, so that change was not observed.

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.
@benceruleanlu
benceruleanlu requested review from a team as code owners November 15, 2026 03:58
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The title bar now detects Linux and adjusts its spacing for window controls. A Linux end-to-end test checks button clearance at the opening size and at 800 pixels wide.

Changes: Linux title-bar controls

Layer / File(s) Summary
Linux detection and title-bar spacing
src/preload/comfyTitleBarPreload.ts, src/renderer/src/comfyTitleBar/TitleBarApp.vue, src/renderer/src/comfyTitleBar/TitleBarApp.test.ts
The bridge exposes isLinux(). The title bar uses Linux-specific window-control offsets to calculate spacing. The test mock supports the new bridge method.
Linux window-control clearance checks
e2e/title-bar-linux-window-controls.test.ts
The end-to-end test configures GTK window controls on both sides and checks that visible header buttons remain within the free title-bar area at the opening size and at 800 pixels wide.

Suggested reviewers: deepme987, mariana953

Merge Risk: Minimal · up to 37d4a

The change keeps Linux title bar buttons clear of window controls on either side, and Windows and macOS spacing is unchanged. No merge-blocking issue was found.

Pre-merge checks: Passed 2

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c80c6c1a-7a0c-40ad-885e-d30e759a44c1
Commits

Reviewing files that changed from the base of the PR and between 5d85efd and 37d4ab4.

Files selected for processing: 4

  • e2e/title-bar-linux-window-controls.test.ts
  • src/preload/comfyTitleBarPreload.ts
  • src/renderer/src/comfyTitleBar/TitleBarApp.test.ts
  • src/renderer/src/comfyTitleBar/TitleBarApp.vue

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@benceruleanlu
benceruleanlu merged commit df45cab into main Nov 15, 2026
21 checks passed
@benceruleanlu
benceruleanlu deleted the bl/linux-titlebar-controls branch November 15, 2026 04:21
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