Skip to content

Commit

Permalink
fix: Backport CL 3733039 and CL 3753528 for WCO
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 committed Sep 8, 2022
1 parent 4fb4167 commit 1f7b412
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions shell/browser/ui/views/win_caption_button_container.cc
Expand Up @@ -148,11 +148,12 @@ void WinCaptionButtonContainer::OnWidgetBoundsChanged(

void WinCaptionButtonContainer::UpdateButtons() {
const bool is_maximized = frame_view_->frame()->IsMaximized();
restore_button_->SetVisible(is_maximized);
maximize_button_->SetVisible(!is_maximized);
const bool maximizable = frame_view_->window()->IsMaximizable();
restore_button_->SetVisible(is_maximized && maximizable);
maximize_button_->SetVisible(!is_maximized && maximizable);

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.
Expand All @@ -161,20 +162,11 @@ void WinCaptionButtonContainer::UpdateButtons() {

// The maximize button should only be enabled if the window is
// maximizable *and* touch mode is disabled.
const bool maximizable = frame_view_->window()->IsMaximizable();
maximize_button_->SetEnabled(!is_touch && maximizable);
maximize_button_->SetEnabled(!is_touch || !is_maximized);

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

0 comments on commit 1f7b412

Please sign in to comment.