summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 17:55:53 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 17:55:53 +0000
commitf8ef310be3f196ae5df2ed39e8b1057c5dddf782 (patch)
tree5e74b8935ad8a36e303a0c72c3e9d438f93e136a /chromeos
parentc754b8be87432da6e382b8348d6e60670afd2b21 (diff)
downloadchromium_src-f8ef310be3f196ae5df2ed39e8b1057c5dddf782.zip
chromium_src-f8ef310be3f196ae5df2ed39e8b1057c5dddf782.tar.gz
chromium_src-f8ef310be3f196ae5df2ed39e8b1057c5dddf782.tar.bz2
Fixing caps lock problems under ChromeOS where the tray does not properly follow the real caps lock change
BUG=356393 TEST=visual with chromebooks internal keyboard, external keyboard and with linux Review URL: https://codereview.chromium.org/231753002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263025 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/ime/fake_xkeyboard.cc6
-rw-r--r--chromeos/ime/fake_xkeyboard.h2
-rw-r--r--chromeos/ime/xkeyboard.cc19
-rw-r--r--chromeos/ime/xkeyboard.h10
4 files changed, 37 insertions, 0 deletions
diff --git a/chromeos/ime/fake_xkeyboard.cc b/chromeos/ime/fake_xkeyboard.cc
index 6a7d7a4..fdc227a 100644
--- a/chromeos/ime/fake_xkeyboard.cc
+++ b/chromeos/ime/fake_xkeyboard.cc
@@ -13,6 +13,12 @@ FakeXKeyboard::FakeXKeyboard()
auto_repeat_is_enabled_(false) {
}
+void FakeXKeyboard::AddObserver(XKeyboard::Observer* observer) {
+}
+
+void FakeXKeyboard::RemoveObserver(XKeyboard::Observer* observer) {
+}
+
bool FakeXKeyboard::SetCurrentKeyboardLayoutByName(
const std::string& layout_name) {
++set_current_keyboard_layout_by_name_count_;
diff --git a/chromeos/ime/fake_xkeyboard.h b/chromeos/ime/fake_xkeyboard.h
index df531ae..3422bfa 100644
--- a/chromeos/ime/fake_xkeyboard.h
+++ b/chromeos/ime/fake_xkeyboard.h
@@ -20,6 +20,8 @@ class CHROMEOS_EXPORT FakeXKeyboard : public XKeyboard {
FakeXKeyboard();
virtual ~FakeXKeyboard() {}
+ virtual void AddObserver(Observer* observer) OVERRIDE;
+ virtual void RemoveObserver(Observer* observer) OVERRIDE;
virtual bool SetCurrentKeyboardLayoutByName(const std::string& layout_name)
OVERRIDE;
virtual bool ReapplyCurrentKeyboardLayout() OVERRIDE;
diff --git a/chromeos/ime/xkeyboard.cc b/chromeos/ime/xkeyboard.cc
index b2f55f1..8f2adc8 100644
--- a/chromeos/ime/xkeyboard.cc
+++ b/chromeos/ime/xkeyboard.cc
@@ -117,6 +117,10 @@ class XKeyboardImpl : public XKeyboard {
XKeyboardImpl();
virtual ~XKeyboardImpl() {}
+ // Adds/removes observer.
+ virtual void AddObserver(Observer* observer) OVERRIDE;
+ virtual void RemoveObserver(Observer* observer) OVERRIDE;
+
// Overridden from XKeyboard:
virtual bool SetCurrentKeyboardLayoutByName(
const std::string& layout_name) OVERRIDE;
@@ -169,6 +173,8 @@ class XKeyboardImpl : public XKeyboard {
base::WeakPtrFactory<XKeyboardImpl> weak_factory_;
+ ObserverList<Observer> observers_;
+
DISALLOW_COPY_AND_ASSIGN(XKeyboardImpl);
};
@@ -193,6 +199,14 @@ XKeyboardImpl::XKeyboardImpl()
current_caps_lock_status_ = CapsLockIsEnabled();
}
+void XKeyboardImpl::AddObserver(XKeyboard::Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void XKeyboardImpl::RemoveObserver(XKeyboard::Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
unsigned int XKeyboardImpl::GetNumLockMask() {
DCHECK(thread_checker_.CalledOnValidThread());
static const unsigned int kBadMask = 0;
@@ -378,7 +392,12 @@ bool XKeyboardImpl::SetAutoRepeatRate(const AutoRepeatRate& rate) {
}
void XKeyboardImpl::SetCapsLockEnabled(bool enable_caps_lock) {
+ bool old_state = current_caps_lock_status_;
SetLockedModifiers(enable_caps_lock);
+ if (old_state != enable_caps_lock) {
+ FOR_EACH_OBSERVER(XKeyboard::Observer, observers_,
+ OnCapsLockChanged(enable_caps_lock));
+ }
}
bool XKeyboardImpl::SetCurrentKeyboardLayoutByName(
diff --git a/chromeos/ime/xkeyboard.h b/chromeos/ime/xkeyboard.h
index b07e4f4..ad2cbc7 100644
--- a/chromeos/ime/xkeyboard.h
+++ b/chromeos/ime/xkeyboard.h
@@ -36,8 +36,18 @@ class InputMethodUtil;
class CHROMEOS_EXPORT XKeyboard {
public:
+ class Observer {
+ public:
+ // Called when the caps lock state has changed.
+ virtual void OnCapsLockChanged(bool enabled) = 0;
+ };
+
virtual ~XKeyboard() {}
+ // Adds/removes observer.
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+
// Sets the current keyboard layout to |layout_name|. This function does not
// change the current mapping of the modifier keys. Returns true on success.
virtual bool SetCurrentKeyboardLayoutByName(