Commit b40b6611 authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

[Switch Access] Use source_device_id to identify physical key events.

This addresses a bug in Switch Access (go/cros-switch) where users got
stuck in editable text fields. The root cause was that the physical key
events were perceived to be virtual key events by the Switch Access
event handler. The solution is to more precisely identify which key
events come from physical devices.

Bug: 996893
Change-Id: Id39130ce7edc7f933c1be43f434b5a08f909f19f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1804395
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699053}
parent dae6d099
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "ash/public/cpp/switch_access_event_handler_delegate.h" #include "ash/public/cpp/switch_access_event_handler_delegate.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_utils.h"
namespace ash { namespace ash {
...@@ -101,8 +103,17 @@ void SwitchAccessEventHandler::OnKeyEvent(ui::KeyEvent* event) { ...@@ -101,8 +103,17 @@ void SwitchAccessEventHandler::OnKeyEvent(ui::KeyEvent* event) {
bool SwitchAccessEventHandler::ShouldCancelEvent( bool SwitchAccessEventHandler::ShouldCancelEvent(
const ui::KeyEvent& event) const { const ui::KeyEvent& event) const {
// Ignore virtual key events so users can type with the onscreen keyboard. // Ignore virtual key events so users can type with the onscreen keyboard.
if (ignore_virtual_key_events_ && !event.HasNativeEvent()) if (ignore_virtual_key_events_ &&
return false; event.source_device_id() == ui::ED_UNKNOWN_DEVICE) {
// When running Chrome OS on Linux, the source_device_id property is never
// populated.
auto* properties = event.properties();
bool is_linux_xevent =
properties &&
properties->find(ui::kPropertyKeyboardIBusFlag) != properties->end();
if (!is_linux_xevent)
return false;
}
if (forward_key_events_) if (forward_key_events_)
return true; return true;
......
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