Skip to content

feat: Use system-themed titlebar icons for frameless windows with WCO on Linux - #52461

Merged
jkleinsc merged 4 commits into
electron:mainfrom
mitchchn:mitch/freedesktop-nav-buttons-wco
Jul 29, 2026
Merged

jkleinsc merged 4 commits into
electron:mainfrom
mitchchn:mitch/freedesktop-nav-buttons-wco

Conversation

@mitchchn

@mitchchn mitchchn commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Brings system-themed titlebar buttons to Linux when Window Controls Overlay (WCO) is enabled:

  1. The implementation uses named Freedesktop symbolic icons and is compatible with any Linux distribution and desktop environment that implements the standard.
  2. The new icons fully support Electron's existing titlebarOverlay API (including height, color, symbolColor) and automatic contrast, like the current vector icons.
  3. Minor styling accommodations for color and spacing are applied to the glyphs if the user's theme is Breeze (default for KDE Plasma). Otherwise, the buttons adopt styling based on Adwaita.
    • Beyond being the default theme for GNOME, Adwaita is a safe, conventional default which Linux users are accustomed to seeing everywhere, as modern GTK4 apps already prefer it over the user's GTK theme.
    • This approach was inspired by Firefox, which also makes small adjustments for Breeze but otherwise bases its system titlebar styling on Adwaita and does not attempt to integrate arbitrary GTK themes.
  4. If a Freedesktop icon theme is not installed, Electron will fall back to the built-in Chromium vector icons.

The new look has been tested with a range of web content backgrounds and system configurations. (Examples below.) App developers should not need to make any changes to their app design or code to accommodate the different icons.

Resolves #44540.

Alternatives considered

Earlier in the year I looked into using GTK titlebar buttons directly for WCO. But there is too much variety in third-party GTK themes for them to be embedded automatically into web content. GTK buttons are designed to be placed inside controlled headerbar components, not arbitrary backgrounds, and the icons often use bitmap assets and cannot be tinted or switched between light/dark without changing the app's entire theme.

I also did not want to add new, hard dependencies on GTK to Electron, as it might not always link to GTK and we should build against XDG/Freedesktop standards rather than framework-specific libraries. The vector buttons in this PR are drawn entirely with Skia and do not depend on GTK. (The PR does introduce a GTK impl. for an abstract provider to load the icon glyph and theme name, but this can be upstreamed to LinuxUi.)

Upstreaming

While this feature did not require a Chromium patch, I intend to submit the new button provider and frame view changes in this PR upstream. If it is accepted, this entire implementation will be replaced with about 30 lines of code in Electron.

Examples

Breeze style on KDE (with mouse hovered over close button)

Light Dark
breeze light breeze dark

Adwaita style on GNOME (with Yaru glyphs supplied by Ubuntu)

Light Dark
adwaita light adwaita dark

A bunch of VS Code themes showing the effects of color and symbolColor

Screenshot_20260727_000649 Screenshot_20260727_000630 Screenshot_20260727_000608

Assisted-By: Claude Fable 5

(Claude implemented the FreedesktopNavButtonProvider based on my architectural requirements. I reviewed the file and revised several times for maintainability and separation of concerns)

Checklist

Release Notes

Notes: Frameless windows on Linux now use system-themed titlebar icons for Window Controls Overlay (WCO).

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jul 27, 2026
@mitchchn
mitchchn requested a review from deepak1556 July 27, 2026 22:10
@mitchchn
mitchchn force-pushed the mitch/freedesktop-nav-buttons-wco branch 2 times, most recently from 6592f24 to fd2a632 Compare July 27, 2026 22:44
@nikwen nikwen added semver/minor backwards-compatible functionality target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. labels Jul 27, 2026

@erickzhao erickzhao 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.

API LGTM

@deepak1556 deepak1556 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.

LGTM on proposed design, thanks!

@nikwen nikwen removed the target/42-x-y PR should also be added to the "42-x-y" branch. label Jul 27, 2026

@jkleinsc jkleinsc 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.

API LGTM

@jkleinsc
jkleinsc merged commit 6ac7bc0 into electron:main Jul 29, 2026
68 checks passed
@release-clerk

release-clerk Bot commented Jul 29, 2026

Copy link
Copy Markdown

Release Notes Persisted

Frameless windows on Linux now use system-themed titlebar icons for Window Controls Overlay (WCO).

@trop

trop Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #52530

@trop trop Bot added in-flight/43-x-y and removed target/43-x-y PR should also be added to the "43-x-y" branch. labels Jul 29, 2026
@trop

trop Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #52531

@trop trop Bot removed target/44-x-y PR should also be added to the "44-x-y" branch. in-flight/43-x-y labels Jul 29, 2026
@flying-sheep

Copy link
Copy Markdown
Contributor

What about button position? Mine are supposed to be on the left.

@mitchchn

mitchchn commented Jul 29, 2026 •

Copy link
Copy Markdown
Member Author

@flying-sheep button position was addressed by #51161. That change is in Electron 43, but most apps haven't updated yet.

@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. and removed in-flight/44-x-y labels Jul 30, 2026
DeJeune added a commit to CherryHQ/cherry-studio that referenced this pull request Oct 9, 2026
…21416)

<!-- Template from
https://github.com/kubevirt/kubevirt/blob/main/.github/PULL_REQUEST_TEMPLATE.md?-->
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. Consider creating this PR as draft:
https://github.com/CherryHQ/cherry-studio/blob/main/CONTRIBUTING.md
-->

> ### Branch strategy
>
> - Active development targets `main`.

### What this PR does

Before this PR:

- On Linux with "Use system title bar" off, the main window and
sub-windows are frameless (`frame: false`). React draws its own
min/max/close buttons and drives them over IPC.
- Sub-windows ignore `app.use_system_title_bar`, so they stay frameless
even when it is on. In that case `useHasWindowControls()` returns false,
and the sub-window ends up with **no window controls at all**.
- With the system title bar on, the native bar sits above Cherry's own
44px top bar, giving two stacked bars.

After this PR:

- **Main window (Linux):**
- "Use system title bar" off → `titleBarStyle: 'hidden'` plus
`titleBarOverlay` (44px, matching `AppShellTabBar`'s `h-11`). Electron
draws the controls with the system's Freedesktop icon theme (Electron
44, electron/electron#52461).
  - "Use system title bar" on → native frame, unchanged.
- **Sub-windows (Linux):** always use WCO (37px, matching
`TITLE_BAR_HEIGHT_PX`). Pooled standbys are created from static registry
options only, so they cannot read the preference. As a side effect,
sub-windows now always have controls.
- **Theme sync:** overlay `color` / `symbolColor` follow `nativeTheme`
through `setTitleBarOverlay` (new
`src/main/core/window/linuxTitleBarOverlay.ts`). It is only applied to
windows created with an overlay, which avoids the #5571-style error.
- **Renderer:**
- On Linux, `WindowControls` renders a spacer the width of the overlay
instead of buttons. The width comes from `env(titlebar-area-x/width)`
rather than a hardcoded number, and is 0 when the window has no overlay.
  - The sub-window's `--window-controls-width` uses the same expression.
  - `useHasWindowControls()` is now Windows-only.
- **Leading (left-side) controls:** when GNOME's `button-layout` puts
the buttons on the left, the main window reuses the macOS traffic-light
layout: a sidebar spacer plus a tab-strip inset. The sub-window title
bar pads by `env(titlebar-area-x)`. A new
`useLeadingWindowControlsOverlay` hook follows `geometrychange`, so the
layout updates live when the button layout changes.
- **MCP browser window (Linux):** now uses WCO (42px, theme-synced)
instead of drawing its own buttons in `tabbarHtml.ts`. Its tab bar
BrowserView can read `env(titlebar-area-*)` too, so it reserves the
overlay on either side.
- Windows and macOS behavior is unchanged.

Refs #21413 (partial: see reviewer notes for remaining acceptance items)

### Why we need it and why it was done in this way

The following tradeoffs were made:

- The overlay `color` is fully transparent so Cherry's own top bar shows
through. Its RGB is still chosen to contrast the glyph: Electron's Linux
frame forces `color` opaque and uses it as the inverted glyph color on
hover (Breeze style). A transparent black made hovered glyphs invisible
on the dark hover pill.
- Sub-windows do not read `app.use_system_title_bar`. Before this PR
they did not honor it either. Supporting it would need WindowManager
pool standbys to accept dynamic options, which is an upstream change
left out of scope.

The following alternatives were considered:

- Removing the "Use system title bar" option entirely. It was kept as a
fallback for desktops where WCO is unverified (e.g. KDE, which offers
server-side decorations). Removal touches the preference classification,
migration mappings, settings UI and i18n, so it belongs in a separate PR
once WCO is validated.
- Keeping the React-drawn buttons. That means continuing to maintain
button styling, interaction and maximize-state sync per desktop.

Links to places where the discussion took place: #21413. Approach
mirrors t3code's desktop window (`titleBarStyle: 'hidden'` + transparent
`titleBarOverlay` + `env(titlebar-area-*)` insets).

### Breaking changes

None. The Linux custom title bar mode changes appearance: native-themed
controls replace the React ones. The preference and its restart-to-apply
flow are unchanged.

### Special notes for your reviewer

Verified on Ubuntu GNOME, native Wayland, 1.333 fractional scale, Breeze
GTK/icon theme, right-side buttons:
- Through CDP, `navigator.windowControlsOverlay.visible` is true for
both window types. The main window overlay is 72×44 on the right.
- The `WindowControls` spacer occupies exactly x=888–960 (the overlay
area), and no title-bar control overlaps it.
- Hovering a control inverts its glyph (Breeze style) in the current
build, confirmed by eye. The earlier `#01000000` overlay color showed no
inversion.
- Left-side buttons (`button-layout 'close,minimize,maximize:icon'`):
- Before the fix: the overlay (x=0–72) covered the sidebar avatar and
the start of the first tab.
- After the fix: the avatar moves below the 44px spacer, and the first
tab starts at x=74. In Settings (no sidebar), the strip pads by 74px.
The sub-window title bar pads by 80px.
  - Switching back restores the original layout live.
- MCP browser on Linux: the tab bar sees the overlay (safe area 1128 of
1200 wide). The tab row pads 80px on the side with the buttons, and the
self-drawn controls are hidden. That the overlay is drawn above the tab
bar BrowserView was confirmed by eye.

Not yet verified / follow-ups:
- X11/XWayland, KDE, and toggling the preference back and forth.
- Blurriness of the native frame when the system title bar is on
(fractional scaling) is a separate issue, not addressed here.

### Checklist

This checklist is not enforcing, but it's a reminder of items that could
be relevant to every PR.
Approvers are expected to review this list.

- [x] Branch: This PR targets `main`
- [x] PR: The PR description is expressive enough and will help future
contributors
- [x] Code: [Write code that humans can
understand](https://en.wikiquote.org/wiki/Martin_Fowler#code-for-humans)
and [Keep it simple](https://en.wikipedia.org/wiki/KISS_principle)
- [ ] Refactor: You have [left the code cleaner than you found it (Boy
Scout
Rule)](https://learning.oreilly.com/library/view/97-things-every/9780596809515/ch08.html)
- [x] Upgrade: Impact of this change on upgrade flows was considered and
addressed if required
- [ ] Documentation: A [user-guide update](https://docs.cherry-ai.com)
was considered and is present (link) or not required. Check this only
when the PR introduces or changes a user-facing feature or behavior.
- [ ] Self-review: I have reviewed my own code (e.g., via
[`/gh-pr-review`](/.claude/skills/gh-pr-review/SKILL.md), `gh pr diff`,
or GitHub UI) before requesting review from others

### Release note

<!--  Write your release note:
1. Enter your extended release note in the below block. If the PR
requires additional action from users switching to the new release,
include the string "action required".
2. If no release note is required, just write "NONE".
3. Only include user-facing changes (new features, bug fixes visible to
users, UI changes, behavior changes). For CI, maintenance, internal
refactoring, build tooling, or other non-user-facing work, write "NONE".
-->

```release-note
Linux: with "Use system title bar" off, window controls are now drawn by the system icon theme (Electron Window Controls Overlay) in Cherry Studio's own title bar. Detached tab windows now always show minimize/maximize/close buttons.
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: SuYao <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

45-x-y api-review/requested 🗳 merged/44-x-y PR was merged to the "44-x-y" branch. new-pr 🌱 PR opened recently semver/minor backwards-compatible functionality

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Linux - Provide window borders and title bar buttons approprate for the user's desktop environment

7 participants