fix: snapped restoration after minimization (#48155)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2025-08-25 09:57:09 +02:00 committed by GitHub
commit 3faad259e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 5 deletions

View file

@ -310,6 +310,9 @@ class NativeWindowViews : public NativeWindow,
// Whether the window is currently being moved.
bool is_moving_ = false;
// Whether or not the window was previously snapped e.g. before minimizing.
bool was_snapped_ = false;
std::variant<std::monostate, bool, SkColor> accent_color_;
std::optional<gfx::Rect> pending_bounds_change_;

View file

@ -462,11 +462,12 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
return false;
}
case WM_SYSCOMMAND: {
// Mask is needed to account for double clicking title bar to maximize
WPARAM max_mask = 0xFFF0;
if (transparent() && ((w_param & max_mask) == SC_MAXIMIZE)) {
WPARAM cmd = w_param & 0xFFF0;
// Needed to account for double clicking title bar to maximize.
if (transparent() && (cmd == SC_MAXIMIZE))
return true;
}
if (cmd == SC_MINIMIZE)
was_snapped_ = IsSnapped();
return false;
}
case WM_INITMENU: {
@ -519,8 +520,13 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
// multiple times for one resize because of the SetWindowPlacement call.
if (w_param == SIZE_MAXIMIZED &&
last_window_state_ != ui::mojom::WindowShowState::kMaximized) {
if (last_window_state_ == ui::mojom::WindowShowState::kMinimized)
if (last_window_state_ == ui::mojom::WindowShowState::kMinimized) {
if (was_snapped_) {
SetRoundedCorners(false);
was_snapped_ = false;
}
NotifyWindowRestore();
}
last_window_state_ = ui::mojom::WindowShowState::kMaximized;
NotifyWindowMaximize();
ResetWindowControls();
@ -542,6 +548,10 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
last_window_state_ = ui::mojom::WindowShowState::kFullscreen;
NotifyWindowEnterFullScreen();
} else {
if (was_snapped_) {
SetRoundedCorners(false);
was_snapped_ = false;
}
last_window_state_ = ui::mojom::WindowShowState::kNormal;
NotifyWindowRestore();
}