| 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 "ui/aura/client/focus_change_observer.h" | 13 #include "ui/aura/client/focus_change_observer.h" |
| 13 #include "ui/events/event_handler.h" | 14 #include "ui/events/event_handler.h" |
| 14 | 15 |
| 15 namespace ui { | 16 namespace ui { |
| 16 enum class DomCode; | 17 enum class DomCode; |
| 17 class Event; | 18 class Event; |
| 18 class KeyEvent; | 19 class KeyEvent; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace exo { | 22 namespace exo { |
| 22 class KeyboardDelegate; | 23 class KeyboardDelegate; |
| 23 class Surface; | 24 class Surface; |
| 24 | 25 |
| 25 // This class implements a client keyboard that represents one or more keyboard | 26 // This class implements a client keyboard that represents one or more keyboard |
| 26 // devices. | 27 // devices. |
| 27 class Keyboard : public ui::EventHandler, | 28 class Keyboard : public ui::EventHandler, |
| 28 public aura::client::FocusChangeObserver, | 29 public WMHelper::FocusObserver, |
| 29 public SurfaceObserver { | 30 public SurfaceObserver { |
| 30 public: | 31 public: |
| 31 explicit Keyboard(KeyboardDelegate* delegate); | 32 explicit Keyboard(KeyboardDelegate* delegate); |
| 32 ~Keyboard() override; | 33 ~Keyboard() override; |
| 33 | 34 |
| 34 // Overridden from ui::EventHandler: | 35 // Overridden from ui::EventHandler: |
| 35 void OnKeyEvent(ui::KeyEvent* event) override; | 36 void OnKeyEvent(ui::KeyEvent* event) override; |
| 36 | 37 |
| 37 // Overridden aura::client::FocusChangeObserver: | 38 // Overridden WMHelper::FocusObserver: |
| 38 void OnWindowFocused(aura::Window* gained_focus, | 39 void OnWindowFocused(aura::Window* gained_focus, |
| 39 aura::Window* lost_focus) override; | 40 aura::Window* lost_focus) override; |
| 40 | 41 |
| 41 // Overridden from SurfaceObserver: | 42 // Overridden from SurfaceObserver: |
| 42 void OnSurfaceDestroying(Surface* surface) override; | 43 void OnSurfaceDestroying(Surface* surface) override; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 // Returns the effective focus for |window|. | 46 // Returns the effective focus for |window|. |
| 46 Surface* GetEffectiveFocus(aura::Window* window) const; | 47 Surface* GetEffectiveFocus(aura::Window* window) const; |
| 47 | 48 |
| 48 // The delegate instance that all events are dispatched to. | 49 // The delegate instance that all events are dispatched to. |
| 49 KeyboardDelegate* const delegate_; | 50 KeyboardDelegate* const delegate_; |
| 50 | 51 |
| 51 // The current focus surface for the keyboard. | 52 // The current focus surface for the keyboard. |
| 52 Surface* focus_ = nullptr; | 53 Surface* focus_ = nullptr; |
| 53 | 54 |
| 54 // Vector of currently pressed keys. | 55 // Vector of currently pressed keys. |
| 55 std::vector<ui::DomCode> pressed_keys_; | 56 std::vector<ui::DomCode> pressed_keys_; |
| 56 | 57 |
| 57 // Current set of modifier flags. | 58 // Current set of modifier flags. |
| 58 int modifier_flags_ = 0; | 59 int modifier_flags_ = 0; |
| 59 | 60 |
| 60 DISALLOW_COPY_AND_ASSIGN(Keyboard); | 61 DISALLOW_COPY_AND_ASSIGN(Keyboard); |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 } // namespace exo | 64 } // namespace exo |
| 64 | 65 |
| 65 #endif // COMPONENTS_EXO_KEYBOARD_H_ | 66 #endif // COMPONENTS_EXO_KEYBOARD_H_ |
| OLD | NEW |