From 7a7f1ee711c9de118da5a63aba6f49da37f52faa Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Sun, 12 Nov 2017 07:09:25 +0100 Subject: [PATCH 1/5] dont resize on taskbar resize if resizable is false --- atom/browser/native_window_views_win.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index 83e7dfaa79..3af8877c41 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -165,6 +165,13 @@ bool NativeWindowViews::PreHandleMSG( } return false; } + case WM_WINDOWPOSCHANGING: { + auto window_pos = reinterpret_cast(l_param); + if (window_pos->flags | SWP_FRAMECHANGED) + return !CanResize(); + + return false; + } default: return false; } From ca76dda6a69a1458775cdd92e44972d3dbf427c7 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Sun, 12 Nov 2017 07:31:59 +0100 Subject: [PATCH 2/5] remove incorrect checks --- atom/browser/native_window_views_win.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index 3af8877c41..f1bc3d4e34 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -166,11 +166,7 @@ bool NativeWindowViews::PreHandleMSG( return false; } case WM_WINDOWPOSCHANGING: { - auto window_pos = reinterpret_cast(l_param); - if (window_pos->flags | SWP_FRAMECHANGED) - return !CanResize(); - - return false; + return !CanResize(); } default: return false; From bb5eecc16cff8053c7b04e0b9396803fbbb8c4df Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 13 Nov 2017 00:35:39 +0100 Subject: [PATCH 3/5] Use SizeConstraints instead of window events --- atom/browser/native_window.cc | 4 +--- atom/browser/native_window_views.cc | 17 +++++++++-------- atom/browser/native_window_views.h | 9 ++++++--- atom/browser/native_window_views_win.cc | 3 --- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 43aad44c10..1b4111eabc 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -148,13 +148,11 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { } else { SetSizeConstraints(size_constraints); } -#if defined(USE_X11) +#if defined(OS_WIN) || defined(USE_X11) bool resizable; if (options.Get(options::kResizable, &resizable)) { SetResizable(resizable); } -#endif -#if defined(OS_WIN) || defined(USE_X11) bool closable; if (options.Get(options::kClosable, &closable)) { SetClosable(closable); diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 0ae5092b43..2c95d93e93 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -547,9 +547,9 @@ bool NativeWindowViews::IsFullscreen() const { } void NativeWindowViews::SetBounds(const gfx::Rect& bounds, bool animate) { -#if defined(USE_X11) - // On Linux the minimum and maximum size should be updated with window size - // when window is not resizable. +#if defined(OS_WIN) || defined(USE_X11) + // On Linux and Windows the minimum and maximum size should be updated with + // window size when window is not resizable. if (!resizable_) { SetMaximumSize(bounds.size()); SetMinimumSize(bounds.size()); @@ -594,17 +594,14 @@ void NativeWindowViews::SetContentSizeConstraints( // this to determine whether native widget has initialized. if (window_ && window_->widget_delegate()) window_->OnSizeConstraintsChanged(); -#if defined(USE_X11) +#if defined(OS_WIN) || defined(USE_X11) if (resizable_) old_size_constraints_ = size_constraints; #endif } void NativeWindowViews::SetResizable(bool resizable) { -#if defined(OS_WIN) - if (has_frame() && thick_frame_) - FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME); -#elif defined(USE_X11) +#if defined(OS_WIN) || defined(USE_X11) if (resizable != resizable_) { // On Linux there is no "resizable" property of a window, we have to set // both the minimum and maximum size to the window size to achieve it. @@ -619,6 +616,10 @@ void NativeWindowViews::SetResizable(bool resizable) { } } #endif +#if defined(OS_WIN) + if (has_frame() && thick_frame_) + FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME); +#endif resizable_ = resizable; } diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 638f2b849c..f08603d123 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -228,12 +228,15 @@ class NativeWindowViews : public NativeWindow, // To disable the mouse events. std::unique_ptr event_disabler_; - +#endif +#if defined(OS_WIN) || defined(USE_X11) // The "resizable" flag on Linux is implemented by setting size constraints, // we need to make sure size constraints are restored when window becomes - // resizable again. + // resizable again. This is also used on Windows, to keep taskbar resize + // events from resizing the window. extensions::SizeConstraints old_size_constraints_; -#elif defined(OS_WIN) +#endif +#if defined(OS_WIN) // Weak ref. AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_; diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index f1bc3d4e34..83e7dfaa79 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -165,9 +165,6 @@ bool NativeWindowViews::PreHandleMSG( } return false; } - case WM_WINDOWPOSCHANGING: { - return !CanResize(); - } default: return false; } From 710ca230f30d2b455c16a503c5d05ab142280d17 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Thu, 23 Nov 2017 20:58:37 +0100 Subject: [PATCH 4/5] update tests to reflect new behaviour --- spec/api-browser-window-spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 2adc82df05..b5b7543952 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -2177,8 +2177,11 @@ describe('BrowserWindow module', () => { assert.equal(w.isMaximizable(), true) w.setFullScreenable(false) assert.equal(w.isMaximizable(), true) + }) + + it('is set to false when resizable state is set to false', () => { w.setResizable(false) - assert.equal(w.isMaximizable(), true) + assert.equal(w.isMaximizable(), false) }) }) From 62594780e0eee653ecc5e7ed65c280087c7056a6 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Thu, 23 Nov 2017 21:24:50 +0100 Subject: [PATCH 5/5] run the new test only on windows --- spec/api-browser-window-spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index b5b7543952..55ca6c66c7 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -2178,6 +2178,11 @@ describe('BrowserWindow module', () => { w.setFullScreenable(false) assert.equal(w.isMaximizable(), true) }) + }) + + describe('maximizable state (Windows only)', () => { + // Only implemented on windows. + if (process.platform !== 'win32') return it('is set to false when resizable state is set to false', () => { w.setResizable(false)