Skip to content

Commit

Permalink
Observe OnKeyboardEnableFlagsChanged to get notified VK availability.
Browse files Browse the repository at this point in the history
OnKeyboardEnabledChanged() is called only when the Chrome OS IME is active.
To capture the VK availability update while using other IMEs, exo::Keyboard
should observe KeyboardEnableFlag changes instead.

Bug: 1238454
Change-Id: I63ee66d49d524cbd6645b1d2853ef94d705054c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3120286
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/main@{#915483}
  • Loading branch information
chiro authored and Chromium LUCI CQ committed Aug 26, 2021
1 parent 27f47a7 commit 8113560
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
24 changes: 15 additions & 9 deletions components/exo/keyboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool Keyboard::HasDeviceConfigurationDelegate() const {
void Keyboard::SetDeviceConfigurationDelegate(
KeyboardDeviceConfigurationDelegate* delegate) {
device_configuration_delegate_ = delegate;
OnKeyboardEnabledChanged(IsVirtualKeyboardEnabled());
UpdateKeyboardType();
}

void Keyboard::AddObserver(KeyboardObserver* observer) {
Expand Down Expand Up @@ -397,14 +397,9 @@ void Keyboard::OnSurfaceFocused(Surface* gained_focus) {
////////////////////////////////////////////////////////////////////////////////
// ash::KeyboardControllerObserver overrides:

void Keyboard::OnKeyboardEnabledChanged(bool enabled) {
if (device_configuration_delegate_) {
// Ignore kAndroidDisabled which affects |enabled| and just test for a11y
// and touch enabled keyboards. TODO(yhanada): Fix this using an Android
// specific KeyboardUI implementation. https://crbug.com/897655.
bool is_physical = !IsVirtualKeyboardEnabled();
device_configuration_delegate_->OnKeyboardTypeChanged(is_physical);
}
void Keyboard::OnKeyboardEnableFlagsChanged(
const std::set<keyboard::KeyboardEnableFlag>& flags) {
UpdateKeyboardType();
}

void Keyboard::OnKeyRepeatSettingsChanged(
Expand Down Expand Up @@ -516,4 +511,15 @@ void Keyboard::RemoveEventHandler() {
toplevel_window->RemovePostTargetHandler(this);
}

void Keyboard::UpdateKeyboardType() {
if (!device_configuration_delegate_)
return;

// Ignore kAndroidDisabled which affects |enabled| and just test for a11y
// and touch enabled keyboards. TODO(yhanada): Fix this using an Android
// specific KeyboardUI implementation. https://crbug.com/897655.
const bool is_physical = !IsVirtualKeyboardEnabled();
device_configuration_delegate_->OnKeyboardTypeChanged(is_physical);
}

} // namespace exo
10 changes: 7 additions & 3 deletions components/exo/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ class Keyboard : public ui::EventHandler,
// Overridden from SeatObserver:
void OnSurfaceFocused(Surface* gained_focus) override;

// Overridden from ash::KeyboardControllerObserver
void OnKeyboardEnabledChanged(bool is_enabled) override;
// Overridden from ash::KeyboardControllerObserver:
void OnKeyboardEnableFlagsChanged(
const std::set<keyboard::KeyboardEnableFlag>& flags) override;
void OnKeyRepeatSettingsChanged(
const ash::KeyRepeatSettings& settings) override;

// Overridden from ash::ImeControllerImpl::Observer
// Overridden from ash::ImeControllerImpl::Observer:
void OnCapsLockChanged(bool enabled) override;
void OnKeyboardLayoutNameChanged(const std::string& layout_name) override;

Expand All @@ -97,6 +98,9 @@ class Keyboard : public ui::EventHandler,
void AddEventHandler();
void RemoveEventHandler();

// Notify the current keyboard type.
void UpdateKeyboardType();

// The delegate instance that all events except for events about device
// configuration are dispatched to.
std::unique_ptr<KeyboardDelegate> delegate_;
Expand Down

0 comments on commit 8113560

Please sign in to comment.