diff options
author | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-27 09:43:59 +0000 |
---|---|---|
committer | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-27 09:43:59 +0000 |
commit | d18fbc41d962daeefd0bb854aeb3337641ccd773 (patch) | |
tree | 0f86874ac0ee0702622396321a39e136ec946a39 /chrome/browser/chromeos/preferences.cc | |
parent | 8a4da96004a267322e214095b1465913b03179f9 (diff) | |
download | chromium_src-d18fbc41d962daeefd0bb854aeb3337641ccd773.zip chromium_src-d18fbc41d962daeefd0bb854aeb3337641ccd773.tar.gz chromium_src-d18fbc41d962daeefd0bb854aeb3337641ccd773.tar.bz2 |
Implement the "Configure modifier keys" drop-down which enables users to swap Alt/Ctrl keys and Search/Ctrl keys.
BUG=chromium-os:2636
TEST=manually on eeepc
Review URL: http://codereview.chromium.org/3038025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53764 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/preferences.cc')
-rw-r--r-- | chrome/browser/chromeos/preferences.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index 7a993d9..d5cbcd1 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc @@ -8,6 +8,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/keyboard_library.h" #include "chrome/browser/chromeos/cros/input_method_library.h" #include "chrome/browser/chromeos/cros/synaptics_library.h" #include "chrome/browser/chromeos/input_method/input_method_util.h" @@ -83,6 +84,9 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterIntegerPref(kMozcIntegerPrefs[i].pref_name, kMozcIntegerPrefs[i].default_pref_value); } + prefs->RegisterIntegerPref( + kXkbModifierMultipleChoicePrefs.pref_name, + kXkbModifierMultipleChoicePrefs.default_pref_value); } void Preferences::Init(PrefService* prefs) { @@ -137,6 +141,8 @@ void Preferences::Init(PrefService* prefs) { language_mozc_integer_prefs_[i].Init( kMozcIntegerPrefs[i].pref_name, prefs, this); } + language_xkb_modifier_remap_.Init( + kXkbModifierMultipleChoicePrefs.pref_name, prefs, this); std::string locale(g_browser_process->GetApplicationLocale()); // Add input methods based on the application locale when the user first @@ -296,6 +302,32 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) { language_mozc_integer_prefs_[i].GetValue()); } } + if (!pref_name || *pref_name == kXkbModifierMultipleChoicePrefs.pref_name) { + chromeos::ModifierMap modifier_map; + const int remap_type = language_xkb_modifier_remap_.GetValue(); + switch (remap_type) { + default: + LOG(ERROR) << "Unknown XKB remapping type: " << remap_type; + /* fall through */ + case kNoRemap: + modifier_map.push_back(ModifierKeyPair(kSearchKey, kSearchKey)); + modifier_map.push_back( + ModifierKeyPair(kLeftControlKey, kLeftControlKey)); + modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftAltKey)); + break; + case kSwapCtrlAndAlt: + modifier_map.push_back(ModifierKeyPair(kSearchKey, kSearchKey)); + modifier_map.push_back(ModifierKeyPair(kLeftControlKey, kLeftAltKey)); + modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftControlKey)); + break; + case kSwapSearchAndCtrl: + modifier_map.push_back(ModifierKeyPair(kSearchKey, kLeftControlKey)); + modifier_map.push_back(ModifierKeyPair(kLeftControlKey, kSearchKey)); + modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftAltKey)); + break; + } + CrosLibrary::Get()->GetKeyboardLibrary()->RemapModifierKeys(modifier_map); + } } void Preferences::SetLanguageConfigBoolean(const char* section, |