From 9ec710e99c3cbb92de59e00936231046f772beac Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:57:48 -0400 Subject: [PATCH] fix: WCO maximize button visibility when non-maximizable (#41806) fix: WCO button visibility when non-maximizable Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- .../ui/views/win_caption_button_container.cc | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/shell/browser/ui/views/win_caption_button_container.cc b/shell/browser/ui/views/win_caption_button_container.cc index ff8fa9478d7a6..1d7987801913e 100644 --- a/shell/browser/ui/views/win_caption_button_container.cc +++ b/shell/browser/ui/views/win_caption_button_container.cc @@ -156,36 +156,26 @@ void WinCaptionButtonContainer::UpdateBackground() { } void WinCaptionButtonContainer::UpdateButtons() { - const bool is_maximized = frame_view_->frame()->IsMaximized(); - restore_button_->SetVisible(is_maximized); - maximize_button_->SetVisible(!is_maximized); - const bool minimizable = frame_view_->window()->IsMinimizable(); minimize_button_->SetEnabled(minimizable); minimize_button_->SetVisible(minimizable); - // In touch mode, windows cannot be taken out of fullscreen or tiled mode, so - // the maximize/restore button should be disabled. - const bool is_touch = ui::TouchUiController::Get()->touch_ui(); - restore_button_->SetEnabled(!is_touch); + const bool is_maximized = frame_view_->frame()->IsMaximized(); + const bool maximizable = frame_view_->window()->IsMaximizable(); + restore_button_->SetVisible(is_maximized && maximizable); + maximize_button_->SetVisible(!is_maximized && maximizable); // In touch mode, windows cannot be taken out of fullscreen or tiled mode, so // the maximize/restore button should be disabled, unless the window is not // maximized. - const bool maximizable = frame_view_->window()->IsMaximizable(); - maximize_button_->SetEnabled(!(is_touch && is_maximized) && maximizable); + const bool is_touch = ui::TouchUiController::Get()->touch_ui(); + restore_button_->SetEnabled(!is_touch); + maximize_button_->SetEnabled(!is_touch || !is_maximized); + // If the window isn't closable, the close button should be disabled. const bool closable = frame_view_->window()->IsClosable(); close_button_->SetEnabled(closable); - // If all three of closable, maximizable, and minimizable are disabled, - // Windows natively only shows the disabled closable button. Copy that - // behavior here. - if (!maximizable && !closable && !minimizable) { - minimize_button_->SetVisible(false); - maximize_button_->SetVisible(false); - } - InvalidateLayout(); } } // namespace electron