Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: services/ui/ws/window_manager_state.h

Issue 2884463002: Make event-targeting asynchronous in window server. (Closed)
Patch Set: comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/ws/test_utils.h ('k') | services/ui/ws/window_manager_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // TODO(sky): EventDispatcher is really an implementation detail and should 93 // TODO(sky): EventDispatcher is really an implementation detail and should
94 // not be exposed. 94 // not be exposed.
95 EventDispatcher* event_dispatcher() { return &event_dispatcher_; } 95 EventDispatcher* event_dispatcher() { return &event_dispatcher_; }
96 96
97 CursorState& cursor_state() { return cursor_state_; } 97 CursorState& cursor_state() { return cursor_state_; }
98 98
99 // Returns true if this is the WindowManager of the active user. 99 // Returns true if this is the WindowManager of the active user.
100 bool IsActive() const; 100 bool IsActive() const;
101 101
102 void Activate(const gfx::Point& mouse_location_on_display, 102 void Activate(const gfx::Point& mouse_location_on_display,
103 const int64_t display_id); 103 int64_t display_id);
104 void Deactivate(); 104 void Deactivate();
105 105
106 // Processes an event from PlatformDisplay. 106 // Processes an event from PlatformDisplay.
107 void ProcessEvent(const Event& event, int64_t display_id); 107 void ProcessEvent(const Event& event, int64_t display_id);
108 108
109 private: 109 private:
110 class ProcessedEventTarget; 110 class ProcessedEventTarget;
111 friend class Display; 111 friend class Display;
112 friend class test::WindowManagerStateTestApi; 112 friend class test::WindowManagerStateTestApi;
113 113
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 struct QueuedEvent { 150 struct QueuedEvent {
151 QueuedEvent(); 151 QueuedEvent();
152 ~QueuedEvent(); 152 ~QueuedEvent();
153 153
154 std::unique_ptr<Event> event; 154 std::unique_ptr<Event> event;
155 std::unique_ptr<ProcessedEventTarget> processed_target; 155 std::unique_ptr<ProcessedEventTarget> processed_target;
156 int64_t display_id; 156 int64_t display_id;
157 }; 157 };
158 158
159 // Tracks state associated with an event being dispatched to a client. 159 // Tracks state associated with an event being dispatched to a client.
160 struct InFlightEventDetails { 160 struct InFlightEventDispatchDetails {
161 InFlightEventDetails(WindowManagerState* window_manager_state, 161 InFlightEventDispatchDetails(WindowManagerState* window_manager_state,
162 WindowTree* tree, 162 WindowTree* tree,
163 int64_t display_id, 163 int64_t display_id,
164 const Event& event, 164 const Event& event,
165 EventDispatchPhase phase); 165 EventDispatchPhase phase);
166 ~InFlightEventDetails(); 166 ~InFlightEventDispatchDetails();
167 167
168 base::OneShotTimer timer; 168 base::OneShotTimer timer;
169 WindowTree* tree; 169 WindowTree* tree;
170 int64_t display_id; 170 int64_t display_id;
171 std::unique_ptr<Event> event; 171 std::unique_ptr<Event> event;
172 EventDispatchPhase phase; 172 EventDispatchPhase phase;
173 base::WeakPtr<Accelerator> post_target_accelerator; 173 base::WeakPtr<Accelerator> post_target_accelerator;
174 // Used for callbacks/timer specific to processing |event|. 174 // Used for callbacks/timer specific to processing |event|.
175 base::WeakPtrFactory<WindowManagerState> weak_factory; 175 base::WeakPtrFactory<WindowManagerState> weak_factory;
176 }; 176 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 // Implemenation of processing an event with a match phase of all. This 211 // Implemenation of processing an event with a match phase of all. This
212 // handles debug accelerators and forwards to EventDispatcher. 212 // handles debug accelerators and forwards to EventDispatcher.
213 void ProcessEventImpl(const Event& event, int64_t display_id); 213 void ProcessEventImpl(const Event& event, int64_t display_id);
214 214
215 // Schedules an event to be processed later. 215 // Schedules an event to be processed later.
216 void QueueEvent(const Event& event, 216 void QueueEvent(const Event& event,
217 std::unique_ptr<ProcessedEventTarget> processed_event_target, 217 std::unique_ptr<ProcessedEventTarget> processed_event_target,
218 int64_t display_id); 218 int64_t display_id);
219 219
220 // Processes the next valid event in |event_queue_|. If the event has already
221 // been processed it is dispatched, otherwise the event is passed to the
222 // EventDispatcher for processing.
223 void ProcessNextEventFromQueue();
224
225 // Dispatches the event to the appropriate client and starts the ack timer. 220 // Dispatches the event to the appropriate client and starts the ack timer.
226 void DispatchInputEventToWindowImpl(ServerWindow* target, 221 void DispatchInputEventToWindowImpl(ServerWindow* target,
227 ClientSpecificId client_id, 222 ClientSpecificId client_id,
228 const int64_t display_id, 223 int64_t display_id,
229 const Event& event, 224 const Event& event,
230 base::WeakPtr<Accelerator> accelerator); 225 base::WeakPtr<Accelerator> accelerator);
231 226
232 // Registers accelerators used internally for debugging. 227 // Registers accelerators used internally for debugging.
233 void AddDebugAccelerators(); 228 void AddDebugAccelerators();
234 229
235 // Finds the debug accelerator for |event| and if one is found calls 230 // Finds the debug accelerator for |event| and if one is found calls
236 // HandleDebugAccelerator(). 231 // HandleDebugAccelerator().
237 void ProcessDebugAccelerator(const Event& event, const int64_t display_id); 232 void ProcessDebugAccelerator(const Event& event, int64_t display_id);
238 233
239 // Runs the specified debug accelerator. 234 // Runs the specified debug accelerator.
240 void HandleDebugAccelerator(DebugAcceleratorType type, 235 void HandleDebugAccelerator(DebugAcceleratorType type, int64_t display_id);
241 const int64_t display_id);
242 236
243 // Called when waiting for an event or accelerator to be processed by |tree|. 237 // Called when waiting for an event or accelerator to be processed by |tree|.
244 void ScheduleInputEventTimeout(WindowTree* tree, 238 void ScheduleInputEventTimeout(WindowTree* tree,
245 ServerWindow* target, 239 ServerWindow* target,
246 const int64_t display_id, 240 int64_t display_id,
247 const Event& event, 241 const Event& event,
248 EventDispatchPhase phase); 242 EventDispatchPhase phase);
249 243
250 // Helper function to convert |point| to be in screen coordinates. |point| as 244 // Helper function to convert |point| to be in screen coordinates. |point| as
251 // the input should be in display-physical-pixel space, and the output is in 245 // the input should be in display-physical-pixel space, and the output is in
252 // screen-dip space. Returns true if the |point| is successfully converted, 246 // screen-dip space. Returns true if the |point| is successfully converted,
253 // false otherwise. 247 // false otherwise.
254 bool ConvertPointToScreen(const int64_t display_id, gfx::Point* point); 248 bool ConvertPointToScreen(int64_t display_id, gfx::Point* point);
255 249
256 // EventDispatcherDelegate: 250 // EventDispatcherDelegate:
257 void OnAccelerator(uint32_t accelerator_id, 251 void OnAccelerator(uint32_t accelerator_id,
258 const int64_t display_id, 252 int64_t display_id,
259 const Event& event, 253 const Event& event,
260 AcceleratorPhase phase) override; 254 AcceleratorPhase phase) override;
261 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override; 255 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override;
262 ServerWindow* GetFocusedWindowForEventDispatcher( 256 ServerWindow* GetFocusedWindowForEventDispatcher(int64_t display_id) override;
263 const int64_t display_id) override;
264 void SetNativeCapture(ServerWindow* window) override; 257 void SetNativeCapture(ServerWindow* window) override;
265 void ReleaseNativeCapture() override; 258 void ReleaseNativeCapture() override;
266 void UpdateNativeCursorFromDispatcher() override; 259 void UpdateNativeCursorFromDispatcher() override;
267 void OnCaptureChanged(ServerWindow* new_capture, 260 void OnCaptureChanged(ServerWindow* new_capture,
268 ServerWindow* old_capture) override; 261 ServerWindow* old_capture) override;
269 void OnMouseCursorLocationChanged(const gfx::Point& point, 262 void OnMouseCursorLocationChanged(const gfx::Point& point,
270 const int64_t display_id) override; 263 int64_t display_id) override;
271 void DispatchInputEventToWindow(ServerWindow* target, 264 void DispatchInputEventToWindow(ServerWindow* target,
272 ClientSpecificId client_id, 265 ClientSpecificId client_id,
273 const int64_t display_id, 266 int64_t display_id,
274 const Event& event, 267 const Event& event,
275 Accelerator* accelerator) override; 268 Accelerator* accelerator) override;
269 // Processes the next valid event in |event_queue_|. If the event has already
270 // been processed it is dispatched, otherwise the event is passed to the
271 // EventDispatcher for processing.
272 void ProcessNextAvailableEvent() override;
276 ClientSpecificId GetEventTargetClientId(const ServerWindow* window, 273 ClientSpecificId GetEventTargetClientId(const ServerWindow* window,
277 bool in_nonclient_area) override; 274 bool in_nonclient_area) override;
278 ServerWindow* GetRootWindowContaining(gfx::Point* location_in_display, 275 ServerWindow* GetRootWindowContaining(gfx::Point* location_in_display,
279 int64_t* display_id) override; 276 int64_t* display_id) override;
280 void OnEventTargetNotFound(const Event& event, 277 void OnEventTargetNotFound(const Event& event, int64_t display_id) override;
281 const int64_t display_id) override;
282 278
283 // ServerWindowObserver: 279 // ServerWindowObserver:
284 void OnWindowEmbeddedAppDisconnected(ServerWindow* window) override; 280 void OnWindowEmbeddedAppDisconnected(ServerWindow* window) override;
285 281
286 // The single WindowTree this WindowManagerState is associated with. 282 // The single WindowTree this WindowManagerState is associated with.
287 // |window_tree_| owns this. 283 // |window_tree_| owns this.
288 WindowTree* window_tree_; 284 WindowTree* window_tree_;
289 285
290 // Set to true the first time SetFrameDecorationValues() is called. 286 // Set to true the first time SetFrameDecorationValues() is called.
291 bool got_frame_decoration_values_ = false; 287 bool got_frame_decoration_values_ = false;
292 mojom::FrameDecorationValuesPtr frame_decoration_values_; 288 mojom::FrameDecorationValuesPtr frame_decoration_values_;
293 289
290 // Events can go into this queue if there's a hit-test in flight in
291 // EventDispatcher or if we are actively dispatching an event.
294 std::queue<std::unique_ptr<QueuedEvent>> event_queue_; 292 std::queue<std::unique_ptr<QueuedEvent>> event_queue_;
295 293
296 std::vector<DebugAccelerator> debug_accelerators_; 294 std::vector<DebugAccelerator> debug_accelerators_;
297 295
298 // If non-null we're actively waiting for a response from a client for an 296 // If non-null we're actively waiting for a response from a client for an
299 // event. 297 // event.
300 std::unique_ptr<InFlightEventDetails> in_flight_event_details_; 298 std::unique_ptr<InFlightEventDispatchDetails>
299 in_flight_event_dispatch_details_;
301 300
302 EventDispatcher event_dispatcher_; 301 EventDispatcher event_dispatcher_;
303 302
304 // PlatformDisplay that currently has capture. 303 // PlatformDisplay that currently has capture.
305 PlatformDisplay* platform_display_with_capture_ = nullptr; 304 PlatformDisplay* platform_display_with_capture_ = nullptr;
306 305
307 // All the active WindowManagerDisplayRoots. 306 // All the active WindowManagerDisplayRoots.
308 WindowManagerDisplayRoots window_manager_display_roots_; 307 WindowManagerDisplayRoots window_manager_display_roots_;
309 308
310 // Set of WindowManagerDisplayRoots corresponding to Displays that have been 309 // Set of WindowManagerDisplayRoots corresponding to Displays that have been
311 // destroyed. WindowManagerDisplayRoots are not destroyed immediately when 310 // destroyed. WindowManagerDisplayRoots are not destroyed immediately when
312 // the Display is destroyed to allow the client to destroy the window when it 311 // the Display is destroyed to allow the client to destroy the window when it
313 // wants to. Once the client destroys the window WindowManagerDisplayRoots is 312 // wants to. Once the client destroys the window WindowManagerDisplayRoots is
314 // destroyed. 313 // destroyed.
315 WindowManagerDisplayRoots orphaned_window_manager_display_roots_; 314 WindowManagerDisplayRoots orphaned_window_manager_display_roots_;
316 315
317 // All state regarding what the current cursor is. 316 // All state regarding what the current cursor is.
318 CursorState cursor_state_; 317 CursorState cursor_state_;
319 318
320 DISALLOW_COPY_AND_ASSIGN(WindowManagerState); 319 DISALLOW_COPY_AND_ASSIGN(WindowManagerState);
321 }; 320 };
322 321
323 } // namespace ws 322 } // namespace ws
324 } // namespace ui 323 } // namespace ui
325 324
326 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ 325 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_
OLDNEW
« no previous file with comments | « services/ui/ws/test_utils.h ('k') | services/ui/ws/window_manager_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698