fix: snapped restoration after minimization (#48157)

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 13:22:28 +02:00
committed by GitHub
parent f28d08ad86
commit 9e631b62d8
2 changed files with 18 additions and 5 deletions

View File

@@ -323,6 +323,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

@@ -464,11 +464,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: {
@@ -521,8 +522,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();
@@ -544,6 +550,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();
}