From d04072d1eba8085acae4b58c0fed26e3088262f2 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 26 Aug 2019 23:04:20 +0200 Subject: [PATCH] fix: don't call SetBounds on restore (#19886) --- shell/browser/native_window_views.cc | 1 - shell/browser/native_window_views.h | 17 ------ shell/browser/native_window_views_win.cc | 69 +++++++----------------- 3 files changed, 20 insertions(+), 67 deletions(-) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 6ec3f2d7bb7..63334e64bbf 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -305,7 +305,6 @@ NativeWindowViews::NativeWindowViews(const mate::Dictionary& options, last_window_state_ = ui::SHOW_STATE_FULLSCREEN; else last_window_state_ = ui::SHOW_STATE_NORMAL; - last_normal_bounds_ = GetBounds(); #endif #if defined(OS_LINUX) diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h index 5e46be51bf4..afa52417634 100644 --- a/shell/browser/native_window_views.h +++ b/shell/browser/native_window_views.h @@ -246,23 +246,6 @@ class NativeWindowViews : public NativeWindow, gfx::Rect last_normal_placement_bounds_; - // There's an issue with restore on Windows, that sometimes causes the Window - // to receive the wrong size (#2498). To circumvent that, we keep tabs on the - // 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 - // 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/shell/browser/native_window_views_win.cc b/shell/browser/native_window_views_win.cc index 72adbf19f0a..3e8cb109fdd 100644 --- a/shell/browser/native_window_views_win.cc +++ b/shell/browser/native_window_views_win.cc @@ -409,10 +409,6 @@ bool NativeWindowViews::PreHandleMSG(UINT message, case WM_SIZE: { // 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: { @@ -428,15 +424,6 @@ bool NativeWindowViews::PreHandleMSG(UINT message, } return false; } - case WM_MOVE: { - 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; - } case WM_ENDSESSION: { if (w_param) { NotifyWindowEndSession(); @@ -467,9 +454,6 @@ 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_; - } if (!has_frame()) { TriggerNCCalcSize(GetAcceleratedWidget()); @@ -491,40 +475,27 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { NotifyWindowMinimize(); break; case SIZE_RESTORED: - 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: + switch (last_window_state_) { + case ui::SHOW_STATE_MAXIMIZED: + last_window_state_ = ui::SHOW_STATE_NORMAL; + NotifyWindowUnmaximize(); + + if (!has_frame()) { + TriggerNCCalcSize(GetAcceleratedWidget()); + } + + break; + case ui::SHOW_STATE_MINIMIZED: + if (IsFullscreen()) { + last_window_state_ = ui::SHOW_STATE_FULLSCREEN; + NotifyWindowEnterFullScreen(); + } else { last_window_state_ = ui::SHOW_STATE_NORMAL; - NotifyWindowUnmaximize(); - - if (!has_frame()) { - TriggerNCCalcSize(GetAcceleratedWidget()); - } - - break; - case ui::SHOW_STATE_MINIMIZED: - if (IsFullscreen()) { - last_window_state_ = ui::SHOW_STATE_FULLSCREEN; - NotifyWindowEnterFullScreen(); - } else { - last_window_state_ = ui::SHOW_STATE_NORMAL; - - // When the window is restored we resize it to the previous known - // normal size. - if (has_frame()) { - SetBounds(last_normal_bounds_, false); - } - - NotifyWindowRestore(); - } - break; - default: - break; - } + NotifyWindowRestore(); + } + break; + default: + break; } break; }