| 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 "ui/chromeos/events/event_rewriter_chromeos.h" | 5 #include "ui/chromeos/events/event_rewriter_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 state->flags &= ~characteristic_flag; | 797 state->flags &= ~characteristic_flag; |
| 798 if (non_modifier_to_modifier) | 798 if (non_modifier_to_modifier) |
| 799 pressed_modifier_latches_ &= ~characteristic_flag; | 799 pressed_modifier_latches_ &= ~characteristic_flag; |
| 800 } | 800 } |
| 801 | 801 |
| 802 if (key_event.type() == ui::ET_KEY_PRESSED) { | 802 if (key_event.type() == ui::ET_KEY_PRESSED) { |
| 803 if (!ui::KeycodeConverter::IsDomKeyForModifier(state->key)) { | 803 if (!ui::KeycodeConverter::IsDomKeyForModifier(state->key)) { |
| 804 used_modifier_latches_ |= pressed_modifier_latches_; | 804 used_modifier_latches_ |= pressed_modifier_latches_; |
| 805 latched_modifier_latches_ = ui::EF_NONE; | 805 latched_modifier_latches_ = ui::EF_NONE; |
| 806 } | 806 } |
| 807 // Toggle Caps Lock if the remapped key is ui::VKEY_CAPITAL. | 807 // The handling of Caps Lock toggling is now moved to accelerator |
| 808 if (state->key_code == ui::VKEY_CAPITAL | 808 // controller. |
| 809 // ... except on linux Chrome OS, where InputMethodChromeOS handles it. | 809 // (see https://bugs.chromium.org/p/chromium/issues/detail?id=700705). |
| 810 && (base::SysInfo::IsRunningOnChromeOS() || ime_keyboard_for_testing_) | |
| 811 #if defined(USE_X11) | |
| 812 // ... but for X11, do nothing if the original key is ui::VKEY_CAPITAL | |
| 813 // (i.e. a Caps Lock key on an external keyboard is pressed) since X | |
| 814 // handles that itself. | |
| 815 && incoming.key_code != ui::VKEY_CAPITAL | |
| 816 #endif | |
| 817 ) { | |
| 818 ::chromeos::input_method::ImeKeyboard* ime_keyboard = | |
| 819 ime_keyboard_for_testing_ | |
| 820 ? ime_keyboard_for_testing_ | |
| 821 : ::chromeos::input_method::InputMethodManager::Get() | |
| 822 ->GetImeKeyboard(); | |
| 823 ime_keyboard->SetCapsLockEnabled(!ime_keyboard->CapsLockIsEnabled()); | |
| 824 } | |
| 825 } | 810 } |
| 826 return exact_event; | 811 return exact_event; |
| 827 } | 812 } |
| 828 | 813 |
| 829 void EventRewriterChromeOS::RewriteNumPadKeys(const ui::KeyEvent& key_event, | 814 void EventRewriterChromeOS::RewriteNumPadKeys(const ui::KeyEvent& key_event, |
| 830 MutableKeyState* state) { | 815 MutableKeyState* state) { |
| 831 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || | 816 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || |
| 832 key_event.type() == ui::ET_KEY_RELEASED); | 817 key_event.type() == ui::ET_KEY_RELEASED); |
| 833 static const struct NumPadRemapping { | 818 static const struct NumPadRemapping { |
| 834 ui::KeyboardCode input_key_code; | 819 ui::KeyboardCode input_key_code; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 for (const auto& keyboard : keyboard_devices) { | 1120 for (const auto& keyboard : keyboard_devices) { |
| 1136 if (keyboard.id == device_id) { | 1121 if (keyboard.id == device_id) { |
| 1137 return KeyboardDeviceAddedInternal( | 1122 return KeyboardDeviceAddedInternal( |
| 1138 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); | 1123 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); |
| 1139 } | 1124 } |
| 1140 } | 1125 } |
| 1141 return kDeviceUnknown; | 1126 return kDeviceUnknown; |
| 1142 } | 1127 } |
| 1143 | 1128 |
| 1144 } // namespace ui | 1129 } // namespace ui |
| OLD | NEW |