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 SERVICES_UI_WS_EVENT_DISPATCHER_H_ | 5 #ifndef SERVICES_UI_WS_EVENT_DISPATCHER_H_ |
6 #define SERVICES_UI_WS_EVENT_DISPATCHER_H_ | 6 #define SERVICES_UI_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 "services/ui/common/types.h" | 15 #include "services/ui/common/types.h" |
16 #include "services/ui/public/interfaces/event_matcher.mojom.h" | 16 #include "services/ui/public/interfaces/event_matcher.mojom.h" |
17 #include "services/ui/ws/modal_window_controller.h" | 17 #include "services/ui/ws/modal_window_controller.h" |
18 #include "services/ui/ws/server_window_observer.h" | 18 #include "services/ui/ws/server_window_observer.h" |
19 #include "ui/gfx/geometry/rect_f.h" | 19 #include "ui/gfx/geometry/rect_f.h" |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 class Event; | 22 class Event; |
23 class KeyEvent; | 23 class KeyEvent; |
24 class LocatedEvent; | 24 class LocatedEvent; |
25 | 25 |
26 namespace ws { | 26 namespace ws { |
27 | 27 |
28 class Accelerator; | 28 class Accelerator; |
| 29 class DragController; |
| 30 class DragSource; |
| 31 class DragTargetConnection; |
29 class EventDispatcherDelegate; | 32 class EventDispatcherDelegate; |
30 class ServerWindow; | 33 class ServerWindow; |
| 34 class WindowTree; |
31 | 35 |
32 namespace test { | 36 namespace test { |
33 class EventDispatcherTestApi; | 37 class EventDispatcherTestApi; |
34 } | 38 } |
35 | 39 |
36 // Handles dispatching events to the right location as well as updating focus. | 40 // Handles dispatching events to the right location as well as updating focus. |
37 class EventDispatcher : public ServerWindowObserver { | 41 class EventDispatcher : public ServerWindowObserver { |
38 public: | 42 public: |
39 enum class AcceleratorMatchPhase { | 43 enum class AcceleratorMatchPhase { |
40 // Both pre and post should be considered. | 44 // Both pre and post should be considered. |
(...skipping 27 matching lines...) Expand all Loading... |
68 // Setting capture can fail if the window is blocked by a modal window | 72 // Setting capture can fail if the window is blocked by a modal window |
69 // (indicated by returning |false|). | 73 // (indicated by returning |false|). |
70 bool SetCaptureWindow(ServerWindow* capture_window, | 74 bool SetCaptureWindow(ServerWindow* capture_window, |
71 ClientSpecificId client_id); | 75 ClientSpecificId client_id); |
72 | 76 |
73 // Id of the client that capture events are sent to. | 77 // Id of the client that capture events are sent to. |
74 ClientSpecificId capture_window_client_id() const { | 78 ClientSpecificId capture_window_client_id() const { |
75 return capture_window_client_id_; | 79 return capture_window_client_id_; |
76 } | 80 } |
77 | 81 |
| 82 void SetDragDropSourceWindow( |
| 83 DragSource* drag_source, |
| 84 ServerWindow* window, |
| 85 DragTargetConnection* source_connection, |
| 86 int32_t drag_pointer, |
| 87 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, |
| 88 uint32_t drag_operations); |
| 89 void EndDragDrop(); |
| 90 |
| 91 void OnWillDestroyDragTargetConnection(DragTargetConnection* connection); |
| 92 |
78 // Adds a system modal window. The window remains modal to system until it is | 93 // Adds a system modal window. The window remains modal to system until it is |
79 // destroyed. There can exist multiple system modal windows, in which case the | 94 // destroyed. There can exist multiple system modal windows, in which case the |
80 // one that is visible and added most recently or shown most recently would be | 95 // one that is visible and added most recently or shown most recently would be |
81 // the active one. | 96 // the active one. |
82 void AddSystemModalWindow(ServerWindow* window); | 97 void AddSystemModalWindow(ServerWindow* window); |
83 | 98 |
84 // Checks if |modal_window| is a visible modal window that blocks current | 99 // Checks if |modal_window| is a visible modal window that blocks current |
85 // capture window and if that's the case, releases the capture. | 100 // capture window and if that's the case, releases the capture. |
86 void ReleaseCaptureBlockedByModalWindow(const ServerWindow* modal_window); | 101 void ReleaseCaptureBlockedByModalWindow(const ServerWindow* modal_window); |
87 | 102 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 void ObserveWindow(ServerWindow* winodw); | 212 void ObserveWindow(ServerWindow* winodw); |
198 void UnobserveWindow(ServerWindow* winodw); | 213 void UnobserveWindow(ServerWindow* winodw); |
199 | 214 |
200 // Returns an Accelerator bound to the specified code/flags, and of the | 215 // Returns an Accelerator bound to the specified code/flags, and of the |
201 // matching |phase|. Otherwise returns null. | 216 // matching |phase|. Otherwise returns null. |
202 Accelerator* FindAccelerator(const ui::KeyEvent& event, | 217 Accelerator* FindAccelerator(const ui::KeyEvent& event, |
203 const ui::mojom::AcceleratorPhase phase); | 218 const ui::mojom::AcceleratorPhase phase); |
204 | 219 |
205 ServerWindow* FindDeepestVisibleWindowForEvents(gfx::Point* location); | 220 ServerWindow* FindDeepestVisibleWindowForEvents(gfx::Point* location); |
206 | 221 |
| 222 // Clears the implicit captures in |pointer_targets_|, with the exception of |
| 223 // |window|. |window| may be null. |
| 224 void CancelImplicitCaptureExcept(ServerWindow* window); |
| 225 |
207 // ServerWindowObserver: | 226 // ServerWindowObserver: |
208 void OnWillChangeWindowHierarchy(ServerWindow* window, | 227 void OnWillChangeWindowHierarchy(ServerWindow* window, |
209 ServerWindow* new_parent, | 228 ServerWindow* new_parent, |
210 ServerWindow* old_parent) override; | 229 ServerWindow* old_parent) override; |
211 void OnWindowVisibilityChanged(ServerWindow* window) override; | 230 void OnWindowVisibilityChanged(ServerWindow* window) override; |
212 void OnWindowDestroyed(ServerWindow* window) override; | 231 void OnWindowDestroyed(ServerWindow* window) override; |
213 | 232 |
214 EventDispatcherDelegate* delegate_; | 233 EventDispatcherDelegate* delegate_; |
215 | 234 |
216 ServerWindow* capture_window_; | 235 ServerWindow* capture_window_; |
217 ClientSpecificId capture_window_client_id_; | 236 ClientSpecificId capture_window_client_id_; |
218 | 237 |
| 238 std::unique_ptr<DragController> drag_controller_; |
| 239 |
219 ModalWindowController modal_window_controller_; | 240 ModalWindowController modal_window_controller_; |
220 | 241 |
221 bool mouse_button_down_; | 242 bool mouse_button_down_; |
222 ServerWindow* mouse_cursor_source_window_; | 243 ServerWindow* mouse_cursor_source_window_; |
223 bool mouse_cursor_in_non_client_area_; | 244 bool mouse_cursor_in_non_client_area_; |
224 | 245 |
225 // The on screen location of the mouse pointer. This can be outside the | 246 // The on screen location of the mouse pointer. This can be outside the |
226 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. | 247 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. |
227 gfx::Point mouse_pointer_last_location_; | 248 gfx::Point mouse_pointer_last_location_; |
228 | 249 |
(...skipping 15 matching lines...) Expand all Loading... |
244 AcceleratorMatchPhase::ANY; | 265 AcceleratorMatchPhase::ANY; |
245 #endif | 266 #endif |
246 | 267 |
247 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 268 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
248 }; | 269 }; |
249 | 270 |
250 } // namespace ws | 271 } // namespace ws |
251 } // namespace ui | 272 } // namespace ui |
252 | 273 |
253 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ | 274 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ |
OLD | NEW |