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

Unified Diff: chrome/browser/ui/ash/event_rewriter.cc

Issue 11943009: Add diamond-key remapping support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/event_rewriter.cc
diff --git a/chrome/browser/ui/ash/event_rewriter.cc b/chrome/browser/ui/ash/event_rewriter.cc
index ad5fdec8222933b98b2b6ea4d600ac8061314596..0518320716006fe5fee2018e15a22af436d56e11 100644
--- a/chrome/browser/ui/ash/event_rewriter.cc
+++ b/chrome/browser/ui/ash/event_rewriter.cc
@@ -85,6 +85,7 @@ const struct ModifierFlagToPrefName {
{ Mod4Mask, 0, prefs::kLanguageRemapSearchKeyTo },
{ ControlMask, ui::EF_CONTROL_DOWN, prefs::kLanguageRemapControlKeyTo },
{ Mod1Mask, ui::EF_ALT_DOWN, prefs::kLanguageRemapAltKeyTo },
+ { Mod2Mask, 0, prefs::kLanguageRemapDiamondKeyTo },
};
// Gets a remapped key for |pref_name| key. For example, to find out which
@@ -122,6 +123,11 @@ bool HasChromeOSKeyboard() {
switches::kHasChromeOSKeyboard);
}
+bool HasDiamondKey() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kHasChromeOSDiamondKey);
+}
+
bool IsMod3UsedByCurrentInputMethod() {
// Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask,
// it's not possible to make both features work. For now, we don't remap
@@ -426,7 +432,7 @@ void EventRewriter::GetRemappedModifierMasks(
(original_flags & ~(ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)) |
*remapped_flags;
- unsigned int native_mask = Mod4Mask | ControlMask | Mod1Mask;
+ unsigned int native_mask = Mod4Mask | ControlMask | Mod1Mask | Mod2Mask;
if (!skip_mod3)
native_mask |= Mod3Mask;
*remapped_native_modifiers =
@@ -467,6 +473,19 @@ bool EventRewriter::RewriteModifiers(ui::KeyEvent* event) {
// First, remap |keysym|.
const ModifierRemapping* remapped_key = NULL;
switch (keysym) {
+ // On Chrome OS, XF86XK_Launch6 (F15) with Mod2Mask is sent when Diamond
+ // key is pressed.
+ case XF86XK_Launch6:
+ // When diamond key is not available, the configuration UI for Diamond
+ // key is not shown. Therefore, ignore the kLanguageRemapDiamondKeyTo
+ // syncable pref.
+ if (HasDiamondKey())
+ remapped_key =
+ GetRemappedKey(prefs::kLanguageRemapDiamondKeyTo, *pref_service);
+ // Default behavior is Ctrl key.
+ if (!remapped_key)
+ remapped_key = kModifierRemappingCtrl;
+ break;
// On Chrome OS, XF86XK_Launch7 (F16) with Mod3Mask is sent when Caps Lock
// is pressed (with one exception: when IsMod3UsedByCurrentInputMethod() is
// true, the key generates XK_ISO_Level3_Shift with Mod3Mask, not
@@ -475,11 +494,12 @@ bool EventRewriter::RewriteModifiers(ui::KeyEvent* event) {
// When a Chrome OS keyboard is available, the configuration UI for Caps
// Lock is not shown. Therefore, ignore the kLanguageRemapCapsLockKeyTo
// syncable pref.
- if (HasChromeOSKeyboard())
- remapped_key = kModifierRemappingCapsLock;
- else
+ if (!HasChromeOSKeyboard())
remapped_key =
GetRemappedKey(prefs::kLanguageRemapCapsLockKeyTo, *pref_service);
+ // Default behavior is Caps Lock key.
+ if (!remapped_key)
+ remapped_key = kModifierRemappingCapsLock;
break;
case XK_Super_L:
case XK_Super_R:
@@ -489,6 +509,8 @@ bool EventRewriter::RewriteModifiers(ui::KeyEvent* event) {
else
remapped_key =
GetRemappedKey(prefs::kLanguageRemapSearchKeyTo, *pref_service);
+ // Default behavior is Super key, hence don't remap the event if the pref
+ // is unavailable.
break;
case XK_Control_L:
case XK_Control_R:
« no previous file with comments | « chrome/browser/resources/options/chromeos/keyboard_overlay.js ('k') | chrome/browser/ui/ash/event_rewriter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698