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: handle WCO pressed state when going maximized -> minimized #35073

Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions shell/browser/native_window_views.h
Expand Up @@ -225,6 +225,7 @@ class NativeWindowViews : public NativeWindow,

#if BUILDFLAG(IS_WIN)
void HandleSizeEvent(WPARAM w_param, LPARAM l_param);
void ResetWindowControls();
void SetForwardMouseMessages(bool forward);
static LRESULT CALLBACK SubclassProc(HWND hwnd,
UINT msg,
Expand Down
20 changes: 13 additions & 7 deletions shell/browser/native_window_views_win.cc
Expand Up @@ -415,6 +415,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
last_window_state_ != ui::SHOW_STATE_MAXIMIZED) {
last_window_state_ = ui::SHOW_STATE_MAXIMIZED;
NotifyWindowMaximize();
ResetWindowControls();
} else if (w_param == SIZE_MINIMIZED &&
last_window_state_ != ui::SHOW_STATE_MINIMIZED) {
last_window_state_ = ui::SHOW_STATE_MINIMIZED;
Expand All @@ -440,18 +441,23 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
default:
break;
}
// If a given window was minimized/maximized and has since been
// restored, ensure the WCO buttons are set to normal state.
auto* ncv = widget()->non_client_view();
if (IsWindowControlsOverlayEnabled() && ncv) {
auto* frame_view = static_cast<WinFrameView*>(ncv->frame_view());
frame_view->caption_button_container()->ResetWindowControls();
}
ResetWindowControls();
break;
}
}
}

void NativeWindowViews::ResetWindowControls() {
// If a given window was minimized and has since been
// unminimized (restored/maximized), ensure the WCO buttons
// are reset to their default unpressed state.
auto* ncv = widget()->non_client_view();
if (IsWindowControlsOverlayEnabled() && ncv) {
auto* frame_view = static_cast<WinFrameView*>(ncv->frame_view());
frame_view->caption_button_container()->ResetWindowControls();
}
}

void NativeWindowViews::SetForwardMouseMessages(bool forward) {
if (forward && !forwarding_mouse_messages_) {
forwarding_mouse_messages_ = true;
Expand Down