Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pend bounds change when moving BrowserWindows #33288

Merged
merged 2 commits into from Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions shell/browser/native_window_views.cc
Expand Up @@ -699,6 +699,13 @@ bool NativeWindowViews::IsFullscreen() const {
}

void NativeWindowViews::SetBounds(const gfx::Rect& bounds, bool animate) {
#if BUILDFLAG(IS_WIN)
if (is_moving_ || is_resizing_) {
pending_bounds_change_ = bounds;
return;
}
#endif

#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>
jkleinsc marked this conversation as resolved.
Show resolved Hide resolved
#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;

absl::optional<gfx::Rect> pending_bounds_change_;

// 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
9 changes: 9 additions & 0 deletions shell/browser/native_window_views_win.cc
Expand Up @@ -314,6 +314,15 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
NotifyWindowMoved();
is_moving_ = false;
}

// If the user dragged or moved the window during one or more
// calls to window.setBounds(), we want to apply the most recent
// one once they are done with the move or resize operation.
if (pending_bounds_change_.has_value()) {
SetBounds(pending_bounds_change_.value(), false /* animate */);
pending_bounds_change_.reset();
}

return false;
}
case WM_MOVING: {
Expand Down