Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash when exiting simple fullscreen on macOS #20220

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion shell/browser/native_window_mac.h
Expand Up @@ -158,7 +158,7 @@ class NativeWindowMac : public NativeWindow {
AtomTouchBar* touch_bar() const { return touch_bar_.get(); }
bool zoom_to_page_width() const { return zoom_to_page_width_; }
bool fullscreen_window_title() const { return fullscreen_window_title_; }
bool simple_fullscreen() const { return always_simple_fullscreen_; }
bool always_simple_fullscreen() const { return always_simple_fullscreen_; }

protected:
// views::WidgetDelegate:
Expand Down
10 changes: 8 additions & 2 deletions shell/browser/ui/cocoa/atom_ns_window.mm
Expand Up @@ -178,8 +178,14 @@ - (void)performClose:(id)sender {
}

- (void)toggleFullScreenMode:(id)sender {
if (shell_->simple_fullscreen())
shell_->SetSimpleFullScreen(!shell_->IsSimpleFullScreen());
bool is_simple_fs = shell_->IsSimpleFullScreen();
bool always_simple_fs = shell_->always_simple_fullscreen();

// If we're in simple fullscreen mode and trying to exit it
// we need to ensure we exit it properly to prevent a crash
// with NSWindowStyleMaskTitled mode
if (is_simple_fs || always_simple_fs)
shell_->SetSimpleFullScreen(!is_simple_fs);
else
[super toggleFullScreen:sender];
}
Expand Down
10 changes: 10 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -3343,6 +3343,16 @@ describe('BrowserWindow module', () => {
w.setFullScreen(true)
})

it('does not crash when exiting simpleFullScreen', (done) => {
const w = new BrowserWindow()
w.setSimpleFullScreen(true)

setTimeout(() => {
w.setFullScreen(!w.isFullScreen())
done()
}, 1000)
})

it('should not be changed by setKiosk method', (done) => {
const w = new BrowserWindow()
w.once('enter-full-screen', async () => {
Expand Down