From db671702df352bfc68c3b0bc2fcb9999c9bdfcea Mon Sep 17 00:00:00 2001 From: liusi Date: Sun, 31 Jul 2016 21:49:54 +0800 Subject: [PATCH] fix maximize restore issue caused by restore window size change --- atom/browser/native_window_views.h | 10 ++++++++++ atom/browser/native_window_views_win.cc | 12 +++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 7ad5e8ec292..85aa3a15f46 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -214,6 +214,16 @@ class NativeWindowViews : public NativeWindow, // fullscreen), so we restore it correctly. gfx::Rect last_normal_bounds_; + // 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 sized + // (WM_SIZE). In this case, last_normal_bounds_ should not update. We keep + // last_normal_bounds_candidate_ as a candidate which will become valid + // last_normal_bounds_ if the moves are consecutive with no WM_SIZE event in + // between. + gfx::Rect last_normal_bounds_candidate_; + + bool consecutive_moves_; + // In charge of running taskbar related APIs. TaskbarHost taskbar_host_; diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index 2da0293f341..92697b5642b 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -111,18 +111,24 @@ bool NativeWindowViews::PreHandleMSG( return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param)); return false; - case WM_SIZE: + case WM_SIZE: { + consecutive_moves_ = false; // Handle window state change. HandleSizeEvent(w_param, l_param); return false; - + } case WM_MOVING: { if (!movable_) ::GetWindowRect(GetAcceleratedWidget(), (LPRECT)l_param); return false; } case WM_MOVE: { - last_normal_bounds_ = GetBounds(); + if (last_window_state_ == ui::SHOW_STATE_NORMAL) { + if(consecutive_moves_) + last_normal_bounds_ = last_normal_bounds_candidate_; + last_normal_bounds_candidate_ = GetBounds(); + consecutive_moves_ = true; + } return false; } default: