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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "cc/surfaces/surface_id.h" | |
16 #include "components/mus/public/interfaces/event_matcher.mojom.h" | 15 #include "components/mus/public/interfaces/event_matcher.mojom.h" |
17 #include "components/mus/ws/modal_window_controller.h" | 16 #include "components/mus/ws/modal_window_controller.h" |
18 #include "components/mus/ws/server_window_observer.h" | 17 #include "components/mus/ws/server_window_observer.h" |
19 #include "ui/gfx/geometry/rect_f.h" | 18 #include "ui/gfx/geometry/rect_f.h" |
20 | 19 |
21 namespace ui { | 20 namespace ui { |
22 class Event; | 21 class Event; |
23 class KeyEvent; | 22 class KeyEvent; |
24 class LocatedEvent; | 23 class LocatedEvent; |
25 } | 24 } |
(...skipping 10 matching lines...) Expand all Loading... |
36 } | 35 } |
37 | 36 |
38 // Handles dispatching events to the right location as well as updating focus. | 37 // Handles dispatching events to the right location as well as updating focus. |
39 class EventDispatcher : public ServerWindowObserver { | 38 class EventDispatcher : public ServerWindowObserver { |
40 public: | 39 public: |
41 explicit EventDispatcher(EventDispatcherDelegate* delegate); | 40 explicit EventDispatcher(EventDispatcherDelegate* delegate); |
42 ~EventDispatcher() override; | 41 ~EventDispatcher() override; |
43 | 42 |
44 void set_root(ServerWindow* root) { root_ = root; } | 43 void set_root(ServerWindow* root) { root_ = root; } |
45 | 44 |
46 void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; } | |
47 | |
48 // Cancels capture and stops tracking any pointer events. This does not send | 45 // Cancels capture and stops tracking any pointer events. This does not send |
49 // any events to the delegate. | 46 // any events to the delegate. |
50 void Reset(); | 47 void Reset(); |
51 | 48 |
52 void SetMousePointerScreenLocation(const gfx::Point& screen_location); | 49 void SetMousePointerScreenLocation(const gfx::Point& screen_location); |
53 const gfx::Point& mouse_pointer_last_location() const { | 50 const gfx::Point& mouse_pointer_last_location() const { |
54 return mouse_pointer_last_location_; | 51 return mouse_pointer_last_location_; |
55 } | 52 } |
56 | 53 |
57 // If we still have the window of the last mouse move, returns true and sets | 54 // If we still have the window of the last mouse move, returns true and sets |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 ModalWindowController modal_window_controller_; | 197 ModalWindowController modal_window_controller_; |
201 | 198 |
202 bool mouse_button_down_; | 199 bool mouse_button_down_; |
203 ServerWindow* mouse_cursor_source_window_; | 200 ServerWindow* mouse_cursor_source_window_; |
204 bool mouse_cursor_in_non_client_area_; | 201 bool mouse_cursor_in_non_client_area_; |
205 | 202 |
206 // The on screen location of the mouse pointer. This can be outside the | 203 // The on screen location of the mouse pointer. This can be outside the |
207 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. | 204 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. |
208 gfx::Point mouse_pointer_last_location_; | 205 gfx::Point mouse_pointer_last_location_; |
209 | 206 |
210 cc::SurfaceId surface_id_; | |
211 | |
212 using Entry = std::pair<uint32_t, std::unique_ptr<Accelerator>>; | 207 using Entry = std::pair<uint32_t, std::unique_ptr<Accelerator>>; |
213 std::map<uint32_t, std::unique_ptr<Accelerator>> accelerators_; | 208 std::map<uint32_t, std::unique_ptr<Accelerator>> accelerators_; |
214 | 209 |
215 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; | 210 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; |
216 // |pointer_targets_| contains the active pointers. For a mouse based pointer | 211 // |pointer_targets_| contains the active pointers. For a mouse based pointer |
217 // a PointerTarget is always active (and present in |pointer_targets_|). For | 212 // a PointerTarget is always active (and present in |pointer_targets_|). For |
218 // touch based pointers the pointer is active while down and removed on | 213 // touch based pointers the pointer is active while down and removed on |
219 // cancel or up. | 214 // cancel or up. |
220 PointerIdToTargetMap pointer_targets_; | 215 PointerIdToTargetMap pointer_targets_; |
221 | 216 |
222 // Keeps track of number of observe requests for each observed window. | 217 // Keeps track of number of observe requests for each observed window. |
223 std::map<const ServerWindow*, uint8_t> observed_windows_; | 218 std::map<const ServerWindow*, uint8_t> observed_windows_; |
224 | 219 |
225 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 220 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
226 }; | 221 }; |
227 | 222 |
228 } // namespace ws | 223 } // namespace ws |
229 } // namespace mus | 224 } // namespace mus |
230 | 225 |
231 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 226 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
OLD | NEW |