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

Side by Side Diff: chrome/browser/chromeos/events/event_rewriter.cc

Issue 2763483002: Fix Caps Lock bug (Closed)
Patch Set: q Created 3 years, 9 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
« no previous file with comments | « no previous file | ui/events/event.cc » ('j') | ui/events/event.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/chromeos/events/event_rewriter.h" 5 #include "chrome/browser/chromeos/events/event_rewriter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 // (i.e. a Caps Lock key on an external keyboard is pressed) since X 869 // (i.e. a Caps Lock key on an external keyboard is pressed) since X
870 // handles that itself. 870 // handles that itself.
871 && incoming.key_code != ui::VKEY_CAPITAL 871 && incoming.key_code != ui::VKEY_CAPITAL
872 #endif 872 #endif
873 ) { 873 ) {
874 chromeos::input_method::ImeKeyboard* ime_keyboard = 874 chromeos::input_method::ImeKeyboard* ime_keyboard =
875 ime_keyboard_for_testing_ 875 ime_keyboard_for_testing_
876 ? ime_keyboard_for_testing_ 876 ? ime_keyboard_for_testing_
877 : chromeos::input_method::InputMethodManager::Get() 877 : chromeos::input_method::InputMethodManager::Get()
878 ->GetImeKeyboard(); 878 ->GetImeKeyboard();
879 ime_keyboard->SetCapsLockEnabled(!ime_keyboard->CapsLockIsEnabled()); 879 // Toggle Caps Lock if it is not repeated key event.
880 // Prevent continuous toggles when the key is hold down.
881 if (!key_event.is_repeat())
882 ime_keyboard->SetCapsLockEnabled(!ime_keyboard->CapsLockIsEnabled());
880 } 883 }
881 } 884 }
882 return exact_event; 885 return exact_event;
883 } 886 }
884 887
885 void EventRewriter::RewriteNumPadKeys(const ui::KeyEvent& key_event, 888 void EventRewriter::RewriteNumPadKeys(const ui::KeyEvent& key_event,
886 MutableKeyState* state) { 889 MutableKeyState* state) {
887 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || 890 DCHECK(key_event.type() == ui::ET_KEY_PRESSED ||
888 key_event.type() == ui::ET_KEY_RELEASED); 891 key_event.type() == ui::ET_KEY_RELEASED);
889 static const struct NumPadRemapping { 892 static const struct NumPadRemapping {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 for (const auto& keyboard : keyboard_devices) { 1190 for (const auto& keyboard : keyboard_devices) {
1188 if (keyboard.id == device_id) { 1191 if (keyboard.id == device_id) {
1189 return KeyboardDeviceAddedInternal( 1192 return KeyboardDeviceAddedInternal(
1190 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); 1193 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id);
1191 } 1194 }
1192 } 1195 }
1193 return kDeviceUnknown; 1196 return kDeviceUnknown;
1194 } 1197 }
1195 1198
1196 } // namespace chromeos 1199 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | ui/events/event.cc » ('j') | ui/events/event.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698