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

Side by Side Diff: ui/chromeos/events/event_rewriter_chromeos.cc

Issue 2763483002: Fix Caps Lock bug (Closed)
Patch Set: Applying the fix Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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
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.
808 if (state->key_code == ui::VKEY_CAPITAL
809 // ... except on linux Chrome OS, where InputMethodChromeOS handles it.
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
oshima 2017/04/11 19:04:47 Did you consult with the author of this code? Plea
kpschoedel 2017/04/11 21:56:00 (original author) I believe this can be removed be
oshima 2017/04/11 22:24:54 Many ChromeOS UI devs are still using linux+x11 de
weidongg 2017/04/11 22:55:43 I am sorry, I am still confused about these terms
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 } 807 }
826 return exact_event; 808 return exact_event;
827 } 809 }
828 810
829 void EventRewriterChromeOS::RewriteNumPadKeys(const ui::KeyEvent& key_event, 811 void EventRewriterChromeOS::RewriteNumPadKeys(const ui::KeyEvent& key_event,
830 MutableKeyState* state) { 812 MutableKeyState* state) {
831 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || 813 DCHECK(key_event.type() == ui::ET_KEY_PRESSED ||
832 key_event.type() == ui::ET_KEY_RELEASED); 814 key_event.type() == ui::ET_KEY_RELEASED);
833 static const struct NumPadRemapping { 815 static const struct NumPadRemapping {
834 ui::KeyboardCode input_key_code; 816 ui::KeyboardCode input_key_code;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 for (const auto& keyboard : keyboard_devices) { 1117 for (const auto& keyboard : keyboard_devices) {
1136 if (keyboard.id == device_id) { 1118 if (keyboard.id == device_id) {
1137 return KeyboardDeviceAddedInternal( 1119 return KeyboardDeviceAddedInternal(
1138 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); 1120 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id);
1139 } 1121 }
1140 } 1122 }
1141 return kDeviceUnknown; 1123 return kDeviceUnknown;
1142 } 1124 }
1143 1125
1144 } // namespace ui 1126 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698