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_VIEW_MANAGER_EVENT_DISPATCHER_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_ |
6 #define COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_ | 6 #define COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "components/view_manager/public/interfaces/native_viewport.mojom.h" | 11 #include "ui/mojo/events/input_event_constants.mojom.h" |
| 12 #include "ui/mojo/events/input_events.mojom.h" |
| 13 #include "ui/mojo/events/input_key_codes.mojom.h" |
12 | 14 |
13 namespace view_manager { | 15 namespace view_manager { |
14 | 16 |
15 class ConnectionManager; | 17 class ConnectionManager; |
16 | 18 |
17 // Handles dispatching events to the right location as well as updating focus. | 19 // Handles dispatching events to the right location as well as updating focus. |
18 class EventDispatcher : public mojo::NativeViewportEventDispatcher { | 20 class EventDispatcher { |
19 public: | 21 public: |
20 explicit EventDispatcher(ConnectionManager* connection_manager); | 22 explicit EventDispatcher(ConnectionManager* connection_manager); |
21 ~EventDispatcher() override; | 23 ~EventDispatcher(); |
22 | 24 |
23 void AddAccelerator(mojo::KeyboardCode keyboard_code, mojo::EventFlags flags); | 25 void AddAccelerator(mojo::KeyboardCode keyboard_code, mojo::EventFlags flags); |
24 void RemoveAccelerator(mojo::KeyboardCode keyboard_code, | 26 void RemoveAccelerator(mojo::KeyboardCode keyboard_code, |
25 mojo::EventFlags flags); | 27 mojo::EventFlags flags); |
26 | 28 |
27 // NativeViewportEventDispatcher: | 29 void OnEvent(mojo::EventPtr event); |
28 void OnEvent(mojo::EventPtr event, const OnEventCallback& callback) override; | |
29 | 30 |
30 private: | 31 private: |
31 struct Accelerator { | 32 struct Accelerator { |
32 Accelerator(mojo::KeyboardCode keyboard_code, mojo::EventFlags flags) | 33 Accelerator(mojo::KeyboardCode keyboard_code, mojo::EventFlags flags) |
33 : keyboard_code(keyboard_code), flags(flags) {} | 34 : keyboard_code(keyboard_code), flags(flags) {} |
34 | 35 |
35 // So we can use this in a set. | 36 // So we can use this in a set. |
36 bool operator<(const Accelerator& other) const { | 37 bool operator<(const Accelerator& other) const { |
37 if (keyboard_code == other.keyboard_code) | 38 if (keyboard_code == other.keyboard_code) |
38 return flags < other.flags; | 39 return flags < other.flags; |
39 return keyboard_code < other.keyboard_code; | 40 return keyboard_code < other.keyboard_code; |
40 } | 41 } |
41 | 42 |
42 mojo::KeyboardCode keyboard_code; | 43 mojo::KeyboardCode keyboard_code; |
43 mojo::EventFlags flags; | 44 mojo::EventFlags flags; |
44 }; | 45 }; |
45 | 46 |
46 ConnectionManager* connection_manager_; | 47 ConnectionManager* connection_manager_; |
47 | 48 |
48 std::set<Accelerator> accelerators_; | 49 std::set<Accelerator> accelerators_; |
49 | 50 |
50 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 51 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
51 }; | 52 }; |
52 | 53 |
53 } // namespace view_manager | 54 } // namespace view_manager |
54 | 55 |
55 #endif // COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_ | 56 #endif // COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_ |
OLD | NEW |