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* last_targeted_window() const { | |
38 return last_pointer_target_window_; | |
39 } | |
40 | |
36 void AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); | 41 void AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); |
37 void RemoveAccelerator(uint32_t id); | 42 void RemoveAccelerator(uint32_t id); |
38 | 43 |
39 void OnEvent(mojom::EventPtr event); | 44 void OnEvent(mojom::EventPtr event); |
40 | 45 |
41 private: | 46 private: |
42 // Keeps track of state associated with a pointer down until the | 47 // Keeps track of state associated with a pointer down until the |
43 // corresponding up/cancel. | 48 // corresponding up/cancel. |
44 struct PointerTarget { | 49 struct PointerTarget { |
45 PointerTarget() : window(nullptr), in_nonclient_area(false) {} | 50 PointerTarget() : window(nullptr), in_nonclient_area(false) {} |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 | 89 |
85 // ServerWindowObserver: | 90 // ServerWindowObserver: |
86 void OnWillChangeWindowHierarchy(ServerWindow* window, | 91 void OnWillChangeWindowHierarchy(ServerWindow* window, |
87 ServerWindow* new_parent, | 92 ServerWindow* new_parent, |
88 ServerWindow* old_parent) override; | 93 ServerWindow* old_parent) override; |
89 void OnWindowVisibilityChanged(ServerWindow* window) override; | 94 void OnWindowVisibilityChanged(ServerWindow* window) override; |
90 void OnWindowDestroyed(ServerWindow* window) override; | 95 void OnWindowDestroyed(ServerWindow* window) override; |
91 | 96 |
92 EventDispatcherDelegate* delegate_; | 97 EventDispatcherDelegate* delegate_; |
93 ServerWindow* root_; | 98 ServerWindow* root_; |
99 ServerWindow* last_pointer_target_window_; | |
sky
2015/12/02 21:42:35
As this is specific to a mouse, name it last_mouse
| |
94 | 100 |
95 cc::SurfaceId surface_id_; | 101 cc::SurfaceId surface_id_; |
96 | 102 |
97 using Entry = std::pair<uint32_t, EventMatcher>; | 103 using Entry = std::pair<uint32_t, EventMatcher>; |
98 std::map<uint32_t, EventMatcher> accelerators_; | 104 std::map<uint32_t, EventMatcher> accelerators_; |
99 | 105 |
100 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; | 106 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; |
101 PointerIdToTargetMap pointer_targets_; | 107 PointerIdToTargetMap pointer_targets_; |
102 | 108 |
103 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 109 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
104 }; | 110 }; |
105 | 111 |
106 } // namespace ws | 112 } // namespace ws |
107 } // namespace mus | 113 } // namespace mus |
108 | 114 |
109 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 115 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
OLD | NEW |