Commit 140da00a authored by Josiah K's avatar Josiah K Committed by Commit Bot

Add support for panning the magnifier viewport with Ctrl+Alt+Arrow keys

AX-Relnotes: Add support for panning the fullscreen magnifier viewport with Ctrl+Alt+Arrow keys
Change-Id: I263be6236f7060cd12d2037e82f070a6f0863cf4
Bug: 1140624
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510911
Commit-Queue: Josiah Krutz <josiahk@google.com>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822900}
parent 58e927e3
......@@ -6,6 +6,8 @@
#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/accessibility/point_scan_controller.h"
#include "ash/keyboard/keyboard_util.h"
#include "ash/magnifier/magnification_controller.h"
#include "ash/public/cpp/accessibility_event_rewriter_delegate.h"
#include "ash/shell.h"
#include "ui/chromeos/events/event_rewriter_chromeos.h"
......@@ -199,6 +201,65 @@ bool AccessibilityEventRewriter::RewriteEventForSwitchAccess(
return capture;
}
bool AccessibilityEventRewriter::RewriteEventForMagnifier(
const ui::Event& event,
const Continuation continuation) {
if (!event.IsKeyEvent())
return false;
const ui::KeyEvent* key_event = event.AsKeyEvent();
if (!keyboard_util::IsArrowKeyCode(key_event->key_code()) ||
!key_event->IsControlDown() || !key_event->IsAltDown()) {
return false;
}
if (key_event->type() == ui::ET_KEY_PRESSED) {
// If first time key is pressed (e.g. not repeat), start scrolling.
if (!(key_event->flags() & ui::EF_IS_REPEAT))
OnMagnifierKeyPressed(key_event);
// Either way (first or repeat), capture key press.
return true;
}
if (key_event->type() == ui::ET_KEY_RELEASED) {
OnMagnifierKeyReleased(key_event);
return true;
}
return false;
}
void AccessibilityEventRewriter::OnMagnifierKeyPressed(
const ui::KeyEvent* event) {
MagnificationController* controller =
Shell::Get()->magnification_controller();
switch (event->key_code()) {
case ui::VKEY_UP:
controller->SetScrollDirection(MagnificationController::SCROLL_UP);
break;
case ui::VKEY_DOWN:
controller->SetScrollDirection(MagnificationController::SCROLL_DOWN);
break;
case ui::VKEY_LEFT:
controller->SetScrollDirection(MagnificationController::SCROLL_LEFT);
break;
case ui::VKEY_RIGHT:
controller->SetScrollDirection(MagnificationController::SCROLL_RIGHT);
break;
default:
NOTREACHED() << "Unexpected keyboard_code:" << event->key_code();
}
}
void AccessibilityEventRewriter::OnMagnifierKeyReleased(
const ui::KeyEvent* event) {
MagnificationController* controller =
Shell::Get()->magnification_controller();
controller->SetScrollDirection(MagnificationController::SCROLL_NONE);
}
void AccessibilityEventRewriter::UpdateKeyboardDeviceIds() {
keyboard_device_ids_.clear();
for (auto& keyboard :
......@@ -224,6 +285,10 @@ ui::EventDispatchDetails AccessibilityEventRewriter::RewriteEvent(
captured = RewriteEventForSwitchAccess(event, continuation);
}
if (!captured && Shell::Get()->magnification_controller()->IsEnabled()) {
captured = RewriteEventForMagnifier(event, continuation);
}
if (!captured) {
captured = RewriteEventForChromeVox(event, continuation);
}
......
......@@ -24,6 +24,7 @@ namespace ash {
class AccessibilityEventRewriterDelegate;
enum class SwitchAccessCommand;
enum class MagnifierCommand;
// AccessibilityEventRewriter sends key events to Accessibility extensions (such
// as ChromeVox and Switch Access) via the delegate when the corresponding
......@@ -79,6 +80,10 @@ class ASH_EXPORT AccessibilityEventRewriter
const Continuation continuation);
bool RewriteEventForSwitchAccess(const ui::Event& event,
const Continuation continuation);
bool RewriteEventForMagnifier(const ui::Event& event,
const Continuation continuation);
void OnMagnifierKeyPressed(const ui::KeyEvent* event);
void OnMagnifierKeyReleased(const ui::KeyEvent* event);
// Updates the list of allowed keyboard device ids based on the current set of
// keyboard input types.
......
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