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 // Retrieves the ServerWindow of the last mouse move. |
| 37 ServerWindow* mouse_cursor_source_window() const { |
| 38 return mouse_cursor_source_window_; |
| 39 } |
| 40 |
36 // Adds an accelerator with the given id and event-matcher. If an accelerator | 41 // 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 | 42 // 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. | 43 // is not added. Returns whether adding the accelerator was successful or not. |
39 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); | 44 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); |
40 void RemoveAccelerator(uint32_t id); | 45 void RemoveAccelerator(uint32_t id); |
41 | 46 |
42 void OnEvent(mojom::EventPtr event); | 47 void OnEvent(mojom::EventPtr event); |
43 | 48 |
44 private: | 49 private: |
45 // Keeps track of state associated with a pointer down until the | 50 // Keeps track of state associated with a pointer down until the |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // ServerWindowObserver: | 93 // ServerWindowObserver: |
89 void OnWillChangeWindowHierarchy(ServerWindow* window, | 94 void OnWillChangeWindowHierarchy(ServerWindow* window, |
90 ServerWindow* new_parent, | 95 ServerWindow* new_parent, |
91 ServerWindow* old_parent) override; | 96 ServerWindow* old_parent) override; |
92 void OnWindowVisibilityChanged(ServerWindow* window) override; | 97 void OnWindowVisibilityChanged(ServerWindow* window) override; |
93 void OnWindowDestroyed(ServerWindow* window) override; | 98 void OnWindowDestroyed(ServerWindow* window) override; |
94 | 99 |
95 EventDispatcherDelegate* delegate_; | 100 EventDispatcherDelegate* delegate_; |
96 ServerWindow* root_; | 101 ServerWindow* root_; |
97 | 102 |
| 103 bool mouse_button_down_; |
| 104 ServerWindow* mouse_cursor_source_window_; |
| 105 |
98 cc::SurfaceId surface_id_; | 106 cc::SurfaceId surface_id_; |
99 | 107 |
100 using Entry = std::pair<uint32_t, EventMatcher>; | 108 using Entry = std::pair<uint32_t, EventMatcher>; |
101 std::map<uint32_t, EventMatcher> accelerators_; | 109 std::map<uint32_t, EventMatcher> accelerators_; |
102 | 110 |
103 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; | 111 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; |
104 PointerIdToTargetMap pointer_targets_; | 112 PointerIdToTargetMap pointer_targets_; |
105 | 113 |
106 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 114 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
107 }; | 115 }; |
108 | 116 |
109 } // namespace ws | 117 } // namespace ws |
110 } // namespace mus | 118 } // namespace mus |
111 | 119 |
112 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 120 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
OLD | NEW |