From 621a934160ecabb99f6e667930978c009ba0928b Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 22 Nov 2016 16:07:05 +1100 Subject: [PATCH] Fix maximize --> unmaximize positioning issue --- atom/browser/native_window_views.h | 1 + atom/browser/native_window_views_win.cc | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index caaf64b..110a4e9 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -216,6 +216,7 @@ class NativeWindowViews : public NativeWindow, // size of the window while in the normal state (not maximized, minimized or // fullscreen), so we restore it correctly. gfx::Rect last_normal_bounds_; + gfx::Rect last_normal_bounds_before_move_; // last_normal_bounds_ may or may not require update on WM_MOVE. When a // window is maximized, it is moved (WM_MOVE) to maximum size first and then diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index 85230ad..1b523e9 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -125,9 +125,12 @@ bool NativeWindowViews::PreHandleMSG( return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param)); return false; case WM_SIZE: { - consecutive_moves_ = false; // Handle window state change. HandleSizeEvent(w_param, l_param); + + consecutive_moves_ = false; + last_normal_bounds_before_move_ = last_normal_bounds_; + return false; } case WM_MOVING: { @@ -155,6 +158,9 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { switch (w_param) { case SIZE_MAXIMIZED: last_window_state_ = ui::SHOW_STATE_MAXIMIZED; + if (consecutive_moves_) { + last_normal_bounds_ = last_normal_bounds_before_move_; + } NotifyWindowMaximize(); break; case SIZE_MINIMIZED: @@ -165,14 +171,14 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { if (last_window_state_ == ui::SHOW_STATE_NORMAL) { // Window was resized so we save it's new size. last_normal_bounds_ = GetBounds(); + last_normal_bounds_before_move_ = last_normal_bounds_; } else { switch (last_window_state_) { case ui::SHOW_STATE_MAXIMIZED: last_window_state_ = ui::SHOW_STATE_NORMAL; - // When the window is restored we resize it to the previous known - // normal size. - SetBounds(last_normal_bounds_, false); + // Don't force out last known bounds onto the window as Windows + // actually gets these correct NotifyWindowUnmaximize(); break; -- 2.7.4