From 9cac5df27a4c89cc39a1d17d3c12105f29aa25af Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 16 Mar 2022 10:45:44 +0100 Subject: [PATCH] fix: queue bounds changes when moving BrowserWindows --- shell/browser/native_window_views.cc | 5 +++++ shell/browser/native_window_views.h | 3 +++ shell/browser/native_window_views_win.cc | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index a5c58964016c3..9ac1a31fee736 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -699,6 +699,11 @@ bool NativeWindowViews::IsFullscreen() const { } void NativeWindowViews::SetBounds(const gfx::Rect& bounds, bool animate) { + if (is_moving_ || is_resizing_) { + pending_bounds_changes_.push(bounds); + return; + } + #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) // On Linux and Windows the minimum and maximum size should be updated with // window size when window is not resizable. diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h index db178209ad6a5..bc75f2e82dda7 100644 --- a/shell/browser/native_window_views.h +++ b/shell/browser/native_window_views.h @@ -8,6 +8,7 @@ #include "shell/browser/native_window.h" #include +#include #include #include #include @@ -303,6 +304,8 @@ class NativeWindowViews : public NativeWindow, // Whether the window is currently being moved. bool is_moving_ = false; + std::queue pending_bounds_changes_; + // The color to use as the theme and symbol colors respectively for Window // Controls Overlay if enabled on Windows. SkColor overlay_button_color_; diff --git a/shell/browser/native_window_views_win.cc b/shell/browser/native_window_views_win.cc index 01d88048af794..a32bd6b71ec3c 100644 --- a/shell/browser/native_window_views_win.cc +++ b/shell/browser/native_window_views_win.cc @@ -314,6 +314,12 @@ bool NativeWindowViews::PreHandleMSG(UINT message, NotifyWindowMoved(); is_moving_ = false; } + if (!pending_bounds_changes_.empty()) { + auto next_bounds_change = pending_bounds_changes_.front(); + pending_bounds_changes_.pop(); + SetBounds(next_bounds_change, false /* animate */); + } + return false; } case WM_MOVING: {