OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_WINDOW_MANAGER_STATE_H_ | 5 #ifndef SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ |
6 #define SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ | 6 #define SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 struct QueuedEvent { | 146 struct QueuedEvent { |
147 QueuedEvent(); | 147 QueuedEvent(); |
148 ~QueuedEvent(); | 148 ~QueuedEvent(); |
149 | 149 |
150 std::unique_ptr<Event> event; | 150 std::unique_ptr<Event> event; |
151 std::unique_ptr<ProcessedEventTarget> processed_target; | 151 std::unique_ptr<ProcessedEventTarget> processed_target; |
152 int64_t display_id; | 152 int64_t display_id; |
153 }; | 153 }; |
154 | 154 |
155 // Tracks state associated with an event being dispatched to a client. | 155 // Tracks state associated with an event being dispatched to a client. |
156 struct InFlightEventDetails { | 156 struct InFlightEventDispatchDetails { |
157 InFlightEventDetails(WindowManagerState* window_manager_state, | 157 InFlightEventDispatchDetails(WindowManagerState* window_manager_state, |
158 WindowTree* tree, | 158 WindowTree* tree, |
159 int64_t display_id, | 159 int64_t display_id, |
160 const Event& event, | 160 const Event& event, |
161 EventDispatchPhase phase); | 161 EventDispatchPhase phase); |
162 ~InFlightEventDetails(); | 162 ~InFlightEventDispatchDetails(); |
163 | 163 |
164 base::OneShotTimer timer; | 164 base::OneShotTimer timer; |
165 WindowTree* tree; | 165 WindowTree* tree; |
166 int64_t display_id; | 166 int64_t display_id; |
167 std::unique_ptr<Event> event; | 167 std::unique_ptr<Event> event; |
168 EventDispatchPhase phase; | 168 EventDispatchPhase phase; |
169 base::WeakPtr<Accelerator> post_target_accelerator; | 169 base::WeakPtr<Accelerator> post_target_accelerator; |
170 // Used for callbacks/timer specific to processing |event|. | 170 // Used for callbacks/timer specific to processing |event|. |
171 base::WeakPtrFactory<WindowManagerState> weak_factory; | 171 base::WeakPtrFactory<WindowManagerState> weak_factory; |
172 }; | 172 }; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 // Implemenation of processing an event with a match phase of all. This | 207 // Implemenation of processing an event with a match phase of all. This |
208 // handles debug accelerators and forwards to EventDispatcher. | 208 // handles debug accelerators and forwards to EventDispatcher. |
209 void ProcessEventImpl(const Event& event, int64_t display_id); | 209 void ProcessEventImpl(const Event& event, int64_t display_id); |
210 | 210 |
211 // Schedules an event to be processed later. | 211 // Schedules an event to be processed later. |
212 void QueueEvent(const Event& event, | 212 void QueueEvent(const Event& event, |
213 std::unique_ptr<ProcessedEventTarget> processed_event_target, | 213 std::unique_ptr<ProcessedEventTarget> processed_event_target, |
214 int64_t display_id); | 214 int64_t display_id); |
215 | 215 |
216 // Processes the next valid event in |event_queue_|. If the event has already | |
217 // been processed it is dispatched, otherwise the event is passed to the | |
218 // EventDispatcher for processing. | |
219 void ProcessNextEventFromQueue(); | |
220 | |
221 // Dispatches the event to the appropriate client and starts the ack timer. | 216 // Dispatches the event to the appropriate client and starts the ack timer. |
222 void DispatchInputEventToWindowImpl(ServerWindow* target, | 217 void DispatchInputEventToWindowImpl(ServerWindow* target, |
223 ClientSpecificId client_id, | 218 ClientSpecificId client_id, |
224 const Event& event, | 219 const Event& event, |
225 base::WeakPtr<Accelerator> accelerator); | 220 base::WeakPtr<Accelerator> accelerator); |
226 | 221 |
227 // Registers accelerators used internally for debugging. | 222 // Registers accelerators used internally for debugging. |
228 void AddDebugAccelerators(); | 223 void AddDebugAccelerators(); |
229 | 224 |
230 // Finds the debug accelerator for |event| and if one is found calls | 225 // Finds the debug accelerator for |event| and if one is found calls |
(...skipping 18 matching lines...) Expand all Loading... |
249 void SetNativeCapture(ServerWindow* window) override; | 244 void SetNativeCapture(ServerWindow* window) override; |
250 void ReleaseNativeCapture() override; | 245 void ReleaseNativeCapture() override; |
251 void UpdateNativeCursorFromDispatcher() override; | 246 void UpdateNativeCursorFromDispatcher() override; |
252 void OnCaptureChanged(ServerWindow* new_capture, | 247 void OnCaptureChanged(ServerWindow* new_capture, |
253 ServerWindow* old_capture) override; | 248 ServerWindow* old_capture) override; |
254 void OnMouseCursorLocationChanged(const gfx::Point& point) override; | 249 void OnMouseCursorLocationChanged(const gfx::Point& point) override; |
255 void DispatchInputEventToWindow(ServerWindow* target, | 250 void DispatchInputEventToWindow(ServerWindow* target, |
256 ClientSpecificId client_id, | 251 ClientSpecificId client_id, |
257 const Event& event, | 252 const Event& event, |
258 Accelerator* accelerator) override; | 253 Accelerator* accelerator) override; |
| 254 // Processes the next valid event in |event_queue_|. If the event has already |
| 255 // been processed it is dispatched, otherwise the event is passed to the |
| 256 // EventDispatcher for processing. |
| 257 void ProcessNextEventFromQueue() override; |
259 ClientSpecificId GetEventTargetClientId(const ServerWindow* window, | 258 ClientSpecificId GetEventTargetClientId(const ServerWindow* window, |
260 bool in_nonclient_area) override; | 259 bool in_nonclient_area) override; |
261 ServerWindow* GetRootWindowContaining(gfx::Point* location) override; | 260 ServerWindow* GetRootWindowContaining(gfx::Point* location) override; |
262 void OnEventTargetNotFound(const Event& event) override; | 261 void OnEventTargetNotFound(const Event& event) override; |
263 | 262 |
264 // ServerWindowObserver: | 263 // ServerWindowObserver: |
265 void OnWindowEmbeddedAppDisconnected(ServerWindow* window) override; | 264 void OnWindowEmbeddedAppDisconnected(ServerWindow* window) override; |
266 | 265 |
267 // The single WindowTree this WindowManagerState is associated with. | 266 // The single WindowTree this WindowManagerState is associated with. |
268 // |window_tree_| owns this. | 267 // |window_tree_| owns this. |
269 WindowTree* window_tree_; | 268 WindowTree* window_tree_; |
270 | 269 |
271 // Set to true the first time SetFrameDecorationValues() is called. | 270 // Set to true the first time SetFrameDecorationValues() is called. |
272 bool got_frame_decoration_values_ = false; | 271 bool got_frame_decoration_values_ = false; |
273 mojom::FrameDecorationValuesPtr frame_decoration_values_; | 272 mojom::FrameDecorationValuesPtr frame_decoration_values_; |
274 | 273 |
| 274 // Events can go into this queue if there's a hit-test in flight in |
| 275 // EventDispatcher or if we are actively dispatching an event. |
275 std::queue<std::unique_ptr<QueuedEvent>> event_queue_; | 276 std::queue<std::unique_ptr<QueuedEvent>> event_queue_; |
276 | 277 |
277 std::vector<DebugAccelerator> debug_accelerators_; | 278 std::vector<DebugAccelerator> debug_accelerators_; |
278 | 279 |
279 // If non-null we're actively waiting for a response from a client for an | 280 // If non-null we're actively waiting for a response from a client for an |
280 // event. | 281 // event. |
281 std::unique_ptr<InFlightEventDetails> in_flight_event_details_; | 282 std::unique_ptr<InFlightEventDispatchDetails> |
| 283 in_flight_event_dispatch_details_; |
282 | 284 |
283 EventDispatcher event_dispatcher_; | 285 EventDispatcher event_dispatcher_; |
284 | 286 |
285 // PlatformDisplay that currently has capture. | 287 // PlatformDisplay that currently has capture. |
286 PlatformDisplay* platform_display_with_capture_ = nullptr; | 288 PlatformDisplay* platform_display_with_capture_ = nullptr; |
287 | 289 |
288 // All the active WindowManagerDisplayRoots. | 290 // All the active WindowManagerDisplayRoots. |
289 WindowManagerDisplayRoots window_manager_display_roots_; | 291 WindowManagerDisplayRoots window_manager_display_roots_; |
290 | 292 |
291 // Id of the display the current event being processed originated from. | 293 // Id of the display the current event being processed originated from. |
292 int64_t event_processing_display_id_ = 0; | 294 int64_t event_processing_display_id_ = 0; |
293 | 295 |
294 // Set of WindowManagerDisplayRoots corresponding to Displays that have been | 296 // Set of WindowManagerDisplayRoots corresponding to Displays that have been |
295 // destroyed. WindowManagerDisplayRoots are not destroyed immediately when | 297 // destroyed. WindowManagerDisplayRoots are not destroyed immediately when |
296 // the Display is destroyed to allow the client to destroy the window when it | 298 // the Display is destroyed to allow the client to destroy the window when it |
297 // wants to. Once the client destroys the window WindowManagerDisplayRoots is | 299 // wants to. Once the client destroys the window WindowManagerDisplayRoots is |
298 // destroyed. | 300 // destroyed. |
299 WindowManagerDisplayRoots orphaned_window_manager_display_roots_; | 301 WindowManagerDisplayRoots orphaned_window_manager_display_roots_; |
300 | 302 |
301 // All state regarding what the current cursor is. | 303 // All state regarding what the current cursor is. |
302 CursorState cursor_state_; | 304 CursorState cursor_state_; |
303 | 305 |
304 DISALLOW_COPY_AND_ASSIGN(WindowManagerState); | 306 DISALLOW_COPY_AND_ASSIGN(WindowManagerState); |
305 }; | 307 }; |
306 | 308 |
307 } // namespace ws | 309 } // namespace ws |
308 } // namespace ui | 310 } // namespace ui |
309 | 311 |
310 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ | 312 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ |
OLD | NEW |