linux: Restore size constraints when became sizable
This commit is contained in:
parent
f6327de7f7
commit
e06778178a
2 changed files with 22 additions and 4 deletions
|
@ -387,6 +387,15 @@ gfx::Size NativeWindowViews::GetContentSize() {
|
||||||
return web_view_->size();
|
return web_view_->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowViews::SetContentSizeConstraints(
|
||||||
|
const extensions::SizeConstraints& size_constraints) {
|
||||||
|
NativeWindow::SetContentSizeConstraints(size_constraints);
|
||||||
|
#if defined(USE_X11)
|
||||||
|
if (resizable_)
|
||||||
|
old_size_constraints_ = size_constraints;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetResizable(bool resizable) {
|
void NativeWindowViews::SetResizable(bool resizable) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
// WS_MAXIMIZEBOX => Maximize button
|
// WS_MAXIMIZEBOX => Maximize button
|
||||||
|
@ -403,11 +412,13 @@ void NativeWindowViews::SetResizable(bool 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.
|
||||||
if (resizable) {
|
if (resizable) {
|
||||||
SetMaximumSize(gfx::Size());
|
SetContentSizeConstraints(old_size_constraints_);
|
||||||
SetMinimumSize(gfx::Size());
|
|
||||||
} else {
|
} else {
|
||||||
SetMaximumSize(GetSize());
|
old_size_constraints_ = GetContentSizeConstraints();
|
||||||
SetMinimumSize(GetSize());
|
resizable_ = false;
|
||||||
|
gfx::Size content_size = GetContentSize();
|
||||||
|
SetContentSizeConstraints(
|
||||||
|
extensions::SizeConstraints(content_size, content_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,6 +64,8 @@ class NativeWindowViews : public NativeWindow,
|
||||||
void SetBounds(const gfx::Rect& bounds) override;
|
void SetBounds(const gfx::Rect& bounds) override;
|
||||||
gfx::Rect GetBounds() override;
|
gfx::Rect GetBounds() override;
|
||||||
gfx::Size GetContentSize() override;
|
gfx::Size GetContentSize() override;
|
||||||
|
void SetContentSizeConstraints(
|
||||||
|
const extensions::SizeConstraints& size_constraints) override;
|
||||||
void SetResizable(bool resizable) override;
|
void SetResizable(bool resizable) override;
|
||||||
bool IsResizable() override;
|
bool IsResizable() override;
|
||||||
void SetAlwaysOnTop(bool top) override;
|
void SetAlwaysOnTop(bool top) override;
|
||||||
|
@ -165,6 +167,11 @@ class NativeWindowViews : public NativeWindow,
|
||||||
|
|
||||||
// Handles window state events.
|
// Handles window state events.
|
||||||
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
extensions::SizeConstraints old_size_constraints_;
|
||||||
#elif defined(OS_WIN)
|
#elif defined(OS_WIN)
|
||||||
// Weak ref.
|
// Weak ref.
|
||||||
AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_;
|
AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue