Commit f77a853b authored by Katie D's avatar Katie D Committed by Commit Bot

Autoclick widget responds to shelf bubble changes in OOBE.

BaseState::OnWMEvent is not called when the system settings
bubble is shown or hidden in the OOBE and Login screens,
seemingly because WorkspaceLayoutManager::NotifySystemUiAreaChanged
has no windows_. This change pushes the logic to notify autoclick
when workspace changes occur into workspace_layout_manager.

Bug: 966154
Change-Id: I486d7962653819bd70854a3991fc2e2c7d871926
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627897
Commit-Queue: Katie Dektar <katie@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664829}
parent 184a3b92
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/system/accessibility/accessibility_feature_disable_dialog.h" #include "ash/system/accessibility/accessibility_feature_disable_dialog.h"
#include "ash/system/accessibility/autoclick_menu_bubble_controller.h" #include "ash/system/accessibility/autoclick_menu_bubble_controller.h"
#include "ash/system/accessibility/autoclick_menu_view.h" #include "ash/system/accessibility/autoclick_menu_view.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/wm/collision_detection/collision_detection_utils.h" #include "ash/wm/collision_detection/collision_detection_utils.h"
#include "ash/wm/desks/desks_util.h" #include "ash/wm/desks/desks_util.h"
...@@ -913,6 +914,43 @@ TEST_F(AutoclickTest, BubbleMovesWithShelfPositionChange) { ...@@ -913,6 +914,43 @@ TEST_F(AutoclickTest, BubbleMovesWithShelfPositionChange) {
shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
} }
TEST_F(AutoclickTest, AvoidsShelfBubble) {
const struct {
session_manager::SessionState session_state;
} kTestCases[]{
{session_manager::SessionState::OOBE},
{session_manager::SessionState::LOGIN_PRIMARY},
{session_manager::SessionState::ACTIVE},
{session_manager::SessionState::LOCKED},
};
for (auto test : kTestCases) {
GetSessionControllerClient()->SetSessionState(test.session_state);
// Set up autoclick and the shelf.
Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
mojom::AutoclickMenuPosition::kBottomRight);
auto* unified_system_tray = GetPrimaryUnifiedSystemTray();
EXPECT_FALSE(unified_system_tray->IsBubbleShown());
AutoclickMenuView* menu = GetAutoclickMenuView();
ASSERT_TRUE(menu);
gfx::Rect menu_bounds = menu->GetBoundsInScreen();
unified_system_tray->ShowBubble(true /* show_by_click */);
gfx::Rect new_menu_bounds = menu->GetBoundsInScreen();
// Y is unchanged when the bubble shows.
EXPECT_TRUE(abs(menu_bounds.y() - new_menu_bounds.y()) < 5);
// X is pushed over by at least the bubble's bounds.
EXPECT_TRUE(menu_bounds.x() -
unified_system_tray->GetBubbleBoundsInScreen().width() >
new_menu_bounds.x());
unified_system_tray->CloseBubble();
new_menu_bounds = menu->GetBoundsInScreen();
EXPECT_EQ(menu_bounds, new_menu_bounds);
}
}
TEST_F(AutoclickTest, ConfirmationDialogShownWhenDisablingFeature) { TEST_F(AutoclickTest, ConfirmationDialogShownWhenDisablingFeature) {
// Enable and disable with the AccessibilityController to get real use-case // Enable and disable with the AccessibilityController to get real use-case
// of the dialog. // of the dialog.
......
...@@ -27,11 +27,6 @@ BaseState::~BaseState() = default; ...@@ -27,11 +27,6 @@ BaseState::~BaseState() = default;
void BaseState::OnWMEvent(WindowState* window_state, const WMEvent* event) { void BaseState::OnWMEvent(WindowState* window_state, const WMEvent* event) {
if (event->IsWorkspaceEvent()) { if (event->IsWorkspaceEvent()) {
HandleWorkspaceEvents(window_state, event); HandleWorkspaceEvents(window_state, event);
if (Shell::Get()->accessibility_controller()->autoclick_enabled()) {
Shell::Get()
->accessibility_controller()
->UpdateAutoclickMenuBoundsIfNeeded();
}
if (window_state->IsPip()) if (window_state->IsPip())
window_state->UpdatePipBounds(); window_state->UpdatePipBounds();
return; return;
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include "ash/accessibility/accessibility_controller.h"
#include "ash/autoclick/autoclick_controller.h"
#include "ash/keyboard/ui/keyboard_controller.h" #include "ash/keyboard/ui/keyboard_controller.h"
#include "ash/keyboard/ui/keyboard_controller_observer.h" #include "ash/keyboard/ui/keyboard_controller_observer.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
...@@ -480,6 +482,11 @@ void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( ...@@ -480,6 +482,11 @@ void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange(
Shell::Get()->session_controller()->IsScreenLocked()) Shell::Get()->session_controller()->IsScreenLocked())
return; return;
// The PIP avoids the autoclick bubble, so here we update the autoclick
// position before sending the WMEvent, so that if the PIP is
// also being shown the PIPs calculation does not need to take place twice.
NotifyAutoclickWorkspaceChanged();
// If a user plugs an external display into a laptop running Aura the // If a user plugs an external display into a laptop running Aura the
// display size will change. Maximized windows need to resize to match. // display size will change. Maximized windows need to resize to match.
// We also do this when developers running Aura on a desktop manually resize // We also do this when developers running Aura on a desktop manually resize
...@@ -526,10 +533,22 @@ void WorkspaceLayoutManager::UpdateAlwaysOnTop( ...@@ -526,10 +533,22 @@ void WorkspaceLayoutManager::UpdateAlwaysOnTop(
} }
void WorkspaceLayoutManager::NotifySystemUiAreaChanged() { void WorkspaceLayoutManager::NotifySystemUiAreaChanged() {
// The PIP avoids the autoclick bubble, so here we update the autoclick
// position before sending the WMEvent, so that if the PIP is
// also being shown the PIPs calculation does not need to take place twice.
NotifyAutoclickWorkspaceChanged();
for (auto* window : windows_) { for (auto* window : windows_) {
wm::WMEvent event(wm::WM_EVENT_SYSTEM_UI_AREA_CHANGED); wm::WMEvent event(wm::WM_EVENT_SYSTEM_UI_AREA_CHANGED);
wm::GetWindowState(window)->OnWMEvent(&event); wm::GetWindowState(window)->OnWMEvent(&event);
} }
} }
void WorkspaceLayoutManager::NotifyAutoclickWorkspaceChanged() {
if (Shell::Get()->accessibility_controller()->autoclick_enabled()) {
Shell::Get()
->accessibility_controller()
->UpdateAutoclickMenuBoundsIfNeeded();
}
}
} // namespace ash } // namespace ash
...@@ -166,6 +166,11 @@ class ASH_EXPORT WorkspaceLayoutManager ...@@ -166,6 +166,11 @@ class ASH_EXPORT WorkspaceLayoutManager
// changes to system ui areas on the display they are on. // changes to system ui areas on the display they are on.
void NotifySystemUiAreaChanged(); void NotifySystemUiAreaChanged();
// Notifies the autoclick controller about a workspace event. If autoclick
// is enabled, the autoclick bubble may need to move in response to that
// event.
void NotifyAutoclickWorkspaceChanged();
aura::Window* window_; aura::Window* window_;
aura::Window* root_window_; aura::Window* root_window_;
RootWindowController* root_window_controller_; RootWindowController* root_window_controller_;
......
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