feat: Shadows and CSD for frameless windows on Wayland#49295
feat: Shadows and CSD for frameless windows on Wayland#49295ckerr merged 19 commits intoelectron:mainfrom
Conversation
|
Would this help address #45530, and would it do so in a way that doesn't require configuration on the user's part? |
|
@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 |
…nto mitch/linux-layout
|
Is still in progress? Why is idle? |
ckerr
left a comment
There was a problem hiding this comment.
Sorry for sitting on this for so long. This is good stuff.
|
Release Notes Persisted
|
* 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>
|
I have automatically backported this PR to "41-x-y", please check out #49885 |
|
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. |
|
Congrats! 🎉 |
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>
* 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

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.
Users can opt out of shadows and get a truly frameless window by setting
hasShadow: falseon 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:
frame: true. It simulates a real window frame by drawing borders, shadows, and titlebars using GTK.On X11
OpaqueFrameViewgets 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.ClientFrameViewLinuxalready 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 newLinuxFrameLayouthelper 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:
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
npm testpassesRelease 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: falsein the window constructor.