OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/events/event_rewriter.h" | 5 #include "chrome/browser/chromeos/events/event_rewriter.h" |
6 | 6 |
7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
9 #include <X11/XF86keysym.h> | 9 #include <X11/XF86keysym.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
23 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
24 #include "chrome/browser/chromeos/events/keyboard_driven_event_rewriter.h" | 24 #include "chrome/browser/chromeos/events/keyboard_driven_event_rewriter.h" |
25 #include "chrome/browser/chromeos/events/xinput_hierarchy_changed_event_listener
.h" | 25 #include "chrome/browser/chromeos/events/xinput_hierarchy_changed_event_listener
.h" |
26 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 26 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
27 #include "chrome/browser/chromeos/login/user_manager.h" | 27 #include "chrome/browser/chromeos/login/user_manager.h" |
28 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chromeos/chromeos_switches.h" | 30 #include "chromeos/chromeos_switches.h" |
| 31 #include "chromeos/ime/ime_keyboard.h" |
31 #include "chromeos/ime/input_method_manager.h" | 32 #include "chromeos/ime/input_method_manager.h" |
32 #include "chromeos/ime/xkeyboard.h" | |
33 #include "ui/base/x/x11_util.h" | 33 #include "ui/base/x/x11_util.h" |
34 #include "ui/events/event.h" | 34 #include "ui/events/event.h" |
35 #include "ui/events/event_utils.h" | 35 #include "ui/events/event_utils.h" |
36 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 36 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
37 #include "ui/events/platform/platform_event_source.h" | 37 #include "ui/events/platform/platform_event_source.h" |
38 #include "ui/wm/core/window_util.h" | 38 #include "ui/wm/core/window_util.h" |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 const int kBadDeviceId = -1; | 42 const int kBadDeviceId = -1; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 chromeos::input_method::InputMethodManager::Get(); | 126 chromeos::input_method::InputMethodManager::Get(); |
127 return manager->IsISOLevel5ShiftUsedByCurrentInputMethod(); | 127 return manager->IsISOLevel5ShiftUsedByCurrentInputMethod(); |
128 } | 128 } |
129 | 129 |
130 } // namespace | 130 } // namespace |
131 | 131 |
132 namespace chromeos { | 132 namespace chromeos { |
133 | 133 |
134 EventRewriter::EventRewriter() | 134 EventRewriter::EventRewriter() |
135 : last_device_id_(kBadDeviceId), | 135 : last_device_id_(kBadDeviceId), |
136 xkeyboard_for_testing_(NULL), | 136 keyboard_for_testing_(NULL), |
137 keyboard_driven_event_rewriter_(new KeyboardDrivenEventRewriter), | 137 keyboard_driven_event_rewriter_(new KeyboardDrivenEventRewriter), |
138 pref_service_for_testing_(NULL) { | 138 pref_service_for_testing_(NULL) { |
139 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); | 139 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); |
140 if (base::SysInfo::IsRunningOnChromeOS()) { | 140 if (base::SysInfo::IsRunningOnChromeOS()) { |
141 XInputHierarchyChangedEventListener::GetInstance()->AddObserver(this); | 141 XInputHierarchyChangedEventListener::GetInstance()->AddObserver(this); |
142 } | 142 } |
143 RefreshKeycodes(); | 143 RefreshKeycodes(); |
144 } | 144 } |
145 | 145 |
146 EventRewriter::~EventRewriter() { | 146 EventRewriter::~EventRewriter() { |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 // Next, remap modifier bits. | 514 // Next, remap modifier bits. |
515 unsigned int remapped_native_modifiers = 0U; | 515 unsigned int remapped_native_modifiers = 0U; |
516 GetRemappedModifierMasks(xkey->state, &remapped_native_modifiers); | 516 GetRemappedModifierMasks(xkey->state, &remapped_native_modifiers); |
517 | 517 |
518 // Toggle Caps Lock if the remapped key is ui::VKEY_CAPITAL, but do nothing if | 518 // Toggle Caps Lock if the remapped key is ui::VKEY_CAPITAL, but do nothing if |
519 // the original key is ui::VKEY_CAPITAL (i.e. a Caps Lock key on an external | 519 // the original key is ui::VKEY_CAPITAL (i.e. a Caps Lock key on an external |
520 // keyboard is pressed) since X can handle that case. | 520 // keyboard is pressed) since X can handle that case. |
521 if (event->type == KeyPress && | 521 if (event->type == KeyPress && |
522 original_keycode != ui::VKEY_CAPITAL && | 522 original_keycode != ui::VKEY_CAPITAL && |
523 remapped_keycode == ui::VKEY_CAPITAL) { | 523 remapped_keycode == ui::VKEY_CAPITAL) { |
524 input_method::XKeyboard* xkeyboard = xkeyboard_for_testing_ ? | 524 input_method::ImeKeyboard* keyboard = keyboard_for_testing_ ? |
525 xkeyboard_for_testing_ : | 525 keyboard_for_testing_ : |
526 input_method::InputMethodManager::Get()->GetXKeyboard(); | 526 input_method::InputMethodManager::Get()->GetImeKeyboard(); |
527 xkeyboard->SetCapsLockEnabled(!xkeyboard->CapsLockIsEnabled()); | 527 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
528 } | 528 } |
529 | 529 |
530 OverwriteEvent(event, remapped_native_keycode, remapped_native_modifiers); | 530 OverwriteEvent(event, remapped_native_keycode, remapped_native_modifiers); |
531 return true; | 531 return true; |
532 } | 532 } |
533 | 533 |
534 bool EventRewriter::RewriteNumPadKeys(XEvent* event) { | 534 bool EventRewriter::RewriteNumPadKeys(XEvent* event) { |
535 DCHECK(event->type == KeyPress || event->type == KeyRelease); | 535 DCHECK(event->type == KeyPress || event->type == KeyRelease); |
536 bool rewritten = false; | 536 bool rewritten = false; |
537 XKeyEvent* xkey = &event->xkey; | 537 XKeyEvent* xkey = &event->xkey; |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " | 892 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " |
893 << "id=" << device_id; | 893 << "id=" << device_id; |
894 } | 894 } |
895 // Always overwrite the existing device_id since the X server may reuse a | 895 // Always overwrite the existing device_id since the X server may reuse a |
896 // device id for an unattached device. | 896 // device id for an unattached device. |
897 device_id_to_type_[device_id] = type; | 897 device_id_to_type_[device_id] = type; |
898 return type; | 898 return type; |
899 } | 899 } |
900 | 900 |
901 } // namespace chromeos | 901 } // namespace chromeos |
OLD | NEW |