Skip to content

Commit

Permalink
Overview mode: Empty space above desks bar when turn off ChromeVox.
Browse files Browse the repository at this point in the history
After closing ChromeVox panel, desks bar doesn't move to the top of the
screen. Hence there's an empty space on the previous ChromeVox panel.
Implementing OnUserWorkAreaInsetsChanged() in overview session to listen
the work area insets changes and update overview grid bounds can fix the
issue.

Test: Unit-test, Manual

Fixed: 1162413
Change-Id: I51360fbf2da2778a75c63a32fafbd6ddf945bec5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3046471
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: Cattalyya Nuengsigkapian <cattalyya@chromium.org>
Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
Commit-Queue: Connie Xu <conniekxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#907337}
  • Loading branch information
conniekxu authored and Chromium LUCI CQ committed Jul 31, 2021
1 parent 274f19d commit 94b7c67
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 4 deletions.
10 changes: 9 additions & 1 deletion ash/wm/overview/overview_grid.cc
Expand Up @@ -8,7 +8,6 @@
#include <functional>
#include <memory>
#include <utility>

#include "ash/frame_throttler/frame_throttling_controller.h"
#include "ash/metrics/histogram_macros.h"
#include "ash/public/cpp/metrics_util.h"
Expand Down Expand Up @@ -759,6 +758,15 @@ bool OverviewGrid::MaybeUpdateDesksWidgetBounds() {
return false;
}

void OverviewGrid::OnUserWorkAreaInsetsChanged(aura::Window* root_window) {
DCHECK_EQ(root_window, root_window_);
if (!desks_widget_)
return;

SetBoundsAndUpdatePositions(GetGridBoundsInScreen(root_window_),
/*ignored_items=*/{}, /*animate=*/false);
}

void OverviewGrid::UpdateDropTargetBackgroundVisibility(
OverviewItem* dragged_item,
const gfx::PointF& location_in_screen) {
Expand Down
3 changes: 3 additions & 0 deletions ash/wm/overview/overview_grid.h
Expand Up @@ -213,6 +213,9 @@ class ASH_EXPORT OverviewGrid : public SplitViewObserver,
// with this grid.
void OnDisplayMetricsChanged();

// Called by |OverviewSession::OnUserWorkAreaInsetsChanged|.
void OnUserWorkAreaInsetsChanged(aura::Window* root_window);

// SplitViewObserver:
void OnSplitViewStateChanged(SplitViewController::State previous_state,
SplitViewController::State state) override;
Expand Down
29 changes: 28 additions & 1 deletion ash/wm/overview/overview_session.cc
Expand Up @@ -144,7 +144,11 @@ OverviewSession::OverviewSession(OverviewDelegate* delegate)
active_window_before_overview_(window_util::GetActiveWindow()),
overview_start_time_(base::Time::Now()),
highlight_controller_(
std::make_unique<OverviewHighlightController>(this)) {
std::make_unique<OverviewHighlightController>(this)),
chromevox_enabled_(Shell::Get()
->accessibility_controller()
->spoken_feedback()
.enabled()) {
DCHECK(delegate_);
Shell::Get()->AddPreTargetHandler(this);
}
Expand Down Expand Up @@ -1113,6 +1117,29 @@ void OverviewSession::OnSplitViewDividerPositionChanged() {
RefreshNoWindowsWidgetBounds(/*animate=*/false);
}

void OverviewSession::OnUserWorkAreaInsetsChanged(aura::Window* root_window) {
// Don't make any change if |root_window| is not the primary root window.
// Because ChromveVox is only shown on the primary window.
if (root_window != Shell::GetPrimaryRootWindow())
return;

const bool new_chromevox_enabled =
Shell::Get()->accessibility_controller()->spoken_feedback().enabled();
// Don't make any change if ChromeVox status remains the same.
if (new_chromevox_enabled == chromevox_enabled_)
return;

// Make ChromeVox status up to date.
chromevox_enabled_ = new_chromevox_enabled;

for (std::unique_ptr<OverviewGrid>& overview_grid : grid_list_) {
// Do not handle work area insets change in |overview_grid| if its root
// window doesn't match |root_window|.
if (root_window == overview_grid->root_window())
overview_grid->OnUserWorkAreaInsetsChanged(root_window);
}
}

void OverviewSession::Move(bool reverse) {
// Do not allow moving the highlight while in the middle of a drag.
if (window_util::IsAnyWindowDragged() || desks_util::IsDraggingAnyDesk())
Expand Down
6 changes: 5 additions & 1 deletion ash/wm/overview/overview_session.h
Expand Up @@ -276,10 +276,11 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver,
// aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override;

// ShelObserver:
// ShellObserver:
void OnShellDestroying() override;
void OnShelfAlignmentChanged(aura::Window* root_window,
ShelfAlignment old_alignment) override;
void OnUserWorkAreaInsetsChanged(aura::Window* root_window) override;

// ui::EventHandler:
void OnKeyEvent(ui::KeyEvent* event) override;
Expand Down Expand Up @@ -412,6 +413,9 @@ class ASH_EXPORT OverviewSession : public display::DisplayObserver,

absl::optional<display::ScopedDisplayObserver> display_observer_;

// Boolean to indicate whether chromeVox is enabled or not.
bool chromevox_enabled_;

DISALLOW_COPY_AND_ASSIGN(OverviewSession);
};

Expand Down
43 changes: 42 additions & 1 deletion ash/wm/overview/overview_session_unittest.cc
Expand Up @@ -1058,6 +1058,47 @@ TEST_F(OverviewSessionTest, FullscreenWindowTabletMode) {
{0, 0, 3, 0, 0}, {0, 0, 3, 0, 0});
}

// Tests that when disabling ChromeVox, desks widget bounds on overview mode
// should be updated. Desks widget will be moved to the top of the screen.
TEST_F(OverviewSessionTest, DesksWidgetBoundsChangeWhenDisableChromeVox) {
std::unique_ptr<aura::Window> window1 = CreateTestWindow();

AccessibilityControllerImpl* accessibility_controller =
Shell::Get()->accessibility_controller();

// Enable ChromeVox.
const int kAccessibilityPanelHeight = 45;
// ChromeVox layout manager relies on the widget to validate ChromaVox panel's
// exist. Check AccessibilityPanelLayoutManager::SetPanelBounds.
std::unique_ptr<views::Widget> widget =
CreateTestWidget(nullptr, kShellWindowId_AccessibilityPanelContainer);
SetAccessibilityPanelHeight(kAccessibilityPanelHeight);
accessibility_controller->SetSpokenFeedbackEnabled(true,
A11Y_NOTIFICATION_NONE);
// Enable overview mode.
ToggleOverview();

const views::Widget* desks_widget =
overview_session()->grid_list()[0].get()->desks_widget();

const gfx::Rect desks_widget_bounds = desks_widget->GetWindowBoundsInScreen();
// Desks widget should lay out right below ChromeVox panel.
EXPECT_EQ(desks_widget_bounds.y(), kAccessibilityPanelHeight);

// Disable ChromeVox panel.
accessibility_controller->SetSpokenFeedbackEnabled(false,
A11Y_NOTIFICATION_NONE);
SetAccessibilityPanelHeight(0);

const gfx::Rect desks_widget_bounds_after_disable_chromeVox =
desks_widget->GetWindowBoundsInScreen();
// Desks widget should be moved to the top of the screen after
// disabling ChromeVox panel.
EXPECT_EQ(desks_widget_bounds_after_disable_chromeVox.y(), 0);

EXPECT_NE(desks_widget_bounds, desks_widget_bounds_after_disable_chromeVox);
}

TEST_F(OverviewSessionTest, SkipOverviewWindow) {
std::unique_ptr<aura::Window> window1(CreateTestWindow());
std::unique_ptr<aura::Window> window2(CreateTestWindow());
Expand Down Expand Up @@ -4657,7 +4698,7 @@ TEST_F(SplitViewOverviewSessionTest, NoClippingWhenSplitviewDisabled) {
std::unique_ptr<aura::Window> window1 = CreateTestWindow();
std::unique_ptr<aura::Window> window2 = CreateTestWindow();

// Splitview is disabled when chromeVox is enabled.
// Splitview is disabled when ChromeVox is enabled.
Shell::Get()->accessibility_controller()->SetSpokenFeedbackEnabled(
true, A11Y_NOTIFICATION_NONE);
ASSERT_FALSE(ShouldAllowSplitView());
Expand Down

0 comments on commit 94b7c67

Please sign in to comment.