Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: remoting/host/input_injector_chromeos.cc

Issue 2881293002: Remove duplicate Caps Lock handling (Closed)
Patch Set: Include reference. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/input_injector_chromeos.cc
diff --git a/remoting/host/input_injector_chromeos.cc b/remoting/host/input_injector_chromeos.cc
index 1398e3f864c84e35cfefe71ce0abfe561482f073..d3bccd0b813db5f6da94ba2a3d97f74a9c30b12e 100644
--- a/remoting/host/input_injector_chromeos.cc
+++ b/remoting/host/input_injector_chromeos.cc
@@ -15,9 +15,10 @@
#include "remoting/host/chromeos/point_transformer.h"
#include "remoting/host/clipboard.h"
#include "remoting/proto/internal.pb.h"
+#include "ui/base/ime/chromeos/ime_keyboard.h"
+#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
-#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/system_input_injector.h"
@@ -45,6 +46,28 @@ ui::EventFlags MouseButtonToUIFlags(MouseEvent::MouseButton button) {
}
}
+bool shouldSetLockStates(ui::DomCode dom_code, bool key_pressed) {
+ if (!key_pressed)
+ return false;
+ switch (dom_code) {
+ // Ignores all the keys that could possibly be mapped to Caps Lock in event
+ // rewriter. Please refer to ui::EventRewriterChromeOS::RewriteModifierKeys.
+ case ui::DomCode::F16:
+ case ui::DomCode::CAPS_LOCK:
+ case ui::DomCode::META_LEFT:
+ case ui::DomCode::META_RIGHT:
+ case ui::DomCode::CONTROL_LEFT:
+ case ui::DomCode::CONTROL_RIGHT:
+ case ui::DomCode::ALT_LEFT:
+ case ui::DomCode::ALT_RIGHT:
+ case ui::DomCode::ESCAPE:
+ case ui::DomCode::BACKSPACE:
+ return false;
+ default:
+ return true;
+ }
+}
+
} // namespace
// This class is run exclusively on the UI thread of the browser process.
@@ -85,13 +108,14 @@ void InputInjectorChromeos::Core::InjectKeyEvent(const KeyEvent& event) {
DCHECK(event.has_pressed());
DCHECK(event.has_usb_keycode());
- if (event.has_lock_states()) {
- SetLockStates(event.lock_states());
- }
-
ui::DomCode dom_code =
ui::KeycodeConverter::UsbKeycodeToDomCode(event.usb_keycode());
+ if (event.has_lock_states() &&
+ shouldSetLockStates(dom_code, event.pressed())) {
+ SetLockStates(event.lock_states());
+ }
+
// Ignore events which can't be mapped.
if (dom_code != ui::DomCode::NONE) {
delegate_->InjectKeyEvent(dom_code, event.pressed(),
@@ -131,9 +155,9 @@ void InputInjectorChromeos::Core::Start(
}
void InputInjectorChromeos::Core::SetLockStates(uint32_t states) {
- ui::InputController* input_controller =
- ui::OzonePlatform::GetInstance()->GetInputController();
- input_controller->SetCapsLockEnabled(
+ chromeos::input_method::InputMethodManager* ime =
+ chromeos::input_method::InputMethodManager::Get();
+ ime->GetImeKeyboard()->SetCapsLockEnabled(
states & protocol::KeyEvent::LOCK_STATES_CAPSLOCK);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698