fix: WCO pressed background state updates (#34771)

This commit is contained in:
Shelley Vohr 2022-07-07 17:17:20 +02:00 committed by GitHub
parent 47d8d4cc5c
commit 7ec88584b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -11,6 +11,7 @@
#include "shell/browser/browser.h"
#include "shell/browser/native_window_views.h"
#include "shell/browser/ui/views/root_view.h"
#include "shell/browser/ui/views/win_frame_view.h"
#include "shell/common/electron_constants.h"
#include "ui/display/display.h"
#include "ui/display/win/screen_win.h"
@ -421,7 +422,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
}
break;
}
case SIZE_RESTORED:
case SIZE_RESTORED: {
switch (last_window_state_) {
case ui::SHOW_STATE_MAXIMIZED:
last_window_state_ = ui::SHOW_STATE_NORMAL;
@ -439,9 +440,17 @@ 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();
}
break;
}
}
}
void NativeWindowViews::SetForwardMouseMessages(bool forward) {
if (forward && !forwarding_mouse_messages_) {

View file

@ -46,6 +46,9 @@ class WinCaptionButtonContainer : public views::View,
// time, and both are disabled in tablet UI mode.
void UpdateButtons();
// Reset window button states to STATE_NORMAL.
void ResetWindowControls();
private:
// views::View:
void AddedToWidget() override;
@ -55,8 +58,6 @@ class WinCaptionButtonContainer : public views::View,
void OnWidgetBoundsChanged(views::Widget* widget,
const gfx::Rect& new_bounds) override;
void ResetWindowControls();
WinFrameView* const frame_view_;
WinCaptionButton* const minimize_button_;
WinCaptionButton* const maximize_button_;