From c4de246bfbdc4f2ec6611b922fdf1723fab1c02f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 9 Jul 2016 23:04:42 +0900 Subject: [PATCH] Correctly handle unmaximize --- atom/browser/native_window_views.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 20e43a1b7..7b65dfc8b 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -284,7 +284,7 @@ NativeWindowViews::NativeWindowViews( last_window_state_ = ui::SHOW_STATE_FULLSCREEN; else last_window_state_ = ui::SHOW_STATE_NORMAL; - last_normal_size_ = gfx::Size(widget_size_); + last_normal_size_ = widget_size_; if (!has_frame()) { // Set Window style so that we get a minimize and maximize animation when @@ -419,6 +419,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(); auto display = gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition()); SetBounds(display.work_area(), false); @@ -434,6 +435,13 @@ void NativeWindowViews::Maximize() { } void NativeWindowViews::Unmaximize() { +#if defined(OS_WIN) + if (!thick_frame_) { + NativeWindow::SetSize(last_normal_size_); + return; + } +#endif + window_->Restore(); } @@ -471,11 +479,16 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) { 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_) { - auto display = - gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition()); - SetBounds(display.bounds(), false); + if (fullscreen) { + last_normal_size_ = GetSize(); + auto display = + gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition()); + SetBounds(display.bounds(), false); + } else { + NativeWindow::SetSize(last_normal_size_); + } return; } -- 2.34.1