Chromium Code Reviews| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 | 89 |
| 90 // TODO(sky): EventDispatcher is really an implementation detail and should | 90 // TODO(sky): EventDispatcher is really an implementation detail and should |
| 91 // not be exposed. | 91 // not be exposed. |
| 92 EventDispatcher* event_dispatcher() { return &event_dispatcher_; } | 92 EventDispatcher* event_dispatcher() { return &event_dispatcher_; } |
| 93 | 93 |
| 94 CursorState& cursor_state() { return cursor_state_; } | 94 CursorState& cursor_state() { return cursor_state_; } |
| 95 | 95 |
| 96 // Returns true if this is the WindowManager of the active user. | 96 // Returns true if this is the WindowManager of the active user. |
| 97 bool IsActive() const; | 97 bool IsActive() const; |
| 98 | 98 |
| 99 void Activate(const gfx::Point& mouse_location_on_screen); | 99 void Activate(const gfx::Point& mouse_location_on_display, |
| 100 const int64_t display_id); | |
| 100 void Deactivate(); | 101 void Deactivate(); |
| 101 | 102 |
| 102 // Processes an event from PlatformDisplay. | 103 // Processes an event from PlatformDisplay. |
| 103 void ProcessEvent(const Event& event, int64_t display_id); | 104 void ProcessEvent(const Event& event, int64_t display_id); |
| 104 | 105 |
| 105 private: | 106 private: |
| 106 class ProcessedEventTarget; | 107 class ProcessedEventTarget; |
| 107 friend class Display; | 108 friend class Display; |
| 108 friend class test::WindowManagerStateTestApi; | 109 friend class test::WindowManagerStateTestApi; |
| 109 | 110 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 int64_t display_id); | 215 int64_t display_id); |
| 215 | 216 |
| 216 // Processes the next valid event in |event_queue_|. If the event has already | 217 // 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 // been processed it is dispatched, otherwise the event is passed to the |
| 218 // EventDispatcher for processing. | 219 // EventDispatcher for processing. |
| 219 void ProcessNextEventFromQueue(); | 220 void ProcessNextEventFromQueue(); |
| 220 | 221 |
| 221 // Dispatches the event to the appropriate client and starts the ack timer. | 222 // Dispatches the event to the appropriate client and starts the ack timer. |
| 222 void DispatchInputEventToWindowImpl(ServerWindow* target, | 223 void DispatchInputEventToWindowImpl(ServerWindow* target, |
| 223 ClientSpecificId client_id, | 224 ClientSpecificId client_id, |
| 225 const int64_t display_id, | |
| 224 const Event& event, | 226 const Event& event, |
| 225 base::WeakPtr<Accelerator> accelerator); | 227 base::WeakPtr<Accelerator> accelerator); |
| 226 | 228 |
| 227 // Registers accelerators used internally for debugging. | 229 // Registers accelerators used internally for debugging. |
| 228 void AddDebugAccelerators(); | 230 void AddDebugAccelerators(); |
| 229 | 231 |
| 230 // Finds the debug accelerator for |event| and if one is found calls | 232 // Finds the debug accelerator for |event| and if one is found calls |
| 231 // HandleDebugAccelerator(). | 233 // HandleDebugAccelerator(). |
| 232 void ProcessDebugAccelerator(const Event& event); | 234 void ProcessDebugAccelerator(const Event& event, const int64_t display_id); |
| 233 | 235 |
| 234 // Runs the specified debug accelerator. | 236 // Runs the specified debug accelerator. |
| 235 void HandleDebugAccelerator(DebugAcceleratorType type); | 237 void HandleDebugAccelerator(DebugAcceleratorType type, |
| 238 const int64_t display_id); | |
| 236 | 239 |
| 237 // Called when waiting for an event or accelerator to be processed by |tree|. | 240 // Called when waiting for an event or accelerator to be processed by |tree|. |
| 238 void ScheduleInputEventTimeout(WindowTree* tree, | 241 void ScheduleInputEventTimeout(WindowTree* tree, |
| 239 ServerWindow* target, | 242 ServerWindow* target, |
| 243 const int64_t display_id, | |
| 240 const Event& event, | 244 const Event& event, |
| 241 EventDispatchPhase phase); | 245 EventDispatchPhase phase); |
| 242 | 246 |
| 247 // Helper function to update |point| to be in screen coordinates. | |
| 248 bool ConvertPointToScreen(gfx::Point* point, const int64_t display_id); | |
|
sky
2017/05/25 22:10:19
Style guide says out params should be last. Also,
riajiang
2017/05/25 22:59:23
Done.
| |
| 249 | |
| 243 // EventDispatcherDelegate: | 250 // EventDispatcherDelegate: |
| 244 void OnAccelerator(uint32_t accelerator_id, | 251 void OnAccelerator(uint32_t accelerator_id, |
| 252 const int64_t display_id, | |
| 245 const Event& event, | 253 const Event& event, |
| 246 AcceleratorPhase phase) override; | 254 AcceleratorPhase phase) override; |
| 247 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override; | 255 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override; |
| 248 ServerWindow* GetFocusedWindowForEventDispatcher() override; | 256 ServerWindow* GetFocusedWindowForEventDispatcher(int64_t display_id) override; |
| 249 void SetNativeCapture(ServerWindow* window) override; | 257 void SetNativeCapture(ServerWindow* window) override; |
| 250 void ReleaseNativeCapture() override; | 258 void ReleaseNativeCapture() override; |
| 251 void UpdateNativeCursorFromDispatcher() override; | 259 void UpdateNativeCursorFromDispatcher() override; |
| 252 void OnCaptureChanged(ServerWindow* new_capture, | 260 void OnCaptureChanged(ServerWindow* new_capture, |
| 253 ServerWindow* old_capture) override; | 261 ServerWindow* old_capture) override; |
| 254 void OnMouseCursorLocationChanged(const gfx::Point& point) override; | 262 void OnMouseCursorLocationChanged(const gfx::Point& point, |
| 263 const int64_t display_id) override; | |
| 255 void DispatchInputEventToWindow(ServerWindow* target, | 264 void DispatchInputEventToWindow(ServerWindow* target, |
| 256 ClientSpecificId client_id, | 265 ClientSpecificId client_id, |
| 266 const int64_t display_id, | |
| 257 const Event& event, | 267 const Event& event, |
| 258 Accelerator* accelerator) override; | 268 Accelerator* accelerator) override; |
| 259 ClientSpecificId GetEventTargetClientId(const ServerWindow* window, | 269 ClientSpecificId GetEventTargetClientId(const ServerWindow* window, |
| 260 bool in_nonclient_area) override; | 270 bool in_nonclient_area) override; |
| 261 ServerWindow* GetRootWindowContaining(gfx::Point* location) override; | 271 ServerWindow* GetRootWindowContaining(gfx::Point* location_in_display, |
| 262 void OnEventTargetNotFound(const Event& event) override; | 272 int64_t* display_id) override; |
| 273 void OnEventTargetNotFound(const Event& event, | |
| 274 const int64_t display_id) override; | |
| 263 | 275 |
| 264 // ServerWindowObserver: | 276 // ServerWindowObserver: |
| 265 void OnWindowEmbeddedAppDisconnected(ServerWindow* window) override; | 277 void OnWindowEmbeddedAppDisconnected(ServerWindow* window) override; |
| 266 | 278 |
| 267 // The single WindowTree this WindowManagerState is associated with. | 279 // The single WindowTree this WindowManagerState is associated with. |
| 268 // |window_tree_| owns this. | 280 // |window_tree_| owns this. |
| 269 WindowTree* window_tree_; | 281 WindowTree* window_tree_; |
| 270 | 282 |
| 271 // Set to true the first time SetFrameDecorationValues() is called. | 283 // Set to true the first time SetFrameDecorationValues() is called. |
| 272 bool got_frame_decoration_values_ = false; | 284 bool got_frame_decoration_values_ = false; |
| 273 mojom::FrameDecorationValuesPtr frame_decoration_values_; | 285 mojom::FrameDecorationValuesPtr frame_decoration_values_; |
| 274 | 286 |
| 275 std::queue<std::unique_ptr<QueuedEvent>> event_queue_; | 287 std::queue<std::unique_ptr<QueuedEvent>> event_queue_; |
| 276 | 288 |
| 277 std::vector<DebugAccelerator> debug_accelerators_; | 289 std::vector<DebugAccelerator> debug_accelerators_; |
| 278 | 290 |
| 279 // If non-null we're actively waiting for a response from a client for an | 291 // If non-null we're actively waiting for a response from a client for an |
| 280 // event. | 292 // event. |
| 281 std::unique_ptr<InFlightEventDetails> in_flight_event_details_; | 293 std::unique_ptr<InFlightEventDetails> in_flight_event_details_; |
| 282 | 294 |
| 283 EventDispatcher event_dispatcher_; | 295 EventDispatcher event_dispatcher_; |
| 284 | 296 |
| 285 // PlatformDisplay that currently has capture. | 297 // PlatformDisplay that currently has capture. |
| 286 PlatformDisplay* platform_display_with_capture_ = nullptr; | 298 PlatformDisplay* platform_display_with_capture_ = nullptr; |
| 287 | 299 |
| 288 // All the active WindowManagerDisplayRoots. | 300 // All the active WindowManagerDisplayRoots. |
| 289 WindowManagerDisplayRoots window_manager_display_roots_; | 301 WindowManagerDisplayRoots window_manager_display_roots_; |
| 290 | 302 |
| 291 // Id of the display the current event being processed originated from. | |
| 292 int64_t event_processing_display_id_ = 0; | |
| 293 | |
| 294 // Set of WindowManagerDisplayRoots corresponding to Displays that have been | 303 // Set of WindowManagerDisplayRoots corresponding to Displays that have been |
| 295 // destroyed. WindowManagerDisplayRoots are not destroyed immediately when | 304 // destroyed. WindowManagerDisplayRoots are not destroyed immediately when |
| 296 // the Display is destroyed to allow the client to destroy the window when it | 305 // 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 | 306 // wants to. Once the client destroys the window WindowManagerDisplayRoots is |
| 298 // destroyed. | 307 // destroyed. |
| 299 WindowManagerDisplayRoots orphaned_window_manager_display_roots_; | 308 WindowManagerDisplayRoots orphaned_window_manager_display_roots_; |
| 300 | 309 |
| 301 // All state regarding what the current cursor is. | 310 // All state regarding what the current cursor is. |
| 302 CursorState cursor_state_; | 311 CursorState cursor_state_; |
| 303 | 312 |
| 304 DISALLOW_COPY_AND_ASSIGN(WindowManagerState); | 313 DISALLOW_COPY_AND_ASSIGN(WindowManagerState); |
| 305 }; | 314 }; |
| 306 | 315 |
| 307 } // namespace ws | 316 } // namespace ws |
| 308 } // namespace ui | 317 } // namespace ui |
| 309 | 318 |
| 310 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ | 319 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ |
| OLD | NEW |