fix: accurate window sizing and support for content sizing on Linux/Wayland with CSD#49209
fix: accurate window sizing and support for content sizing on Linux/Wayland with CSD#49209jkleinsc merged 10 commits intoelectron:mainfrom
Conversation
efd7de2 to
e7d91d9
Compare
|
FYI @ckerr this is the "separate Chromium patch" I mentioned in the description. I landed it the other day: https://chromium-review.googlesource.com/c/chromium/src/+/7442667. It makes some of the math for min/max size constraints more consistent but I think it's best saved for a followup. |
ckerr
left a comment
There was a problem hiding this comment.
Sorry for the extreme tardiness of this review.
This is a nice piece of work, and that "When a window isn't a window" document was extremely helpful. I learned a lot from it.
|
This is a big change, so I'd suggest doing 41, maybe 40, but not further than that. |
|
Let's do 41 for this and especially the followup. |
|
Release Notes Persisted
|
…ayland with CSD (#49209) * fix window sizing and content sizing on Linux when CSD is in use * fixed size constraints * simplify min/max size calculation * use base window size for min/max * moved windows min/max size overrides * remove unnecessary checks for client frame * cleanup Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
|
I have automatically backported this PR to "41-x-y", please check out #49835 |
…ayland with CSD (#49835) fix: accurate window sizing and support for content sizing on Linux/Wayland with CSD (#49209) * fix window sizing and content sizing on Linux when CSD is in use * fixed size constraints * simplify min/max size calculation * use base window size for min/max * moved windows min/max size overrides * remove unnecessary checks for client frame * cleanup Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
…ayland with CSD (electron#49209) * fix window sizing and content sizing on Linux when CSD is in use * fixed size constraints * simplify min/max size calculation * use base window size for min/max * moved windows min/max size overrides * remove unnecessary checks for client frame * cleanup
Description of Change
Fixes #48589.
Fixes #48588.
Background reading for maintainers: https://electronhq.slack.com/docs/T394SAQKC/F09ME0YPPV1.
This PR affects Linux environments which use CSD on Wayland. Today that means mostly just GNOME, but in the near future it will include frameless windows on any desktop environment. I regularized bounds handling and fixed edge cases to ensure:
setBounds/SetSize/setContentSize(if the compositor supports this).BrowserWindow.getBoundsreports the logical size of the window, without leaking invisible decoration insetse.g.: A window created at 800x600 on GNOME will now visually measure 800x600 including the titlebar, just like on other platforms, and
getBoundswill report 800x600. If the window is created withuseContentSize: true, it will visually measure something like 800x650, with an 800x600 content area. Bounds will be stable throughout the window lifecycle, and future bounds operations will work consistently and as expected.Thought process
When CSD is in use, Chromium's accelerated widget is larger than the visible window frame. An 800x600 window might be inset into an 844x844 widget, with the outer part being used for shadows and resize targets. Electron is now aware of this possibility and has tools to manage it consistently.
Stabilizing CSD bounds fixes a large class of interaction quirks on Wayland which were caused by the compositor fighting with Electron over confcliting size constraints.It is also a necessary pre-req to introduce shadows to frameless windows: #48570. (Some of this PR anticipates that upcoming work by hoisting shared methods into
FramelessView.)The bulk of the PR is about adding awareness of the difference between the window's "logical bounds" and the total "widget bounds" to
native_window_views. This code is used on both Linux and Windows, and I tried to keep the logic as platform-independent as possible, both to avoid ifdefs, but also because Windows also has similar issues with resize target bounds that extend past the logical/client area which these interfaces may be able to help with in the future.In general, Electron should now be able to handle "widgets that are larger than the actually visible window/frame" as a platform-independent problem, whenever it comes up. At a high level, the philosophy here is:
setBounds,getBoundsand derivatives) deal in logical geometric bounds instead of the total bounds of the accelerated widget. These APIs always strip out/convert invisible insets used by the widget for shadows, decorations, and resize targets.widget()directly if they need to manipulate or read the total underlying bounds.So there is some more internal complexity to negotiate the difference between logical and widget bounds spaces, but most callers should only care about logical bounds, especially in APIs exposed to JS.
Checklist
npm testpassesRelease Notes
Notes: Fixed several issues with consistent window sizing and resizing on Linux when CSD is in use (e.g. on GNOME/Wayland) and added support for creating content-sized windows.