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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 ui::KeyboardCode key_code; | 61 ui::KeyboardCode key_code; |
62 const char* pref_name; | 62 const char* pref_name; |
63 } kModifierRemappings[] = { | 63 } kModifierRemappings[] = { |
64 {input_method::kSearchKey, ui::EF_COMMAND_DOWN, ui::VKEY_LWIN, | 64 {input_method::kSearchKey, ui::EF_COMMAND_DOWN, ui::VKEY_LWIN, |
65 prefs::kLanguageRemapSearchKeyTo}, | 65 prefs::kLanguageRemapSearchKeyTo}, |
66 {input_method::kControlKey, ui::EF_CONTROL_DOWN, ui::VKEY_CONTROL, | 66 {input_method::kControlKey, ui::EF_CONTROL_DOWN, ui::VKEY_CONTROL, |
67 prefs::kLanguageRemapControlKeyTo}, | 67 prefs::kLanguageRemapControlKeyTo}, |
68 {input_method::kAltKey, ui::EF_ALT_DOWN, ui::VKEY_MENU, | 68 {input_method::kAltKey, ui::EF_ALT_DOWN, ui::VKEY_MENU, |
69 prefs::kLanguageRemapAltKeyTo}, | 69 prefs::kLanguageRemapAltKeyTo}, |
70 {input_method::kVoidKey, 0, ui::VKEY_UNKNOWN, NULL}, | 70 {input_method::kVoidKey, 0, ui::VKEY_UNKNOWN, NULL}, |
71 {input_method::kCapsLockKey, ui::EF_CAPS_LOCK_DOWN, ui::VKEY_CAPITAL, | 71 {input_method::kCapsLockKey, ui::EF_MOD3_DOWN, ui::VKEY_CAPITAL, |
72 prefs::kLanguageRemapCapsLockKeyTo}, | 72 prefs::kLanguageRemapCapsLockKeyTo}, |
73 {input_method::kEscapeKey, 0, ui::VKEY_ESCAPE, NULL}, | 73 {input_method::kEscapeKey, 0, ui::VKEY_ESCAPE, NULL}, |
74 {0, 0, ui::VKEY_F15, prefs::kLanguageRemapDiamondKeyTo}, | 74 {0, 0, ui::VKEY_F15, prefs::kLanguageRemapDiamondKeyTo}, |
75 }; | 75 }; |
76 | 76 |
77 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[1]; | 77 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[1]; |
78 | 78 |
79 // Gets a remapped key for |pref_name| key. For example, to find out which | 79 // Gets a remapped key for |pref_name| key. For example, to find out which |
80 // key Search is currently remapped to, call the function with | 80 // key Search is currently remapped to, call the function with |
81 // prefs::kLanguageRemapSearchKeyTo. | 81 // prefs::kLanguageRemapSearchKeyTo. |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 if (!(unmodified_flags & kModifierRemappings[i].flag)) | 318 if (!(unmodified_flags & kModifierRemappings[i].flag)) |
319 continue; | 319 continue; |
320 switch (kModifierRemappings[i].flag) { | 320 switch (kModifierRemappings[i].flag) { |
321 case ui::EF_COMMAND_DOWN: | 321 case ui::EF_COMMAND_DOWN: |
322 // Rewrite Command key presses on an Apple keyboard to Control. | 322 // Rewrite Command key presses on an Apple keyboard to Control. |
323 if (IsAppleKeyboard()) { | 323 if (IsAppleKeyboard()) { |
324 DCHECK_EQ(ui::EF_CONTROL_DOWN, kModifierRemappingCtrl->flag); | 324 DCHECK_EQ(ui::EF_CONTROL_DOWN, kModifierRemappingCtrl->flag); |
325 remapped_key = kModifierRemappingCtrl; | 325 remapped_key = kModifierRemappingCtrl; |
326 } | 326 } |
327 break; | 327 break; |
328 case ui::EF_CAPS_LOCK_DOWN: | 328 case ui::EF_MOD3_DOWN: |
329 // If CapsLock is used by the current input method, don't allow the | 329 // If EF_MOD3_DOWN is used by the current input method, leave it alone; |
330 // CapsLock pref to remap it, or the keyboard behavior will be broken. | 330 // it is not remappable. |
331 if (IsISOLevel5ShiftUsedByCurrentInputMethod()) | 331 if (IsISOLevel5ShiftUsedByCurrentInputMethod()) |
332 continue; | 332 continue; |
| 333 // Otherwise, Mod3Mask is set on X events when the Caps Lock key |
| 334 // is down, but, if Caps Lock is remapped, CapsLock is NOT set, |
| 335 // because pressing the key does not invoke caps lock. So, the |
| 336 // kModifierRemappings[] table uses EF_MOD3_DOWN for the Caps |
| 337 // Lock remapping. |
333 break; | 338 break; |
334 default: | 339 default: |
335 break; | 340 break; |
336 } | 341 } |
337 if (!remapped_key && kModifierRemappings[i].pref_name) { | 342 if (!remapped_key && kModifierRemappings[i].pref_name) { |
338 remapped_key = | 343 remapped_key = |
339 GetRemappedKey(kModifierRemappings[i].pref_name, pref_service); | 344 GetRemappedKey(kModifierRemappings[i].pref_name, pref_service); |
340 } | 345 } |
341 if (remapped_key) { | 346 if (remapped_key) { |
342 unmodified_flags &= ~kModifierRemappings[i].flag; | 347 unmodified_flags &= ~kModifierRemappings[i].flag; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 | 757 |
753 XIFreeDeviceInfo(device_info); | 758 XIFreeDeviceInfo(device_info); |
754 } | 759 } |
755 | 760 |
756 void EventRewriter::DeviceRemoved(int device_id) { | 761 void EventRewriter::DeviceRemoved(int device_id) { |
757 device_id_to_type_.erase(device_id); | 762 device_id_to_type_.erase(device_id); |
758 } | 763 } |
759 #endif | 764 #endif |
760 | 765 |
761 } // namespace chromeos | 766 } // namespace chromeos |
OLD | NEW |