| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_EXO_KEYBOARD_H_ | 5 #ifndef COMPONENTS_EXO_KEYBOARD_H_ |
| 6 #define COMPONENTS_EXO_KEYBOARD_H_ | 6 #define COMPONENTS_EXO_KEYBOARD_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/exo/surface_observer.h" | 11 #include "components/exo/surface_observer.h" |
| 12 #include "components/exo/wm_helper.h" | 12 #include "components/exo/wm_helper.h" |
| 13 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 enum class DomCode; | 16 enum class DomCode; |
| 17 class KeyEvent; | 17 class KeyEvent; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace exo { | 20 namespace exo { |
| 21 class KeyboardDelegate; | 21 class KeyboardDelegate; |
| 22 class KeyboardDeviceConfigurationDelegate; | 22 class KeyboardDeviceConfigurationDelegate; |
| 23 class Surface; | 23 class Surface; |
| 24 | 24 |
| 25 // This class implements a client keyboard that represents one or more keyboard | 25 // This class implements a client keyboard that represents one or more keyboard |
| 26 // devices. | 26 // devices. |
| 27 class Keyboard : public ui::EventHandler, | 27 class Keyboard : public ui::EventHandler, |
| 28 public WMHelper::FocusObserver, | 28 public WMHelper::FocusObserver, |
| 29 public WMHelper::InputDeviceEventObserver, | 29 public WMHelper::InputDeviceEventObserver, |
| 30 public WMHelper::MaximizeModeObserver, | 30 public WMHelper::TabletModeObserver, |
| 31 public SurfaceObserver { | 31 public SurfaceObserver { |
| 32 public: | 32 public: |
| 33 explicit Keyboard(KeyboardDelegate* delegate); | 33 explicit Keyboard(KeyboardDelegate* delegate); |
| 34 ~Keyboard() override; | 34 ~Keyboard() override; |
| 35 | 35 |
| 36 bool HasDeviceConfigurationDelegate() const; | 36 bool HasDeviceConfigurationDelegate() const; |
| 37 void SetDeviceConfigurationDelegate( | 37 void SetDeviceConfigurationDelegate( |
| 38 KeyboardDeviceConfigurationDelegate* delegate); | 38 KeyboardDeviceConfigurationDelegate* delegate); |
| 39 | 39 |
| 40 // Overridden from ui::EventHandler: | 40 // Overridden from ui::EventHandler: |
| 41 void OnKeyEvent(ui::KeyEvent* event) override; | 41 void OnKeyEvent(ui::KeyEvent* event) override; |
| 42 | 42 |
| 43 // Overridden WMHelper::FocusObserver: | 43 // Overridden WMHelper::FocusObserver: |
| 44 void OnWindowFocused(aura::Window* gained_focus, | 44 void OnWindowFocused(aura::Window* gained_focus, |
| 45 aura::Window* lost_focus) override; | 45 aura::Window* lost_focus) override; |
| 46 | 46 |
| 47 // Overridden from SurfaceObserver: | 47 // Overridden from SurfaceObserver: |
| 48 void OnSurfaceDestroying(Surface* surface) override; | 48 void OnSurfaceDestroying(Surface* surface) override; |
| 49 | 49 |
| 50 // Overridden from ui::InputDeviceEventObserver: | 50 // Overridden from ui::InputDeviceEventObserver: |
| 51 void OnKeyboardDeviceConfigurationChanged() override; | 51 void OnKeyboardDeviceConfigurationChanged() override; |
| 52 | 52 |
| 53 // Overridden from WMHelper::MaximizeModeObserver: | 53 // Overridden from WMHelper::TabletModeObserver: |
| 54 void OnMaximizeModeStarted() override; | 54 void OnTabletModeStarted() override; |
| 55 void OnMaximizeModeEnding() override; | 55 void OnTabletModeEnding() override; |
| 56 void OnMaximizeModeEnded() override; | 56 void OnTabletModeEnded() override; |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 // Returns the effective focus for |window|. | 59 // Returns the effective focus for |window|. |
| 60 Surface* GetEffectiveFocus(aura::Window* window) const; | 60 Surface* GetEffectiveFocus(aura::Window* window) const; |
| 61 | 61 |
| 62 // The delegate instance that all events except for events about device | 62 // The delegate instance that all events except for events about device |
| 63 // configuration are dispatched to. | 63 // configuration are dispatched to. |
| 64 KeyboardDelegate* const delegate_; | 64 KeyboardDelegate* const delegate_; |
| 65 | 65 |
| 66 // The delegate instance that events about device configuration are dispatched | 66 // The delegate instance that events about device configuration are dispatched |
| 67 // to. | 67 // to. |
| 68 KeyboardDeviceConfigurationDelegate* device_configuration_delegate_ = nullptr; | 68 KeyboardDeviceConfigurationDelegate* device_configuration_delegate_ = nullptr; |
| 69 | 69 |
| 70 // The current focus surface for the keyboard. | 70 // The current focus surface for the keyboard. |
| 71 Surface* focus_ = nullptr; | 71 Surface* focus_ = nullptr; |
| 72 | 72 |
| 73 // Vector of currently pressed keys. | 73 // Vector of currently pressed keys. |
| 74 std::vector<ui::DomCode> pressed_keys_; | 74 std::vector<ui::DomCode> pressed_keys_; |
| 75 | 75 |
| 76 // Current set of modifier flags. | 76 // Current set of modifier flags. |
| 77 int modifier_flags_ = 0; | 77 int modifier_flags_ = 0; |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(Keyboard); | 79 DISALLOW_COPY_AND_ASSIGN(Keyboard); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace exo | 82 } // namespace exo |
| 83 | 83 |
| 84 #endif // COMPONENTS_EXO_KEYBOARD_H_ | 84 #endif // COMPONENTS_EXO_KEYBOARD_H_ |
| OLD | NEW |