Skip to content

fix: edge resizing of frameless windows on Linux/Wayland - #51992

Closed
codebytere wants to merge 1 commit into
mainfrom
wayland-frameless-resize
Closed

codebytere wants to merge 1 commit into
mainfrom
wayland-frameless-resize

Conversation

@codebytere

@codebytere codebytere commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Description of Change

ElectronFrameViewLinux sits on views::FrameViewLinux, not FramelessView,
so it lost two things FramelessView provides: a TargetForRect that keeps
resize-border events on the frame view, and the kResizeInsideBoundsSize
inside-edge hit band (NativeWindow::NonClientHitTest only re-adds that
when the frame view is a FramelessView). FrameViewLinux's own resize
hit-test only covers GetFrameBorderInsets(), which on Wayland is the
shadow-only outer margin — and that band is zero anyway when
supports_client_frame_shadow_ stays cached at the value read before the
platform window existed.

  • electron_desktop_window_tree_host_linux: refresh
    SetSupportsClientFrameShadow() in UpdateFrameHints(), same as
    BrowserDesktopWindowTreeHostLinux, so the layout doesn't keep a stale
    false from widget-init time.
  • ElectronFrameViewLinux::NonClientHitTest: when the base class says
    HTCLIENT, re-test with GetFrameBorderInsets() + kResizeInsideBoundsSize
    so there's a 5px resize band just inside the visible edge.
  • ElectronFrameViewLinux::TargetForRect: return this for the eight
    resize HT components so the overlapping client view doesn't swallow the
    press; scoped to resize codes only so WCO caption-button clicks still
    reach the buttons.

cc @VerteDinde

Checklist

Release Notes

Notes: Fixed an issue where resizing didn't work on Wayland in some circumstances.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jun 15, 2026
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/41-x-y PR should also be added to the "41-x-y" branch. 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. and removed target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Jun 15, 2026

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

Nice!

@trop

trop Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@codebytere has manually backported this PR to "42-x-y", please check out #51993

@trop

trop Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@codebytere has manually backported this PR to "41-x-y", please check out #51994

@codebytere
codebytere marked this pull request as draft June 15, 2026 05:18
@mitchchn

Copy link
Copy Markdown
Member

cc: @aiddya since this touches the new ElectronFrameViewLinux. (Can any of it be upstreamed?)

@codebytere
codebytere force-pushed the wayland-frameless-resize branch from 03fd489 to a085c2d Compare June 15, 2026 20:33
ElectronFrameViewLinux sits on views::FrameViewLinux, not FramelessView,
so it lost two things FramelessView provides: a TargetForRect that keeps
resize-border events on the frame view, and the kResizeInsideBoundsSize
inside-edge hit band (NativeWindow::NonClientHitTest only re-adds that
when the frame view is a FramelessView). FrameViewLinux's own resize
hit-test only covers GetFrameBorderInsets(), which on Wayland is the
shadow-only outer margin — and that band is zero anyway when
supports_client_frame_shadow_ stays cached at the value read before the
platform window existed.

* electron_desktop_window_tree_host_linux: refresh
  SetSupportsClientFrameShadow() in UpdateFrameHints(), same as
  BrowserDesktopWindowTreeHostLinux, so the layout doesn't keep a stale
  false from widget-init time.
* ElectronFrameViewLinux::NonClientHitTest: when the base class says
  HTCLIENT, re-test with GetFrameBorderInsets() + kResizeInsideBoundsSize
  so there's a 5px resize band just inside the visible edge.
* ElectronFrameViewLinux::TargetForRect: return `this` for the eight
  resize HT components so the overlapping client view doesn't swallow the
  press; scoped to resize codes only so WCO caption-button clicks still
  reach the buttons.
@codebytere
codebytere force-pushed the wayland-frameless-resize branch from a085c2d to 858cd0d Compare June 15, 2026 20:37
@codebytere
codebytere marked this pull request as ready for review June 15, 2026 20:38
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Jun 16, 2026
@aiddya

aiddya commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

This is bringing back the 5px inside resize border. With FramelessViewLinux, an inside resize border is not necessary as we compute and maintain a 10px outside resize border all the time. We adjust the input region insets to account for the 10px outside resize border, even when there are no shadows to be drawn. I had mentioned this in the description of #51161.

I think inside resize borders are a compromise. You lose the resize band area within the client view. The resize band is kept small to minimize conflicts with client elements, but it makes it harder to interact with. The inside resize border was removed from three sides on Windows in #51503 after a couple of issues were reported.

I think the only downside of outside resize handles is that in case of frameless windows without shadows, they are not intuitive as you have to drag from empty space around the window. If we decide to go with an inside resize border, I think we should make it conditional on shadows being off.

Fixed an issue where resizing didn't work on Wayland in some circumstances.

@codebytere Did the outside resize border work during this time?

@codebytere

Copy link
Copy Markdown
Member Author

@aiddya it didn't, no. I couldn't get resizing to work or the cursor to even show up without that, unfortunately.

@aiddya

aiddya commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

That's pretty strange. I'll have to look into that. Can you share what DE did you see that issue in?

@mitchchn

mitchchn commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

I’d also like to help troubleshoot if possible @codebytere. There shouldn’t be any fundamental need for internal resize targets with the new frame view (any more than on a window with frame: true) so hopefully we can fix bugs without reverting that change.

Does it also happen on 42.x (which introduced external targets on the old frameless view)?

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

Just marking as requesting changes on behalf of @aiddya and @mitchchn so it doesn't accidentally get merged. :)

Feel free to dismiss my review once addressed.

@codebytere

Copy link
Copy Markdown
Member Author

@aiddya seeing it on sway, window force-floated (for_window [...] floating enable), Ubuntu 24.04 arm64. Window config is titleBarStyle: 'hidden' + titleBarOverlay: true, no explicit hasShadow.

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

Update: I believe this resize issue is an older Sway bug. I tested Electron 43 beta in Sway in Ubuntu 24.04 and 26.04 LTS.

  • In Sway 1.9 (24.04), I could not resize any apps that use CSD while in floating mode without using Mod-R. That includes Electron frameless windows, but also Firefox, Chrome, Nautilus, Thunderbird, etc.
  • In Sway 1.11 (26.04), all these apps + Electron frameless windows could be resized as expected.

Electron does support Ubuntu 24.04, but Sway is not an official spin for Ubuntu, and tiling WMs on Wayland are still fairly experimental -- users really need to stay up-to-date to get the best experience and bug fixes. So I don't love the idea of bringing back internal hit targets for all users to work around this issue, especially since it affects GTK apps more broadly and is patched in Sway, including on the current Ubuntu LTS.

Users stuck on older versions of Sway also have workarounds: using the default tiling mode, Mod-R to resize, or setting frame: true (often exposed as a user setting in popular Electron apps).

Electron and other frameworks which use CSD could absolutely do more to detect tiling WMs and better accommodate them (e.g. maybe fall back to frame: true). But that is another discussion and a complicated one to sort out since every app has different expectations.

@codebytere

Copy link
Copy Markdown
Member Author

Closing per discussion with @mitchchn

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

Labels

semver/patch backwards-compatible bug fixes target/43-x-y PR should also be added to the "43-x-y" branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants