Skip to content

Commit

Permalink
fix: fullscreen windows aren't resizable on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed May 30, 2022
1 parent 03d9615 commit fbdb0be
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion shell/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,9 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
}

bool NativeWindowMac::IsResizable() {
return [window_ styleMask] & NSWindowStyleMaskResizable;
bool in_fs_transition = fullscreen_transition_state() != FullScreenTransitionState::NONE;
bool has_rs_mask = [window_ styleMask] & NSWindowStyleMaskResizable;
return has_rs_mask && !IsFullscreen() && !in_fs_transition;
}

void NativeWindowMac::SetMovable(bool movable) {
Expand Down
3 changes: 1 addition & 2 deletions shell/browser/ui/cocoa/electron_ns_window_delegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ - (void)windowWillEnterFullScreen:(NSNotification*)notification {

shell_->NotifyWindowWillEnterFullScreen();

// Setting resizable to true before entering fullscreen.
// Save resizable value before entering fullscreen.
is_resizable_ = shell_->IsResizable();
shell_->SetResizable(true);
}

- (void)windowDidEnterFullScreen:(NSNotification*)notification {
Expand Down
10 changes: 10 additions & 0 deletions spec-main/api-browser-window-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4208,6 +4208,16 @@ describe('BrowserWindow module', () => {
}
});

ifit(process.platform === 'darwin')('is false when the window is fullscreen', async () => {
const w = new BrowserWindow();

const enterFS = emittedOnce(w, 'enter-full-screen');
w.setFullScreen(true);
await enterFS;

expect(w.resizable).to.be.false('resizable');
});

// On Linux there is no "resizable" property of a window.
ifit(process.platform !== 'linux')('does affect maximizability when disabled and enabled', () => {
const w = new BrowserWindow({ show: false });
Expand Down

0 comments on commit fbdb0be

Please sign in to comment.