Commit 77c7b9ba authored by Richard Chui's avatar Richard Chui Committed by Commit Bot

Overview Desks: Display close button for switch access

Make the close desk button visible and navigable for switch access
users.

Switch access users are unable to execute keyboard commands through
their physical switch devices, rendering them unable to close virtual
spaces without the close buttons being visible.

Test: manual
Change-Id: I8624783a586424307971f0a27ba9c80456fa788b
Fixed: 997011
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391594
Commit-Queue: Richard Chui <richui@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805597}
parent 1418c34a
...@@ -75,15 +75,13 @@ DeskMiniView::DeskMiniView(DesksBarView* owner_bar, ...@@ -75,15 +75,13 @@ DeskMiniView::DeskMiniView(DesksBarView* owner_bar,
SetPaintToLayer(); SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
auto close_desk_button = std::make_unique<CloseDeskButton>(this);
close_desk_button->SetVisible(false);
// TODO(afakhry): Tooltips. // TODO(afakhry): Tooltips.
desk_preview_ = AddChildView(std::make_unique<DeskPreviewView>(this)); desk_preview_ = AddChildView(std::make_unique<DeskPreviewView>(this));
desk_name_view_ = AddChildView(std::move(desk_name_view)); desk_name_view_ = AddChildView(std::move(desk_name_view));
close_desk_button_ = AddChildView(std::move(close_desk_button)); close_desk_button_ = AddChildView(std::make_unique<CloseDeskButton>(this));
UpdateCloseButtonVisibility();
UpdateBorderColor(); UpdateBorderColor();
} }
...@@ -104,13 +102,16 @@ bool DeskMiniView::IsDeskNameBeingModified() const { ...@@ -104,13 +102,16 @@ bool DeskMiniView::IsDeskNameBeingModified() const {
return desk_name_view_->HasFocus(); return desk_name_view_->HasFocus();
} }
void DeskMiniView::OnHoverStateMayHaveChanged() { void DeskMiniView::UpdateCloseButtonVisibility() {
// Don't show the close button when hovered while the dragged window is on // Don't show the close button when hovered while the dragged window is on
// the DesksBarView. // the DesksBarView.
// For switch access, setting the close button to visible allows users to
// navigate to it.
close_desk_button_->SetVisible( close_desk_button_->SetVisible(
DesksController::Get()->CanRemoveDesks() && DesksController::Get()->CanRemoveDesks() &&
!owner_bar_->dragged_item_over_bar() && !owner_bar_->dragged_item_over_bar() &&
(IsMouseHovered() || force_show_close_button_)); (IsMouseHovered() || force_show_close_button_ ||
Shell::Get()->accessibility_controller()->IsSwitchAccessRunning()));
} }
void DeskMiniView::OnWidgetGestureTap(const gfx::Rect& screen_rect, void DeskMiniView::OnWidgetGestureTap(const gfx::Rect& screen_rect,
...@@ -124,7 +125,7 @@ void DeskMiniView::OnWidgetGestureTap(const gfx::Rect& screen_rect, ...@@ -124,7 +125,7 @@ void DeskMiniView::OnWidgetGestureTap(const gfx::Rect& screen_rect,
(!is_long_gesture && close_desk_button_->GetVisible() && (!is_long_gesture && close_desk_button_->GetVisible() &&
close_desk_button_->DoesIntersectScreenRect(screen_rect)); close_desk_button_->DoesIntersectScreenRect(screen_rect));
if (old_force_show_close_button != force_show_close_button_) if (old_force_show_close_button != force_show_close_button_)
OnHoverStateMayHaveChanged(); UpdateCloseButtonVisibility();
} }
void DeskMiniView::UpdateBorderColor() { void DeskMiniView::UpdateBorderColor() {
......
...@@ -57,8 +57,8 @@ class ASH_EXPORT DeskMiniView ...@@ -57,8 +57,8 @@ class ASH_EXPORT DeskMiniView
bool IsDeskNameBeingModified() const; bool IsDeskNameBeingModified() const;
// Updates the visibility state of the close button depending on whether this // Updates the visibility state of the close button depending on whether this
// view is mouse hovered. // view is mouse hovered, or if switch access is enabled.
void OnHoverStateMayHaveChanged(); void UpdateCloseButtonVisibility();
// Gesture tapping may affect the visibility of the close button. There's only // Gesture tapping may affect the visibility of the close button. There's only
// one mini_view that shows the close button on long press at any time. // one mini_view that shows the close button on long press at any time.
......
...@@ -221,7 +221,7 @@ float DesksBarView::GetOnHoverWindowSizeScaleFactor() const { ...@@ -221,7 +221,7 @@ float DesksBarView::GetOnHoverWindowSizeScaleFactor() const {
void DesksBarView::OnHoverStateMayHaveChanged() { void DesksBarView::OnHoverStateMayHaveChanged() {
for (auto* mini_view : mini_views_) for (auto* mini_view : mini_views_)
mini_view->OnHoverStateMayHaveChanged(); mini_view->UpdateCloseButtonVisibility();
} }
void DesksBarView::OnGestureTap(const gfx::Rect& screen_rect, void DesksBarView::OnGestureTap(const gfx::Rect& screen_rect,
...@@ -340,15 +340,18 @@ void DesksBarView::OnDeskRemoved(const Desk* desk) { ...@@ -340,15 +340,18 @@ void DesksBarView::OnDeskRemoved(const Desk* desk) {
const int begin_x = GetFirstMiniViewXOffset(); const int begin_x = GetFirstMiniViewXOffset();
// Remove the mini view from the list now. And remove it from its parent // Remove the mini view from the list now. And remove it from its parent
// after the animation is done. // after the animation is done.
DeskMiniView* mini_view = *iter; DeskMiniView* removed_mini_view = *iter;
auto partition_iter = mini_views_.erase(iter); auto partition_iter = mini_views_.erase(iter);
UpdateMinimumWidthToFitContents(); UpdateMinimumWidthToFitContents();
overview_grid_->OnDesksChanged(); overview_grid_->OnDesksChanged();
new_desk_button_->UpdateButtonState(); new_desk_button_->UpdateButtonState();
for (auto* mini_view : mini_views_)
mini_view->UpdateCloseButtonVisibility();
PerformRemoveDeskMiniViewAnimation( PerformRemoveDeskMiniViewAnimation(
mini_view, removed_mini_view,
std::vector<DeskMiniView*>(mini_views_.begin(), partition_iter), std::vector<DeskMiniView*>(mini_views_.begin(), partition_iter),
std::vector<DeskMiniView*>(partition_iter, mini_views_.end()), std::vector<DeskMiniView*>(partition_iter, mini_views_.end()),
begin_x - GetFirstMiniViewXOffset()); begin_x - GetFirstMiniViewXOffset());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment