From 0d80b8cb59db7ed226f7b5ff75afd268df9f46fe Mon Sep 17 00:00:00 2001 From: "zork@chromium.org" Date: Tue, 12 Jul 2011 13:03:28 +0000 Subject: Fix AltGr and Search key mapping R=yusukes@chromium.org BUG=chromium-os:17484 TEST=Manual Review URL: http://codereview.chromium.org/7344006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92161 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/chromeos/input_method/input_method_util.cc | 9 +++++++++ chrome/browser/chromeos/input_method/input_method_util.h | 10 ++++++++++ chrome/browser/chromeos/input_method/xkeyboard.cc | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) (limited to 'chrome/browser/chromeos') diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc index 5c3ac96..cb5e0fe 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.cc +++ b/chrome/browser/chromeos/input_method/input_method_util.cc @@ -506,6 +506,15 @@ std::string GetKeyboardOverlayId(const std::string& input_method_id) { return ""; } +std::string GetKeyboardOverlayIdFromXkb(const std::string& xkb_layout_id) { + for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { + if (kIBusEngines[i].xkb_layout_id == xkb_layout_id) { + return kIBusEngines[i].keyboard_overlay_id; + } + } + return ""; +} + std::string GetInputMethodDisplayNameFromId( const std::string& input_method_id) { const std::string display_name = diff --git a/chrome/browser/chromeos/input_method/input_method_util.h b/chrome/browser/chromeos/input_method/input_method_util.h index 4e17744..6a729a8 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.h +++ b/chrome/browser/chromeos/input_method/input_method_util.h @@ -93,6 +93,16 @@ std::string GetKeyboardLayoutName(const std::string& input_method_id); // "xkb:gb::eng" => "en_GB" std::string GetKeyboardOverlayId(const std::string& input_method_id); +// Gets the ID for the keyboard overlay from the given xkb layout ID. +// If the ID is invalid, an empty string will be returned. +// +// Examples: +// +// "us" => "en_US" +// "us(dvorak)" => "en_US_dvorak" +// "gb(extd)" => "en_GB" +std::string GetKeyboardOverlayIdFromXkb(const std::string& xkb_layout_id); + // Converts an input method ID to a language code of the IME. Returns "Eng" // when |input_method_id| is unknown. // Example: "hangul" => "ko" diff --git a/chrome/browser/chromeos/input_method/xkeyboard.cc b/chrome/browser/chromeos/input_method/xkeyboard.cc index 430e47d..270672d 100644 --- a/chrome/browser/chromeos/input_method/xkeyboard.cc +++ b/chrome/browser/chromeos/input_method/xkeyboard.cc @@ -85,7 +85,7 @@ const char* kCapsLockRemapped[] = { bool KeepRightAlt(const std::string& layout_name) { for (size_t c = 0; c < arraysize(kKeepRightAltOverlays); ++c) { - if (GetKeyboardOverlayId(layout_name) == kKeepRightAltOverlays[c]) { + if (GetKeyboardOverlayIdFromXkb(layout_name) == kKeepRightAltOverlays[c]) { return true; } } @@ -94,7 +94,7 @@ bool KeepRightAlt(const std::string& layout_name) { bool KeepCapsLock(const std::string& layout_name) { for (size_t c = 0; c < arraysize(kCapsLockRemapped); ++c) { - if (GetKeyboardOverlayId(layout_name) == kCapsLockRemapped[c]) { + if (GetKeyboardOverlayIdFromXkb(layout_name) == kCapsLockRemapped[c]) { return true; } } -- cgit v1.1