mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
fix: ensure stable bounds on Windows when toggling setResizable for frameless windows (#51296)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
This commit is contained in:
@@ -285,8 +285,7 @@ gfx::Size WinFrameView::GetMaximumSize() const {
|
||||
}
|
||||
|
||||
gfx::Insets WinFrameView::RestoredFrameBorderInsets() const {
|
||||
if (window_->has_frame() || !window_->has_thick_frame() ||
|
||||
!window_->IsResizable())
|
||||
if (window_->has_frame() || !window_->has_thick_frame())
|
||||
return {};
|
||||
|
||||
const int thickness =
|
||||
|
||||
@@ -121,10 +121,11 @@ bool ElectronDesktopWindowTreeHostWin::GetClientAreaInsets(
|
||||
// monitors with different DPIs before changing this code.
|
||||
*insets = gfx::Insets::TLBR(thickness, thickness, thickness, thickness);
|
||||
return true;
|
||||
} else if (native_window_view_->has_thick_frame() &&
|
||||
native_window_view_->IsResizable()) {
|
||||
} else if (native_window_view_->has_thick_frame()) {
|
||||
// Grow the insets to support resize targets past the frame edge like in
|
||||
// windows with standard frames.
|
||||
// windows with standard frames. Non-resizable windows still get input
|
||||
// insets for stable bounds and so they can be dragged from outer edges,
|
||||
// also like in windows with standard frames.
|
||||
*insets = gfx::Insets::TLBR(0, thickness, thickness, thickness);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5692,6 +5692,20 @@ describe('BrowserWindow module', () => {
|
||||
expectBoundsEqual(w.getSize(), [400, 300]);
|
||||
});
|
||||
|
||||
it('does not change window size when disabled and enabled for frameless window', () => {
|
||||
const w = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 300,
|
||||
frame: false
|
||||
});
|
||||
|
||||
w.setResizable(false);
|
||||
expectBoundsEqual(w.getSize(), [400, 300]);
|
||||
w.setResizable(true);
|
||||
expectBoundsEqual(w.getSize(), [400, 300]);
|
||||
});
|
||||
|
||||
ifit(process.platform === 'win32')('do not change window with frame bounds when maximized', () => {
|
||||
const w = new BrowserWindow({
|
||||
show: true,
|
||||
|
||||
Reference in New Issue
Block a user