diff options
author | kelvinp <kelvinp@chromium.org> | 2014-12-07 17:29:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-08 01:30:07 +0000 |
commit | ed826b6a2a9474c013d4a1e4067895073050742e (patch) | |
tree | 667718ac5b9f4ddaf824df8e874a69ee066ae8f5 | |
parent | eaf26106414e42aa28fc3771f1a4201e37eb8982 (diff) | |
download | chromium_src-ed826b6a2a9474c013d4a1e4067895073050742e.zip chromium_src-ed826b6a2a9474c013d4a1e4067895073050742e.tar.gz chromium_src-ed826b6a2a9474c013d4a1e4067895073050742e.tar.bz2 |
Expose GetAutoRepeateEnabled() on ImeKeyboard
This API will be used by Remote Assistance on ChromeOS.
During a Remote Assistance session, we would like to disable auto-repeat
as long as keys are pressed to avoid triggering auto-repeat if network
congestion delays the key-up event from the client.
This API is needed to restore auto-repeat to the original value after
a Remote Assistance session ends.
BUG=439142
Review URL: https://codereview.chromium.org/769703006
Cr-Commit-Position: refs/heads/master@{#307196}
-rw-r--r-- | ui/base/ime/chromeos/fake_ime_keyboard.cc | 4 | ||||
-rw-r--r-- | ui/base/ime/chromeos/fake_ime_keyboard.h | 1 | ||||
-rw-r--r-- | ui/base/ime/chromeos/ime_keyboard.h | 7 | ||||
-rw-r--r-- | ui/base/ime/chromeos/ime_keyboard_ozone.cc | 4 | ||||
-rw-r--r-- | ui/base/ime/chromeos/ime_keyboard_ozone.h | 1 | ||||
-rw-r--r-- | ui/base/ime/chromeos/ime_keyboard_x11.cc | 13 | ||||
-rw-r--r-- | ui/base/ime/chromeos/ime_keyboard_x11.h | 1 | ||||
-rw-r--r-- | ui/base/ime/chromeos/ime_keyboard_x11_unittest.cc | 6 |
8 files changed, 23 insertions, 14 deletions
diff --git a/ui/base/ime/chromeos/fake_ime_keyboard.cc b/ui/base/ime/chromeos/fake_ime_keyboard.cc index 8b3b509..54fe8c0 100644 --- a/ui/base/ime/chromeos/fake_ime_keyboard.cc +++ b/ui/base/ime/chromeos/fake_ime_keyboard.cc @@ -32,6 +32,10 @@ bool FakeImeKeyboard::SetAutoRepeatEnabled(bool enabled) { return true; } +bool FakeImeKeyboard::GetAutoRepeatEnabled() { + return auto_repeat_is_enabled_; +} + bool FakeImeKeyboard::ReapplyCurrentKeyboardLayout() { return true; } diff --git a/ui/base/ime/chromeos/fake_ime_keyboard.h b/ui/base/ime/chromeos/fake_ime_keyboard.h index 0557fe7..ecabeca 100644 --- a/ui/base/ime/chromeos/fake_ime_keyboard.h +++ b/ui/base/ime/chromeos/fake_ime_keyboard.h @@ -23,6 +23,7 @@ class UI_BASE_EXPORT FakeImeKeyboard : public ImeKeyboard { override; virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) override; virtual bool SetAutoRepeatEnabled(bool enabled) override; + virtual bool GetAutoRepeatEnabled() override; virtual bool ReapplyCurrentKeyboardLayout() override; virtual void ReapplyCurrentModifierLockStatus() override; virtual void DisableNumLock() override; diff --git a/ui/base/ime/chromeos/ime_keyboard.h b/ui/base/ime/chromeos/ime_keyboard.h index 5c84fff..5fa5e13 100644 --- a/ui/base/ime/chromeos/ime_keyboard.h +++ b/ui/base/ime/chromeos/ime_keyboard.h @@ -91,15 +91,14 @@ class UI_BASE_EXPORT ImeKeyboard { // Do not call the function from non-UI threads. virtual bool SetAutoRepeatEnabled(bool enabled) = 0; + // Returns true if auto-repeat is enabled. + virtual bool GetAutoRepeatEnabled() = 0; + // Sets the auto-repeat rate of the keyboard, initial delay in ms, and repeat // interval in ms. Returns true on success. Do not call the function from // non-UI threads. virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) = 0; - // Returns true if auto repeat is enabled. This function is protected: for - // testability. - static UI_BASE_EXPORT bool GetAutoRepeatEnabledForTesting(); - // On success, set current auto repeat rate on |out_rate| and returns true. // Returns false otherwise. This function is protected: for testability. static UI_BASE_EXPORT bool GetAutoRepeatRateForTesting( diff --git a/ui/base/ime/chromeos/ime_keyboard_ozone.cc b/ui/base/ime/chromeos/ime_keyboard_ozone.cc index f8ab018..290f511 100644 --- a/ui/base/ime/chromeos/ime_keyboard_ozone.cc +++ b/ui/base/ime/chromeos/ime_keyboard_ozone.cc @@ -52,6 +52,10 @@ bool ImeKeyboardOzone::SetAutoRepeatEnabled(bool enabled) { return true; } +bool ImeKeyboardOzone::GetAutoRepeatEnabled() { + return true; +} + // static ImeKeyboard* ImeKeyboard::Create() { return new ImeKeyboardOzone(); diff --git a/ui/base/ime/chromeos/ime_keyboard_ozone.h b/ui/base/ime/chromeos/ime_keyboard_ozone.h index 4459c36..9c623e4 100644 --- a/ui/base/ime/chromeos/ime_keyboard_ozone.h +++ b/ui/base/ime/chromeos/ime_keyboard_ozone.h @@ -24,6 +24,7 @@ class UI_BASE_EXPORT ImeKeyboardOzone : public ImeKeyboard { override; virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) override; virtual bool SetAutoRepeatEnabled(bool enabled) override; + virtual bool GetAutoRepeatEnabled() override; virtual bool ReapplyCurrentKeyboardLayout() override; virtual void ReapplyCurrentModifierLockStatus() override; virtual void DisableNumLock() override; diff --git a/ui/base/ime/chromeos/ime_keyboard_x11.cc b/ui/base/ime/chromeos/ime_keyboard_x11.cc index 7bb8d0a..116e08f 100644 --- a/ui/base/ime/chromeos/ime_keyboard_x11.cc +++ b/ui/base/ime/chromeos/ime_keyboard_x11.cc @@ -224,6 +224,12 @@ bool ImeKeyboardX11::SetAutoRepeatEnabled(bool enabled) { return true; } +bool ImeKeyboardX11::GetAutoRepeatEnabled() { + XKeyboardState state = {}; + XGetKeyboardControl(gfx::GetXDisplay(), &state); + return state.global_auto_repeat != AutoRepeatModeOff; +} + bool ImeKeyboardX11::SetAutoRepeatRate(const AutoRepeatRate& rate) { DVLOG(1) << "Set auto-repeat rate to: " << rate.initial_delay_in_ms << " ms delay, " @@ -278,13 +284,6 @@ void ImeKeyboardX11::OnSetLayoutFinish() { } // static -bool ImeKeyboard::GetAutoRepeatEnabledForTesting() { - XKeyboardState state = {}; - XGetKeyboardControl(gfx::GetXDisplay(), &state); - return state.global_auto_repeat != AutoRepeatModeOff; -} - -// static bool ImeKeyboard::GetAutoRepeatRateForTesting(AutoRepeatRate* out_rate) { return XkbGetAutoRepeatRate(gfx::GetXDisplay(), XkbUseCoreKbd, diff --git a/ui/base/ime/chromeos/ime_keyboard_x11.h b/ui/base/ime/chromeos/ime_keyboard_x11.h index b731b74..966c82dc 100644 --- a/ui/base/ime/chromeos/ime_keyboard_x11.h +++ b/ui/base/ime/chromeos/ime_keyboard_x11.h @@ -43,6 +43,7 @@ class UI_BASE_EXPORT ImeKeyboardX11 : public ImeKeyboard { virtual void SetCapsLockEnabled(bool enable_caps_lock) override; virtual bool CapsLockIsEnabled() override; virtual bool SetAutoRepeatEnabled(bool enabled) override; + virtual bool GetAutoRepeatEnabled() override; virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) override; private: diff --git a/ui/base/ime/chromeos/ime_keyboard_x11_unittest.cc b/ui/base/ime/chromeos/ime_keyboard_x11_unittest.cc index ada5593..358eab7 100644 --- a/ui/base/ime/chromeos/ime_keyboard_x11_unittest.cc +++ b/ui/base/ime/chromeos/ime_keyboard_x11_unittest.cc @@ -121,12 +121,12 @@ TEST_F(ImeKeyboardTest, TestSetAutoRepeatEnabled) { DVLOG(1) << "X server is not available. Skip the test."; return; } - const bool state = ImeKeyboard::GetAutoRepeatEnabledForTesting(); + const bool state = xkey_->GetAutoRepeatEnabled(); xkey_->SetAutoRepeatEnabled(!state); - EXPECT_EQ(!state, ImeKeyboard::GetAutoRepeatEnabledForTesting()); + EXPECT_EQ(!state, xkey_->GetAutoRepeatEnabled()); // Restore the initial state. xkey_->SetAutoRepeatEnabled(state); - EXPECT_EQ(state, ImeKeyboard::GetAutoRepeatEnabledForTesting()); + EXPECT_EQ(state, xkey_->GetAutoRepeatEnabled()); } TEST_F(ImeKeyboardTest, TestSetAutoRepeatRate) { |