From 12548294c0b2639d34c05c544f56545004efee01 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 25 Jul 2023 18:18:36 +0200 Subject: [PATCH] fix: `resizable: false` should disable fullscreen button at start (#39086) fix: resizable should disable fullscreen button at start --- shell/browser/native_window.cc | 15 +++++++++------ shell/browser/native_window_mac.mm | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index a24a4c131be7..aaa9676f6a0d 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -198,10 +198,6 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) { SetSizeConstraints(size_constraints); } #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) - bool resizable; - if (options.Get(options::kResizable, &resizable)) { - SetResizable(resizable); - } bool closable; if (options.Get(options::kClosable, &closable)) { SetClosable(closable); @@ -223,6 +219,7 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) { if (options.Get(options::kAlwaysOnTop, &top) && top) { SetAlwaysOnTop(ui::ZOrderLevel::kFloatingWindow); } + bool fullscreenable = true; bool fullscreen = false; if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) { @@ -231,12 +228,18 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) { fullscreenable = false; #endif } - // Overridden by 'fullscreenable'. + options.Get(options::kFullScreenable, &fullscreenable); SetFullScreenable(fullscreenable); - if (fullscreen) { + + if (fullscreen) SetFullScreen(true); + + bool resizable; + if (options.Get(options::kResizable, &resizable)) { + SetResizable(resizable); } + bool skip; if (options.Get(options::kSkipTaskbar, &skip)) { SetSkipTaskbar(skip); diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index c396175027b1..7af696339ed4 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -818,7 +818,24 @@ void NativeWindowMac::MoveTop() { void NativeWindowMac::SetResizable(bool resizable) { ScopedDisableResize disable_resize; SetStyleMask(resizable, NSWindowStyleMaskResizable); + + // Right now, resizable and fullscreenable are decoupled in + // documentation and on Windows/Linux. Chromium disables + // fullscreenability if resizability is false on macOS as well + // as disabling the maximize traffic light unless the window + // is both resizable and maximizable. To work around this, we want + // to match behavior on other platforms by disabiliting the maximize + // button but keeping fullscreenability enabled. + // TODO(codebytere): refactor this once we have a better solution. SetCanResize(resizable); + if (!resizable) { + SetFullScreenable(true); + [[window_ standardWindowButton:NSWindowZoomButton] setEnabled:false]; + } else { + SetFullScreenable(true); + [[window_ standardWindowButton:NSWindowZoomButton] + setEnabled:IsFullScreenable()]; + } } bool NativeWindowMac::IsResizable() {