0

a11y: Read out on snapping/restoring a window through shortcuts

This cl adds ChromeVox read out while snapping or restoring a window
through the shrotcut alt+[ or alt+].

Bug: 1225013
Change-Id: I062c9b3fc328bb23f6089d3b0705cc55dcaaf5e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3514030
Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/main@{#980043}
This commit is contained in:
minch
2022-03-11 00:10:50 +00:00
committed by Chromium LUCI CQ
parent dc81daa7b4
commit 48b173a911
8 changed files with 47 additions and 8 deletions

@ -4807,6 +4807,15 @@ New install
<message name="IDS_ENTER_PIP_A11Y_NOTIFICATION" is_accessibility_with_no_ui="true" desc="Accessibility text read by chromevox when a window starts picture-in-picture mode.">
Picture-in-picture started, Alt+Shift+V to focus
</message>
<message name="IDS_WM_SNAP_WINDOW_TO_LEFT_ON_SHORTCUT" desc="Accessibility text read by chromevox when snap a window to left through shortcut alt+[.">
Active window docked on left.
</message>
<message name="IDS_WM_SNAP_WINDOW_TO_RIGHT_ON_SHORTCUT" desc="Accessibility text read by chromevox when snap a window to right through shortcut alt+].">
Active window docked on right.
</message>
<message name="IDS_WM_RESTORE_SNAPPED_WINDOW_ON_SHORTCUT" desc="Accessibility text read by chromevox when restore a snapped window through shortcut alt+[ or alt+].">
Active window undocked.
</message>
<!-- Shelf Party -->
<message name="IDS_ASH_STATUS_TRAY_SHELF_PARTY_LABEL" desc="The text shown in the tray menu button that toggles Shelf Party mode.">

@ -0,0 +1 @@
167a98a858c7a6a29713d5bd3191d29f62436260

@ -0,0 +1 @@
02ba8db163c0c35f06c43219f7b37a14f979c42c

@ -0,0 +1 @@
7dfe3d3859809f0fc6b86961b1aca7410fa18ca4

@ -8,6 +8,7 @@
#include "ash/public/cpp/window_properties.h"
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/splitview/split_view_utils.h"
@ -131,8 +132,9 @@ void BaseState::CenterWindow(WindowState* window_state) {
// static
void BaseState::CycleSnap(WindowState* window_state, WMEventType event) {
auto* shell = Shell::Get();
// For tablet mode, use |TabletModeWindowState::CycleTabletSnap|.
DCHECK(!Shell::Get()->tablet_mode_controller()->InTabletMode());
DCHECK(!shell->tablet_mode_controller()->InTabletMode());
WindowStateType desired_snap_state = event == WM_EVENT_CYCLE_SNAP_PRIMARY
? WindowStateType::kPrimarySnapped
@ -144,26 +146,31 @@ void BaseState::CycleSnap(WindowState* window_state, WMEventType event) {
window_state->GetStateType() != desired_snap_state) {
window_state->RecordAndResetWindowSnapActionSource();
if (Shell::Get()->overview_controller()->InOverviewSession()) {
const bool is_desired_primary_snapped =
desired_snap_state == WindowStateType::kPrimarySnapped;
if (shell->overview_controller()->InOverviewSession()) {
// |window| must already be in split view, and so we do not need to check
// |SplitViewController::CanSnapWindow|, although in general it is more
// restrictive than |WindowState::CanSnap|.
DCHECK(SplitViewController::Get(window)->IsWindowInSplitView(window));
SplitViewController::Get(window)->SnapWindow(
window, desired_snap_state == WindowStateType::kPrimarySnapped
? SplitViewController::LEFT
: SplitViewController::RIGHT);
window, is_desired_primary_snapped ? SplitViewController::LEFT
: SplitViewController::RIGHT);
} else {
const WMEvent event(desired_snap_state == WindowStateType::kPrimarySnapped
? WM_EVENT_SNAP_PRIMARY
: WM_EVENT_SNAP_SECONDARY);
const WMEvent event(is_desired_primary_snapped ? WM_EVENT_SNAP_PRIMARY
: WM_EVENT_SNAP_SECONDARY);
window_state->OnWMEvent(&event);
}
window_state->ReadOutWindowCycleSnapAction(
is_desired_primary_snapped ? IDS_WM_SNAP_WINDOW_TO_LEFT_ON_SHORTCUT
: IDS_WM_SNAP_WINDOW_TO_RIGHT_ON_SHORTCUT);
return;
}
// If |window| is already in |desired_snap_state|, then unsnap |window|.
if (window_state->IsSnapped()) {
window_state->Restore();
window_state->ReadOutWindowCycleSnapAction(
IDS_WM_RESTORE_SNAPPED_WINDOW_ON_SHORTCUT);
return;
}
// If |window| cannot be snapped, then do a window bounce animation.

@ -13,6 +13,7 @@
#include "ash/public/cpp/window_properties.h"
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/wm/desks/desks_controller.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/overview_controller.h"
@ -534,12 +535,18 @@ void TabletModeWindowState::CycleTabletSnap(
if (window == split_view_controller->GetSnappedWindow(snap_position)) {
UpdateWindow(window_state, window_state->GetMaximizedOrCenteredWindowType(),
/*animated=*/true);
window_state->ReadOutWindowCycleSnapAction(
IDS_WM_RESTORE_SNAPPED_WINDOW_ON_SHORTCUT);
return;
}
// If |window| can snap in split view, then snap |window| in |snap_position|.
if (split_view_controller->CanSnapWindow(window)) {
window_state->RecordAndResetWindowSnapActionSource();
split_view_controller->SnapWindow(window, snap_position);
window_state->ReadOutWindowCycleSnapAction(
snap_position == SplitViewController::LEFT
? IDS_WM_SNAP_WINDOW_TO_LEFT_ON_SHORTCUT
: IDS_WM_SNAP_WINDOW_TO_RIGHT_ON_SHORTCUT);
return;
}
// Otherwise, show the cannot snap toast.

@ -7,6 +7,7 @@
#include <memory>
#include <utility>
#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/constants/ash_constants.h"
#include "ash/constants/ash_features.h"
#include "ash/focus_cycler.h"
@ -1196,4 +1197,11 @@ void WindowState::RecordAndResetWindowSnapActionSource() {
snap_action_source_ = WindowSnapActionSource::kOthers;
}
void WindowState::ReadOutWindowCycleSnapAction(int message_id) {
Shell::Get()
->accessibility_controller()
->TriggerAccessibilityAlertWithMessage(
l10n_util::GetStringUTF8(message_id));
}
} // namespace ash

@ -519,6 +519,11 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
void RecordAndResetWindowSnapActionSource();
// Read out the window cycle snap action through ChromeVox. It can be snap a
// window to the left, right or unsnapped window. `message_id` provides the
// text will be read out.
void ReadOutWindowCycleSnapAction(int message_id);
// The owner of this window settings.
aura::Window* window_;
std::unique_ptr<WindowStateDelegate> delegate_;