Merge pull request #11097 from brenca/resizable-win-fix
Fix resizable property not working when taskbar was resized
This commit is contained in:
commit
fcc8e0924e
4 changed files with 25 additions and 15 deletions
|
@ -148,13 +148,11 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
||||||
} else {
|
} else {
|
||||||
SetSizeConstraints(size_constraints);
|
SetSizeConstraints(size_constraints);
|
||||||
}
|
}
|
||||||
#if defined(USE_X11)
|
#if defined(OS_WIN) || defined(USE_X11)
|
||||||
bool resizable;
|
bool resizable;
|
||||||
if (options.Get(options::kResizable, &resizable)) {
|
if (options.Get(options::kResizable, &resizable)) {
|
||||||
SetResizable(resizable);
|
SetResizable(resizable);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if defined(OS_WIN) || defined(USE_X11)
|
|
||||||
bool closable;
|
bool closable;
|
||||||
if (options.Get(options::kClosable, &closable)) {
|
if (options.Get(options::kClosable, &closable)) {
|
||||||
SetClosable(closable);
|
SetClosable(closable);
|
||||||
|
|
|
@ -547,9 +547,9 @@ bool NativeWindowViews::IsFullscreen() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetBounds(const gfx::Rect& bounds, bool animate) {
|
void NativeWindowViews::SetBounds(const gfx::Rect& bounds, bool animate) {
|
||||||
#if defined(USE_X11)
|
#if defined(OS_WIN) || defined(USE_X11)
|
||||||
// On Linux the minimum and maximum size should be updated with window size
|
// On Linux and Windows the minimum and maximum size should be updated with
|
||||||
// when window is not resizable.
|
// window size when window is not resizable.
|
||||||
if (!resizable_) {
|
if (!resizable_) {
|
||||||
SetMaximumSize(bounds.size());
|
SetMaximumSize(bounds.size());
|
||||||
SetMinimumSize(bounds.size());
|
SetMinimumSize(bounds.size());
|
||||||
|
@ -594,17 +594,14 @@ void NativeWindowViews::SetContentSizeConstraints(
|
||||||
// this to determine whether native widget has initialized.
|
// this to determine whether native widget has initialized.
|
||||||
if (window_ && window_->widget_delegate())
|
if (window_ && window_->widget_delegate())
|
||||||
window_->OnSizeConstraintsChanged();
|
window_->OnSizeConstraintsChanged();
|
||||||
#if defined(USE_X11)
|
#if defined(OS_WIN) || defined(USE_X11)
|
||||||
if (resizable_)
|
if (resizable_)
|
||||||
old_size_constraints_ = size_constraints;
|
old_size_constraints_ = size_constraints;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetResizable(bool resizable) {
|
void NativeWindowViews::SetResizable(bool resizable) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN) || defined(USE_X11)
|
||||||
if (has_frame() && thick_frame_)
|
|
||||||
FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
|
|
||||||
#elif defined(USE_X11)
|
|
||||||
if (resizable != resizable_) {
|
if (resizable != resizable_) {
|
||||||
// On Linux there is no "resizable" property of a window, we have to set
|
// 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.
|
// both the minimum and maximum size to the window size to achieve it.
|
||||||
|
@ -619,6 +616,10 @@ void NativeWindowViews::SetResizable(bool resizable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
if (has_frame() && thick_frame_)
|
||||||
|
FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
|
||||||
|
#endif
|
||||||
|
|
||||||
resizable_ = resizable;
|
resizable_ = resizable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,12 +228,15 @@ class NativeWindowViews : public NativeWindow,
|
||||||
|
|
||||||
// To disable the mouse events.
|
// To disable the mouse events.
|
||||||
std::unique_ptr<EventDisabler> event_disabler_;
|
std::unique_ptr<EventDisabler> event_disabler_;
|
||||||
|
#endif
|
||||||
|
#if defined(OS_WIN) || defined(USE_X11)
|
||||||
// The "resizable" flag on Linux is implemented by setting size constraints,
|
// The "resizable" flag on Linux is implemented by setting size constraints,
|
||||||
// we need to make sure size constraints are restored when window becomes
|
// 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_;
|
extensions::SizeConstraints old_size_constraints_;
|
||||||
#elif defined(OS_WIN)
|
#endif
|
||||||
|
#if defined(OS_WIN)
|
||||||
// Weak ref.
|
// Weak ref.
|
||||||
AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_;
|
AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_;
|
||||||
|
|
||||||
|
|
|
@ -2177,8 +2177,16 @@ describe('BrowserWindow module', () => {
|
||||||
assert.equal(w.isMaximizable(), true)
|
assert.equal(w.isMaximizable(), true)
|
||||||
w.setFullScreenable(false)
|
w.setFullScreenable(false)
|
||||||
assert.equal(w.isMaximizable(), true)
|
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)
|
w.setResizable(false)
|
||||||
assert.equal(w.isMaximizable(), true)
|
assert.equal(w.isMaximizable(), false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue