From 1b8963ff6e3adb9ebdca3aa5b41fa73a7de3b14b Mon Sep 17 00:00:00 2001 From: Shubham Date: Tue, 20 Jun 2017 16:11:28 -0400 Subject: [PATCH] :apple: Fix full screen when resizable is set to true --- atom/browser/native_window_mac.mm | 5 +++++ spec/api-browser-window-spec.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index f46400ec0b02..0f3d65787180 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -171,6 +171,7 @@ bool ScopedDisableResize::disable_resize_ = false; @private atom::NativeWindowMac* shell_; bool is_zooming_; + bool is_resizable_; } - (id)initWithShell:(atom::NativeWindowMac*)shell; @end @@ -324,6 +325,9 @@ bool ScopedDisableResize::disable_resize_ = false; } - (void)windowWillEnterFullScreen:(NSNotification*)notification { + // Setting resizable to true before entering fullscreen + is_resizable_ = shell_->IsResizable(); + shell_->SetResizable(true); // Hide the native toolbar before entering fullscreen, so there is no visual // artifacts. if (base::mac::IsAtLeastOS10_10() && @@ -380,6 +384,7 @@ bool ScopedDisableResize::disable_resize_ = false; } - (void)windowDidExitFullScreen:(NSNotification*)notification { + shell_->SetResizable(is_resizable_); shell_->NotifyWindowLeaveFullScreen(); } diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index dad348599428..79ee12b8387c 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -2000,6 +2000,25 @@ describe('BrowserWindow module', function () { }) }) + describe('fullscreen state with resizable set', function () { + // Only implemented on macOS. + if (process.platform !== 'darwin') return + + it('resizable flag should be set to true and restored', function (done) { + w.destroy() + w = new BrowserWindow({ resizable: false }) + w.once('enter-full-screen', () => { + assert.equal(w.isResizable(), true) + w.setFullScreen(false) + }) + w.once('leave-full-screen', () => { + assert.equal(w.isResizable(), false) + done() + }) + w.setFullScreen(true) + }) + }) + describe('fullscreen state', function () { // Only implemented on macOS. if (process.platform !== 'darwin') return