Skip to content

feat: Shadows and CSD for frameless windows on Wayland#49295

Merged
ckerr merged 19 commits intoelectron:mainfrom
mitchchn:mitch/linux-layout
Feb 20, 2026
Merged

feat: Shadows and CSD for frameless windows on Wayland#49295
ckerr merged 19 commits intoelectron:mainfrom
mitchchn:mitch/linux-layout

Conversation

@mitchchn
Copy link
Copy Markdown
Member

@mitchchn mitchchn commented Jan 4, 2026

Description of Change

This PR is branched from and depends on: #49209, since it requires proper CSD bounds handling to work.

Adds GTK drop shadows and resize borders to frameless windows on Linux in native Wayland mode, including when WCO is in use.

Fixes #48570.
Fixes #36768.

image

Users can opt out of shadows and get a truly frameless window by setting hasShadow: false on the window constructor. (Currently, runtime changes have no effect.) In X11/Xwayland, frameless windows will continue to get server-side shadows as before.

Thought Process

Linux uses two classes for "frameless" views:

  • ClientFrameViewLinux, which is only used on Wayland when frame: true. It simulates a real window frame by drawing borders, shadows, and titlebars using GTK.
  • OpaqueFrameView, which is used on both X11 and Wayland. It draws frameless windows with optional WCO.

On X11 OpaqueFrameView gets window borders + shadows for free from the window manager. But Wayland is unable to provide specialized decorations to frameless windows, so if we want them, we have to draw our own.

ClientFrameViewLinux already had the ability to draw CSD. It also had all the layout code to compute various kinds of insets and bounds. So I factored out most of the layout logic into a new LinuxFrameLayout helper interface which has implementations for Wayland and X11 (or when decorations are not wanted). These can be used as delegates and selected at runtime.

This approach was inspired by Chromium, which also uses layout delegates for its frame views. I think it has quite a few advantages:

  • Any kind of frame can opt in or out of CSD on Linux.
  • Both of the existing frameless view classes have a lot less duplicate layout code, even compared to main.
  • The two Linux frameless view classes are now principally responsible for their different titlebars and unique concerns.
  • The tree host and window no longer needs to make decisions based on specific classes and can simply ask for the layout interface.

While the layout delegate pattern is currently only used on Linux in this PR, in the future it can also scale to other platforms and may be useful on Windows as well.

Checklist

Release Notes

Notes: On Wayland (Linux), frameless windows now have GTK drop shadows and extended resize boundaries. To create fully frameless windows with no decorations, set hasShadow: false in the window constructor.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Jan 4, 2026
@mitchchn mitchchn changed the title feat: Shadows and CSD for framless windows on Wayland feat: Shadows and CSD for frameless windows on Wayland Jan 4, 2026
@joshua-stone
Copy link
Copy Markdown

Would this help address #45530, and would it do so in a way that doesn't require configuration on the user's part?

BessBett

This comment was marked as off-topic.

@absidue
Copy link
Copy Markdown

absidue commented Jan 5, 2026

@mitchchn So that the linked issues get closed automatically when this is merged, you need to write "fixes" in front of each issue number, GitHub only picks up the first one, when you group them together the way that you have currently done it in the pull request description.

Broken format: fixes x, y
Correct format: fixes x, fixes y (or on separate lines so it is easier to read)

@mitchchn
Copy link
Copy Markdown
Member Author

Tested a local build with VS Code. Here it is all in its glory:

image

@sedax90
Copy link
Copy Markdown

sedax90 commented Jan 25, 2026

Is still in progress? Why is idle?

@nikwen nikwen added the target/41-x-y PR should also be added to the "41-x-y" branch. label Feb 17, 2026
Copy link
Copy Markdown
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

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

Sorry for sitting on this for so long. This is good stuff.

@ckerr ckerr merged commit ea89ba5 into electron:main Feb 20, 2026
113 of 115 checks passed
@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Feb 20, 2026

Release Notes Persisted

On Wayland (Linux), frameless windows now have GTK drop shadows and extended resize boundaries. To create fully frameless windows with no decorations, set hasShadow: false in the window constructor.

trop bot added a commit that referenced this pull request Feb 20, 2026
* fix window sizing and content sizing on Linux when CSD is in use

* fixed size constraints

* layout helper

* CSD shadows for frameless windows on Linux

* simplify min/max size calculation

* use base window size for min/max

* respect HasShadow option

* moved windows min/max size overrides

* add newline at end of file

* fix setting background color for frameless csd windows

* fix wco positioning nad sizing to match prod

* safety improvements

Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Feb 20, 2026

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

@trop trop bot added in-flight/41-x-y and removed target/41-x-y PR should also be added to the "41-x-y" branch. labels Feb 20, 2026
@ckerr
Copy link
Copy Markdown
Member

ckerr commented Feb 20, 2026

Oh oof, I thought the API for this had been approved.

API LGTM for whatever that's worth. I'll ping @electron/wg-api here and in Slack about this accidental merge.

@dominichayesferen
Copy link
Copy Markdown

Congrats! 🎉

jkleinsc pushed a commit that referenced this pull request Feb 25, 2026
feat: Shadows and CSD for frameless windows on Wayland (#49295)

* fix window sizing and content sizing on Linux when CSD is in use

* fixed size constraints

* layout helper

* CSD shadows for frameless windows on Linux

* simplify min/max size calculation

* use base window size for min/max

* respect HasShadow option

* moved windows min/max size overrides

* add newline at end of file

* fix setting background color for frameless csd windows

* fix wco positioning nad sizing to match prod

* safety improvements

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
@trop trop bot added merged/41-x-y PR was merged to the "41-x-y" branch. and removed in-flight/41-x-y labels Feb 25, 2026
kycutler pushed a commit to kycutler/electron that referenced this pull request Feb 26, 2026
* fix window sizing and content sizing on Linux when CSD is in use

* fixed size constraints

* layout helper

* CSD shadows for frameless windows on Linux

* simplify min/max size calculation

* use base window size for min/max

* respect HasShadow option

* moved windows min/max size overrides

* add newline at end of file

* fix setting background color for frameless csd windows

* fix wco positioning nad sizing to match prod

* safety improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review/requested 🗳 merged/41-x-y PR was merged to the "41-x-y" branch. semver/minor backwards-compatible functionality wayland

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing shadow for window in Ubuntu [Bug]: Application window does not have border shadow on KDE Plasma desktop environment (or not using mutter)

10 participants