Correctly handle unmaximize

This commit is contained in:
Cheng Zhao 2016-07-09 23:04:42 +09:00
parent baff744601
commit c4de246bfb

View file

@ -284,7 +284,7 @@ NativeWindowViews::NativeWindowViews(
last_window_state_ = ui::SHOW_STATE_FULLSCREEN; last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
else else
last_window_state_ = ui::SHOW_STATE_NORMAL; last_window_state_ = ui::SHOW_STATE_NORMAL;
last_normal_size_ = gfx::Size(widget_size_); last_normal_size_ = widget_size_;
if (!has_frame()) { if (!has_frame()) {
// Set Window style so that we get a minimize and maximize animation when // Set Window style so that we get a minimize and maximize animation when
@ -419,6 +419,7 @@ void NativeWindowViews::Maximize() {
#if defined(OS_WIN) #if defined(OS_WIN)
// For window without WS_THICKFRAME style, we can not call Maximize(). // For window without WS_THICKFRAME style, we can not call Maximize().
if (!thick_frame_) { if (!thick_frame_) {
last_normal_size_ = GetSize();
auto display = auto display =
gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition()); gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
SetBounds(display.work_area(), false); SetBounds(display.work_area(), false);
@ -434,6 +435,13 @@ void NativeWindowViews::Maximize() {
} }
void NativeWindowViews::Unmaximize() { void NativeWindowViews::Unmaximize() {
#if defined(OS_WIN)
if (!thick_frame_) {
NativeWindow::SetSize(last_normal_size_);
return;
}
#endif
window_->Restore(); window_->Restore();
} }
@ -471,11 +479,16 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
NotifyWindowLeaveFullScreen(); NotifyWindowLeaveFullScreen();
} }
// For window without WS_THICKFRAME style, we can not call Maximize(). // For window without WS_THICKFRAME style, we can not call SetFullscreen().
if (!thick_frame_) { if (!thick_frame_) {
auto display = if (fullscreen) {
gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition()); last_normal_size_ = GetSize();
SetBounds(display.bounds(), false); auto display =
gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
SetBounds(display.bounds(), false);
} else {
NativeWindow::SetSize(last_normal_size_);
}
return; return;
} }