mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
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:
@@ -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_;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user