summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-28 21:12:07 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-28 21:12:07 +0000
commit1488a035f4377aa3cc443a4846e5058fc2a6acb4 (patch)
tree0043356ac199af9d7b7e91869bdbf0c0707c5233 /chromeos
parent01bdc9206f8de9eac03ca7da9a736652f1d6add1 (diff)
downloadchromium_src-1488a035f4377aa3cc443a4846e5058fc2a6acb4.zip
chromium_src-1488a035f4377aa3cc443a4846e5058fc2a6acb4.tar.gz
chromium_src-1488a035f4377aa3cc443a4846e5058fc2a6acb4.tar.bz2
Update StickyKeys overlay to show or hide AltGr depending on the
current input method. BUG=335368 Review URL: https://codereview.chromium.org/187313002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260280 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/ime/fake_xkeyboard.cc8
-rw-r--r--chromeos/ime/fake_xkeyboard.h2
-rw-r--r--chromeos/ime/input_method_manager.h4
-rw-r--r--chromeos/ime/input_methods.txt10
-rw-r--r--chromeos/ime/xkeyboard.cc67
-rw-r--r--chromeos/ime/xkeyboard.h6
6 files changed, 93 insertions, 4 deletions
diff --git a/chromeos/ime/fake_xkeyboard.cc b/chromeos/ime/fake_xkeyboard.cc
index 45bd5bf..6a7d7a4 100644
--- a/chromeos/ime/fake_xkeyboard.cc
+++ b/chromeos/ime/fake_xkeyboard.cc
@@ -38,6 +38,14 @@ bool FakeXKeyboard::CapsLockIsEnabled() {
return caps_lock_is_enabled_;
}
+bool FakeXKeyboard::IsISOLevel5ShiftAvailable() const {
+ return false;
+}
+
+bool FakeXKeyboard::IsAltGrAvailable() const {
+ return false;
+}
+
bool FakeXKeyboard::SetAutoRepeatEnabled(bool enabled) {
auto_repeat_is_enabled_ = enabled;
return true;
diff --git a/chromeos/ime/fake_xkeyboard.h b/chromeos/ime/fake_xkeyboard.h
index c25b39f..df531ae 100644
--- a/chromeos/ime/fake_xkeyboard.h
+++ b/chromeos/ime/fake_xkeyboard.h
@@ -27,6 +27,8 @@ class CHROMEOS_EXPORT FakeXKeyboard : public XKeyboard {
virtual void DisableNumLock() OVERRIDE;
virtual void SetCapsLockEnabled(bool enable_caps_lock) OVERRIDE;
virtual bool CapsLockIsEnabled() OVERRIDE;
+ virtual bool IsISOLevel5ShiftAvailable() const OVERRIDE;
+ virtual bool IsAltGrAvailable() const OVERRIDE;
virtual bool SetAutoRepeatEnabled(bool enabled) OVERRIDE;
virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) OVERRIDE;
diff --git a/chromeos/ime/input_method_manager.h b/chromeos/ime/input_method_manager.h
index e344770..dbbed38 100644
--- a/chromeos/ime/input_method_manager.h
+++ b/chromeos/ime/input_method_manager.h
@@ -157,6 +157,10 @@ class CHROMEOS_EXPORT InputMethodManager {
// Gets the descriptor of the input method which is currently selected.
virtual InputMethodDescriptor GetCurrentInputMethod() const = 0;
+ virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const = 0;
+
+ virtual bool IsAltGrUsedByCurrentInputMethod() const = 0;
+
// Returns an X keyboard object which could be used to change the current XKB
// layout, change the caps lock status, and set the auto repeat rate/interval.
virtual XKeyboard* GetXKeyboard() = 0;
diff --git a/chromeos/ime/input_methods.txt b/chromeos/ime/input_methods.txt
index a570da7..d053d122 100644
--- a/chromeos/ime/input_methods.txt
+++ b/chromeos/ime/input_methods.txt
@@ -34,10 +34,12 @@
# * chrome/browser/resources/chromeos/keyboard_overlay_data.js
# * chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc
#
-# If you add an XKB layout which depends on X11's Mod3Mask (e.g. Germany Neo2
-# XKB layout), you should also update IsMod3UsedByCurrentInputMethod() method
-# in chrome/browser/ui/ash/event_rewriter.cc. Otherwise, Mod3Mask might be
-# removed unexpectedly by the rewriter.
+# If you add an XKB layout which depends on AltGr or X11's Mod3Mask
+# (e.g. Germany Neo2 XKB layout), you should also update kAltGrLayoutIds or
+# kMod3LayoutIds in
+# chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+# Otherwise, Mod3Mask might be removed unexpectedly by the rewriter, and
+# sticky keys will not work.
#
# U.S. English
diff --git a/chromeos/ime/xkeyboard.cc b/chromeos/ime/xkeyboard.cc
index e0e69cf..b2f55f1 100644
--- a/chromeos/ime/xkeyboard.cc
+++ b/chromeos/ime/xkeyboard.cc
@@ -45,6 +45,54 @@ const char kSetxkbmapCommand[] = "/usr/bin/setxkbmap";
// A string for obtaining a mask value for Num Lock.
const char kNumLockVirtualModifierString[] = "NumLock";
+const char *kISOLevel5ShiftLayoutIds[] = {
+ "ca(multix)",
+ "de(neo)",
+};
+
+const char *kAltGrLayoutIds[] = {
+ "be",
+ "be",
+ "be",
+ "bg",
+ "bg(phonetic)",
+ "br",
+ "ca",
+ "ca(eng)",
+ "ca(multix)",
+ "ch",
+ "ch(fr)",
+ "cz",
+ "de",
+ "de(neo)",
+ "dk",
+ "ee",
+ "es",
+ "es(cat)",
+ "fi",
+ "fr",
+ "gb(dvorak)",
+ "gb(extd)",
+ "gr",
+ "hr",
+ "il",
+ "it",
+ "latam",
+ "lt",
+ "no",
+ "pl",
+ "pt",
+ "ro",
+ "se",
+ "si",
+ "sk",
+ "tr",
+ "ua",
+ "us(altgr-intl)",
+ "us(intl)",
+};
+
+
// Returns false if |layout_name| contains a bad character.
bool CheckLayoutName(const std::string& layout_name) {
static const char kValidLayoutNameCharacters[] =
@@ -77,6 +125,8 @@ class XKeyboardImpl : public XKeyboard {
virtual void DisableNumLock() OVERRIDE;
virtual void SetCapsLockEnabled(bool enable_caps_lock) OVERRIDE;
virtual bool CapsLockIsEnabled() OVERRIDE;
+ virtual bool IsISOLevel5ShiftAvailable() const OVERRIDE;
+ virtual bool IsAltGrAvailable() const OVERRIDE;
virtual bool SetAutoRepeatEnabled(bool enabled) OVERRIDE;
virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) OVERRIDE;
@@ -288,6 +338,23 @@ bool XKeyboardImpl::CapsLockIsEnabled() {
return (status.locked_mods & LockMask);
}
+bool XKeyboardImpl::IsISOLevel5ShiftAvailable() const {
+ for (size_t i = 0; i < arraysize(kISOLevel5ShiftLayoutIds); ++i) {
+ if (current_layout_name_ == kISOLevel5ShiftLayoutIds[i])
+ return true;
+ }
+ return false;
+}
+
+bool XKeyboardImpl::IsAltGrAvailable() const {
+ for (size_t i = 0; i < arraysize(kAltGrLayoutIds); ++i) {
+ if (current_layout_name_ == kAltGrLayoutIds[i])
+ return true;
+ }
+ return false;
+}
+
+
bool XKeyboardImpl::SetAutoRepeatEnabled(bool enabled) {
if (enabled)
XAutoRepeatOn(GetXDisplay());
diff --git a/chromeos/ime/xkeyboard.h b/chromeos/ime/xkeyboard.h
index eae5e7c..b07e4f4 100644
--- a/chromeos/ime/xkeyboard.h
+++ b/chromeos/ime/xkeyboard.h
@@ -70,6 +70,12 @@ class CHROMEOS_EXPORT XKeyboard {
// threads.
virtual bool CapsLockIsEnabled() = 0;
+ // Returns true if the current layout supports ISO Level 5 shift.
+ virtual bool IsISOLevel5ShiftAvailable() const = 0;
+
+ // Returns true if the current layout supports alt gr.
+ virtual bool IsAltGrAvailable() const = 0;
+
// Turns on and off the auto-repeat of the keyboard. Returns true on success.
// Do not call the function from non-UI threads.
virtual bool SetAutoRepeatEnabled(bool enabled) = 0;