diff options
author | jamiewalch <jamiewalch@chromium.org> | 2015-06-03 17:36:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-04 00:36:47 +0000 |
commit | 39b4e76f4b98556e7b935fdbeae40675daf850d7 (patch) | |
tree | 47138bc9a0ba0d8584101ef8b7094d74cc3a67aa /remoting/host/input_injector_chromeos.cc | |
parent | 192b36003ecd4265667c3625d06948bb7c3d1582 (diff) | |
download | chromium_src-39b4e76f4b98556e7b935fdbeae40675daf850d7.zip chromium_src-39b4e76f4b98556e7b935fdbeae40675daf850d7.tar.gz chromium_src-39b4e76f4b98556e7b935fdbeae40675daf850d7.tar.bz2 |
Suppress modifier key auto-repeat on ChromeOS.
ChromeOS hosts synthesize keyup events between auto-repeated keydown
events, which is the wrong thing to do in the case of modifier keys.
(See https://codereview.chromium.org/1161173003/ for the equivalent CL on Linux.)
BUG=496431
Review URL: https://codereview.chromium.org/1163073004
Cr-Commit-Position: refs/heads/master@{#332753}
Diffstat (limited to 'remoting/host/input_injector_chromeos.cc')
-rw-r--r-- | remoting/host/input_injector_chromeos.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/remoting/host/input_injector_chromeos.cc b/remoting/host/input_injector_chromeos.cc index f4bb049..cdf5b41 100644 --- a/remoting/host/input_injector_chromeos.cc +++ b/remoting/host/input_injector_chromeos.cc @@ -42,6 +42,17 @@ ui::EventFlags MouseButtonToUIFlags(MouseEvent::MouseButton button) { } } +bool IsModifierKey(ui::DomCode dom_code) { + return dom_code == ui::DomCode::CONTROL_RIGHT || + dom_code == ui::DomCode::CONTROL_LEFT || + dom_code == ui::DomCode::SHIFT_RIGHT || + dom_code == ui::DomCode::SHIFT_LEFT || + dom_code == ui::DomCode::ALT_RIGHT || + dom_code == ui::DomCode::ALT_LEFT || + dom_code == ui::DomCode::OS_RIGHT || + dom_code == ui::DomCode::OS_LEFT; +} + } // namespace // This class is run exclusively on the UI thread of the browser process. @@ -101,12 +112,14 @@ void InputInjectorChromeos::Core::InjectKeyEvent(const KeyEvent& event) { void InputInjectorChromeos::Core::HandleAutoRepeat(ui::DomCode dom_code, bool pressed) { if (pressed) { + // Key is already held down, so lift the key up to ensure this repeated + // press takes effect. + // TODO(jamiewalch): Fix SystemInputInjector::InjectKeyPress so that this + // work-around is not needed (crbug.com/496420). if (pressed_keys_.find(dom_code) != pressed_keys_.end()) { - // Key is already held down, so lift the key up to ensure this repeated - // press takes effect. - // TODO(kelvinp): Fix this code to inject auto-repeated key presses as - // the expected behavior of "down down down ... up" as opposed to current - // implementation "down up down ... up". + // Ignore repeats for modifier keys. + if (IsModifierKey(dom_code)) + return; delegate_->InjectKeyPress(dom_code, false); } |