Remember bounds instead of size

This commit is contained in:
Cheng Zhao 2016-07-09 23:10:36 +09:00
parent c4de246bfb
commit 5979c1464f
3 changed files with 17 additions and 15 deletions

View file

@ -279,13 +279,6 @@ NativeWindowViews::NativeWindowViews(
AddChildView(web_view_);
#if defined(OS_WIN)
// Save initial window state.
if (fullscreen)
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
else
last_window_state_ = ui::SHOW_STATE_NORMAL;
last_normal_size_ = widget_size_;
if (!has_frame()) {
// Set Window style so that we get a minimize and maximize animation when
// frameless.
@ -325,6 +318,15 @@ NativeWindowViews::NativeWindowViews(
window_->CenterWindow(size);
Layout();
#if defined(OS_WIN)
// Save initial window state.
if (fullscreen)
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
else
last_window_state_ = ui::SHOW_STATE_NORMAL;
last_normal_bounds_ = GetBounds();
#endif
}
NativeWindowViews::~NativeWindowViews() {
@ -419,7 +421,7 @@ void NativeWindowViews::Maximize() {
#if defined(OS_WIN)
// For window without WS_THICKFRAME style, we can not call Maximize().
if (!thick_frame_) {
last_normal_size_ = GetSize();
last_normal_bounds_ = GetBounds();
auto display =
gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
SetBounds(display.work_area(), false);
@ -437,7 +439,7 @@ void NativeWindowViews::Maximize() {
void NativeWindowViews::Unmaximize() {
#if defined(OS_WIN)
if (!thick_frame_) {
NativeWindow::SetSize(last_normal_size_);
SetBounds(last_normal_bounds_, false);
return;
}
#endif
@ -482,12 +484,12 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
// For window without WS_THICKFRAME style, we can not call SetFullscreen().
if (!thick_frame_) {
if (fullscreen) {
last_normal_size_ = GetSize();
last_normal_bounds_ = GetBounds();
auto display =
gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
SetBounds(display.bounds(), false);
} else {
NativeWindow::SetSize(last_normal_size_);
SetBounds(last_normal_bounds_, false);
}
return;
}