Skip to content

Commit

Permalink
fix: resizable: false should disable fullscreen button at start (#3…
Browse files Browse the repository at this point in the history
…9229)

fix: resizable should disable fullscreen button at start

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Jul 26, 2023
1 parent 9585590 commit 6a4bb4f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
15 changes: 9 additions & 6 deletions shell/browser/native_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions shell/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,24 @@ void ReorderChildWindowAbove(NSWindow* child_window, NSWindow* other_window) {
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() {
Expand Down

0 comments on commit 6a4bb4f

Please sign in to comment.