Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1800)

Unified Diff: components/exo/keyboard.cc

Issue 2506263002: exo: Implement support for zcr_keyboard_configuration_v1 protocol. (Closed)
Patch Set: add one more TODO Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/exo/keyboard.h ('k') | components/exo/keyboard_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/keyboard.cc
diff --git a/components/exo/keyboard.cc b/components/exo/keyboard.cc
index 2ac24547ef0c9b5cd99e797857770784926263b4..206b61f72c5b4c9ac404989b32f272b4e29ec126 100644
--- a/components/exo/keyboard.cc
+++ b/components/exo/keyboard.cc
@@ -5,16 +5,20 @@
#include "components/exo/keyboard.h"
#include "components/exo/keyboard_delegate.h"
+#include "components/exo/keyboard_device_configuration_delegate.h"
#include "components/exo/shell_surface.h"
#include "components/exo/surface.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/window.h"
#include "ui/base/ime/input_method.h"
#include "ui/events/base_event_utils.h"
+#include "ui/events/devices/input_device.h"
+#include "ui/events/devices/input_device_manager.h"
#include "ui/events/event.h"
#include "ui/views/widget/widget.h"
namespace exo {
+namespace {
bool ConsumedByIme(Surface* focus, const ui::KeyEvent* event) {
// Check if IME consumed the event, to avoid it to be doubly processed.
@@ -70,6 +74,21 @@ bool ConsumedByIme(Surface* focus, const ui::KeyEvent* event) {
return false;
}
+bool IsPhysicalKeyboardEnabled() {
+ // The internal keyboard is enabled if maximize mode is not enabled.
+ if (WMHelper::GetInstance()->IsMaximizeModeWindowManagerEnabled())
+ return true;
+
+ for (auto& keyboard :
+ ui::InputDeviceManager::GetInstance()->GetKeyboardDevices()) {
+ if (keyboard.type != ui::InputDeviceType::INPUT_DEVICE_INTERNAL)
+ return true;
+ }
+ return false;
+}
+
+} // namespace
+
////////////////////////////////////////////////////////////////////////////////
// Keyboard, public:
@@ -77,16 +96,28 @@ Keyboard::Keyboard(KeyboardDelegate* delegate) : delegate_(delegate) {
auto* helper = WMHelper::GetInstance();
helper->AddPostTargetHandler(this);
helper->AddFocusObserver(this);
+ helper->AddMaximizeModeObserver(this);
+ helper->AddInputDeviceEventObserver(this);
OnWindowFocused(helper->GetFocusedWindow(), nullptr);
}
Keyboard::~Keyboard() {
delegate_->OnKeyboardDestroying(this);
+ if (device_configuration_delegate_)
+ device_configuration_delegate_->OnKeyboardDestroying(this);
if (focus_)
focus_->RemoveSurfaceObserver(this);
auto* helper = WMHelper::GetInstance();
helper->RemoveFocusObserver(this);
helper->RemovePostTargetHandler(this);
+ helper->RemoveMaximizeModeObserver(this);
+ helper->RemoveInputDeviceEventObserver(this);
+}
+
+void Keyboard::SetDeviceConfigurationDelegate(
+ KeyboardDeviceConfigurationDelegate* delegate) {
+ device_configuration_delegate_ = delegate;
+ OnKeyboardDeviceConfigurationChanged();
}
////////////////////////////////////////////////////////////////////////////////
@@ -170,6 +201,27 @@ void Keyboard::OnSurfaceDestroying(Surface* surface) {
}
////////////////////////////////////////////////////////////////////////////////
+// ui::InputDeviceEventObserver overrides:
+
+void Keyboard::OnKeyboardDeviceConfigurationChanged() {
+ if (device_configuration_delegate_) {
+ device_configuration_delegate_->OnKeyboardTypeChanged(
+ IsPhysicalKeyboardEnabled());
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WMHelper::MaximizeModeObserver overrides:
+
+void Keyboard::OnMaximizeModeStarted() {
+ OnKeyboardDeviceConfigurationChanged();
+}
+
+void Keyboard::OnMaximizeModeEnded() {
+ OnKeyboardDeviceConfigurationChanged();
+}
+
+////////////////////////////////////////////////////////////////////////////////
// Keyboard, private:
Surface* Keyboard::GetEffectiveFocus(aura::Window* window) const {
« no previous file with comments | « components/exo/keyboard.h ('k') | components/exo/keyboard_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698