Use SizeConstraints instead of window events
This commit is contained in:
parent
ca76dda6a6
commit
bb5eecc16c
4 changed files with 16 additions and 17 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -228,12 +228,15 @@ class NativeWindowViews : public NativeWindow,
|
|||
|
||||
// To disable the mouse events.
|
||||
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,
|
||||
// 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_;
|
||||
|
||||
|
|
|
@ -165,9 +165,6 @@ bool NativeWindowViews::PreHandleMSG(
|
|||
}
|
||||
return false;
|
||||
}
|
||||
case WM_WINDOWPOSCHANGING: {
|
||||
return !CanResize();
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue