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_MUS_WS_EVENT_DISPATCHER_H_ | 5 #ifndef COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
6 #define COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 6 #define COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Handles dispatching events to the right location as well as updating focus. | 26 // Handles dispatching events to the right location as well as updating focus. |
27 class EventDispatcher : public ServerWindowObserver { | 27 class EventDispatcher : public ServerWindowObserver { |
28 public: | 28 public: |
29 explicit EventDispatcher(EventDispatcherDelegate* delegate); | 29 explicit EventDispatcher(EventDispatcherDelegate* delegate); |
30 ~EventDispatcher() override; | 30 ~EventDispatcher() override; |
31 | 31 |
32 void set_root(ServerWindow* root) { root_ = root; } | 32 void set_root(ServerWindow* root) { root_ = root; } |
33 | 33 |
34 void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; } | 34 void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; } |
35 | 35 |
36 void AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); | 36 // Adds an accelerator with the given id and event-matcher. If an accelerator |
| 37 // already exists with the same id or the same matcher, then the accelerator |
| 38 // is not added. Returns whether adding the accelerator was successful or not. |
| 39 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); |
37 void RemoveAccelerator(uint32_t id); | 40 void RemoveAccelerator(uint32_t id); |
38 | 41 |
39 void OnEvent(mojom::EventPtr event); | 42 void OnEvent(mojom::EventPtr event); |
40 | 43 |
41 private: | 44 private: |
42 // Keeps track of state associated with a pointer down until the | 45 // Keeps track of state associated with a pointer down until the |
43 // corresponding up/cancel. | 46 // corresponding up/cancel. |
44 struct PointerTarget { | 47 struct PointerTarget { |
45 PointerTarget() : window(nullptr), in_nonclient_area(false) {} | 48 PointerTarget() : window(nullptr), in_nonclient_area(false) {} |
46 | 49 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; | 103 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; |
101 PointerIdToTargetMap pointer_targets_; | 104 PointerIdToTargetMap pointer_targets_; |
102 | 105 |
103 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 106 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
104 }; | 107 }; |
105 | 108 |
106 } // namespace ws | 109 } // namespace ws |
107 } // namespace mus | 110 } // namespace mus |
108 | 111 |
109 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 112 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
OLD | NEW |