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/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 2adc82df05..55ca6c66c7 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -2177,8 +2177,16 @@ describe('BrowserWindow module', () => { assert.equal(w.isMaximizable(), true) 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) - assert.equal(w.isMaximizable(), true) + assert.equal(w.isMaximizable(), false) }) })