OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/ash/event_rewriter.h" | 5 #include "chrome/browser/ui/ash/event_rewriter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 void EventRewriter::Rewrite(ui::KeyEvent* event) { | 376 void EventRewriter::Rewrite(ui::KeyEvent* event) { |
377 #if defined(OS_CHROMEOS) | 377 #if defined(OS_CHROMEOS) |
378 // Do not rewrite an event sent by ui_controls::SendKeyPress(). See | 378 // Do not rewrite an event sent by ui_controls::SendKeyPress(). See |
379 // crbug.com/136465. | 379 // crbug.com/136465. |
380 if (event->native_event()->xkey.send_event) | 380 if (event->native_event()->xkey.send_event) |
381 return; | 381 return; |
382 #endif | 382 #endif |
383 RewriteModifiers(event); | 383 RewriteModifiers(event); |
384 RewriteNumPadKeys(event); | 384 RewriteNumPadKeys(event); |
385 RewriteBackspaceAndArrowKeys(event); | 385 RewriteExtendedKeys(event); |
386 RewriteFunctionKeys(event); | 386 RewriteFunctionKeys(event); |
387 } | 387 } |
388 | 388 |
389 bool EventRewriter::IsAppleKeyboard() const { | 389 bool EventRewriter::IsAppleKeyboard() const { |
390 if (last_device_id_ == kBadDeviceId) | 390 if (last_device_id_ == kBadDeviceId) |
391 return false; | 391 return false; |
392 | 392 |
393 // Check which device generated |event|. | 393 // Check which device generated |event|. |
394 std::map<int, DeviceType>::const_iterator iter = | 394 std::map<int, DeviceType>::const_iterator iter = |
395 device_id_to_type_.find(last_device_id_); | 395 device_id_to_type_.find(last_device_id_); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 break; | 656 break; |
657 default: | 657 default: |
658 break; | 658 break; |
659 } | 659 } |
660 #else | 660 #else |
661 // TODO(yusukes): Support Ash on other platforms if needed. | 661 // TODO(yusukes): Support Ash on other platforms if needed. |
662 #endif | 662 #endif |
663 return rewritten; | 663 return rewritten; |
664 } | 664 } |
665 | 665 |
666 bool EventRewriter::RewriteBackspaceAndArrowKeys(ui::KeyEvent* event) { | 666 bool EventRewriter::RewriteExtendedKeys(ui::KeyEvent* event) { |
667 #if defined(OS_CHROMEOS) | 667 #if defined(OS_CHROMEOS) |
668 // On a ChromeOS keyboard, modifier keys can be used to access extended | 668 // On a ChromeOS keyboard, modifier keys can be used to access extended |
669 // keyboard shortcuts. On other keyboards, keys such as delete and page up are | 669 // keyboard shortcuts. On other keyboards, keys such as delete and page up are |
670 // already available, so we do not need to rewrite anything here. | 670 // already available, so we do not need to rewrite anything here. |
671 if (!EventSourceIsChromeOSKeyboard()) | 671 if (!EventSourceIsChromeOSKeyboard()) |
672 return false; | 672 return false; |
673 | 673 |
674 const PrefService* pref_service = | 674 const PrefService* pref_service = |
675 pref_service_ ? pref_service_ : GetPrefService(); | 675 pref_service_ ? pref_service_ : GetPrefService(); |
676 bool chromebook_function_key = CommandLine::ForCurrentProcess()->HasSwitch( | 676 bool chromebook_function_key = CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 }, | 747 }, |
748 { // Search+Right -> End | 748 { // Search+Right -> End |
749 XK_Right, | 749 XK_Right, |
750 0, Mod4Mask, | 750 0, Mod4Mask, |
751 XK_End, ui::VKEY_END, | 751 XK_End, ui::VKEY_END, |
752 }, | 752 }, |
753 { // Search+Down -> Next (aka PageDown) | 753 { // Search+Down -> Next (aka PageDown) |
754 XK_Down, | 754 XK_Down, |
755 0, Mod4Mask, | 755 0, Mod4Mask, |
756 XK_Next, ui::VKEY_NEXT, | 756 XK_Next, ui::VKEY_NEXT, |
| 757 }, |
| 758 { // Search+Period -> Insert |
| 759 XK_period, |
| 760 0, Mod4Mask, |
| 761 XK_Insert, ui::VKEY_INSERT, |
757 } | 762 } |
758 }; | 763 }; |
759 | 764 |
760 RewriteWithKeyboardRemappingsByKeySym(remappings, | 765 RewriteWithKeyboardRemappingsByKeySym(remappings, |
761 arraysize(remappings), | 766 arraysize(remappings), |
762 keysym, | 767 keysym, |
763 xkey->state, | 768 xkey->state, |
764 event->flags(), | 769 event->flags(), |
765 &remapped_native_keysym, | 770 &remapped_native_keysym, |
766 &remapped_native_mods, | 771 &remapped_native_mods, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 } else if (type == kDeviceChromeOSKeyboard) { | 963 } else if (type == kDeviceChromeOSKeyboard) { |
959 VLOG(1) << "ChromeOS keyboard '" << device_name << "' connected: " | 964 VLOG(1) << "ChromeOS keyboard '" << device_name << "' connected: " |
960 << "id=" << device_id; | 965 << "id=" << device_id; |
961 #endif | 966 #endif |
962 } | 967 } |
963 // Always overwrite the existing device_id since the X server may reuse a | 968 // Always overwrite the existing device_id since the X server may reuse a |
964 // device id for an unattached device. | 969 // device id for an unattached device. |
965 device_id_to_type_[device_id] = type; | 970 device_id_to_type_[device_id] = type; |
966 return type; | 971 return type; |
967 } | 972 } |
OLD | NEW |