Repository navigation
fix: edge resizing of frameless windows on Linux/Wayland - #51992
codebytere wants to merge 1 commit into
Conversation
|
@codebytere has manually backported this PR to "42-x-y", please check out #51993 |
|
@codebytere has manually backported this PR to "41-x-y", please check out #51994 |
|
cc: @aiddya since this touches the new |
03fd489 to
a085c2d
Compare
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.
a085c2d to
858cd0d
Compare
|
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.
@codebytere Did the outside resize border work during this time? |
|
@aiddya it didn't, no. I couldn't get resizing to work or the cursor to even show up without that, unfortunately. |
|
That's pretty strange. I'll have to look into that. Can you share what DE did you see that issue in? |
|
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)? |
|
@aiddya seeing it on sway, window force-floated (for_window [...] floating enable), Ubuntu 24.04 arm64. Window config is |
mitchchn
left a comment
There was a problem hiding this comment.
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.
|
Closing per discussion with @mitchchn |
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.
SetSupportsClientFrameShadow() in UpdateFrameHints(), same as
BrowserDesktopWindowTreeHostLinux, so the layout doesn't keep a stale
false from widget-init time.
HTCLIENT, re-test with GetFrameBorderInsets() + kResizeInsideBoundsSize
so there's a 5px resize band just inside the visible edge.
thisfor the eightresize 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
npm testpassesRelease Notes
Notes: Fixed an issue where resizing didn't work on Wayland in some circumstances.