Skip to content

Commit

Permalink
fix: queue bounds changes when moving BrowserWindows
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Mar 16, 2022
1 parent 2657383 commit 9cac5df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shell/browser/native_window_views.cc
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions shell/browser/native_window_views.h
Expand Up @@ -8,6 +8,7 @@
#include "shell/browser/native_window.h"

#include <memory>
#include <queue>
#include <set>
#include <string>
#include <vector>
Expand Down Expand Up @@ -303,6 +304,8 @@ class NativeWindowViews : public NativeWindow,
// Whether the window is currently being moved.
bool is_moving_ = false;

std::queue<gfx::Rect> 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_;
Expand Down
6 changes: 6 additions & 0 deletions shell/browser/native_window_views_win.cc
Expand Up @@ -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: {
Expand Down

0 comments on commit 9cac5df

Please sign in to comment.