| 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_WINDOW_TREE_HOST_IMPL_H_ | 5 #ifndef COMPONENTS_MUS_WS_WINDOW_TREE_HOST_IMPL_H_ |
| 6 #define COMPONENTS_MUS_WS_WINDOW_TREE_HOST_IMPL_H_ | 6 #define COMPONENTS_MUS_WS_WINDOW_TREE_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "components/mus/ws/focus_controller_observer.h" | 22 #include "components/mus/ws/focus_controller_observer.h" |
| 23 #include "components/mus/ws/server_window.h" | 23 #include "components/mus/ws/server_window.h" |
| 24 #include "components/mus/ws/server_window_observer.h" | 24 #include "components/mus/ws/server_window_observer.h" |
| 25 #include "components/mus/ws/server_window_tracker.h" | 25 #include "components/mus/ws/server_window_tracker.h" |
| 26 | 26 |
| 27 namespace mus { | 27 namespace mus { |
| 28 namespace ws { | 28 namespace ws { |
| 29 | 29 |
| 30 class ConnectionManager; | 30 class ConnectionManager; |
| 31 class FocusController; | 31 class FocusController; |
| 32 class WindowTreeHostDelegate; | 32 class WindowTreeHostConnection; |
| 33 class WindowTreeImpl; | 33 class WindowTreeImpl; |
| 34 | 34 |
| 35 // WindowTreeHostImpl is an implementation of the WindowTreeHost interface. | 35 // WindowTreeHostImpl is an implementation of the WindowTreeHost interface. |
| 36 // It serves as a top level root window for a window. Its lifetime is managed by | 36 // It serves as a top level root window for a window. Its lifetime is managed by |
| 37 // ConnectionManager. If the connection to the client breaks or if the user | 37 // ConnectionManager. If the connection to the client breaks or if the user |
| 38 // closes the associated window, then this object and related state will be | 38 // closes the associated window, then this object and related state will be |
| 39 // deleted. | 39 // deleted. |
| 40 class WindowTreeHostImpl : public DisplayManagerDelegate, | 40 class WindowTreeHostImpl : public DisplayManagerDelegate, |
| 41 public mojom::WindowTreeHost, | 41 public mojom::WindowTreeHost, |
| 42 public FocusControllerObserver, | 42 public FocusControllerObserver, |
| 43 public FocusControllerDelegate, | 43 public FocusControllerDelegate, |
| 44 public EventDispatcherDelegate, | 44 public EventDispatcherDelegate, |
| 45 public ServerWindowObserver { | 45 public ServerWindowObserver { |
| 46 public: | 46 public: |
| 47 // TODO(fsamuel): All these parameters are just plumbing for creating | 47 // TODO(fsamuel): All these parameters are just plumbing for creating |
| 48 // DisplayManagers. We should probably just store these common parameters | 48 // DisplayManagers. We should probably just store these common parameters |
| 49 // in the DisplayManagerFactory and pass them along on DisplayManager::Create. | 49 // in the DisplayManagerFactory and pass them along on DisplayManager::Create. |
| 50 WindowTreeHostImpl(ConnectionManager* connection_manager, | 50 WindowTreeHostImpl(ConnectionManager* connection_manager, |
| 51 mojo::Connector* connector, | 51 mojo::Connector* connector, |
| 52 const scoped_refptr<GpuState>& gpu_state, | 52 const scoped_refptr<GpuState>& gpu_state, |
| 53 const scoped_refptr<SurfacesState>& surfaces_state); | 53 const scoped_refptr<SurfacesState>& surfaces_state); |
| 54 ~WindowTreeHostImpl() override; | 54 ~WindowTreeHostImpl() override; |
| 55 | 55 |
| 56 // Initializes state that depends on the existence of a WindowTreeHostImpl. | 56 // Initializes state that depends on the existence of a WindowTreeHostImpl. |
| 57 void Init(WindowTreeHostDelegate* delegate); | 57 void Init(scoped_ptr<WindowTreeHostConnection> connection); |
| 58 | 58 |
| 59 uint32_t id() const { return id_; } | 59 uint32_t id() const { return id_; } |
| 60 | 60 |
| 61 const WindowTreeImpl* GetWindowTree() const; | 61 const WindowTreeImpl* GetWindowTree() const; |
| 62 WindowTreeImpl* GetWindowTree(); | 62 WindowTreeImpl* GetWindowTree(); |
| 63 | 63 |
| 64 void SetFrameDecorationValues(mojom::FrameDecorationValuesPtr values); | 64 void SetFrameDecorationValues(mojom::FrameDecorationValuesPtr values); |
| 65 const mojom::FrameDecorationValues& frame_decoration_values() const { | 65 const mojom::FrameDecorationValues& frame_decoration_values() const { |
| 66 return *frame_decoration_values_; | 66 return *frame_decoration_values_; |
| 67 } | 67 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // The second case happens if EventDispatcher generates more than one event | 149 // The second case happens if EventDispatcher generates more than one event |
| 150 // at a time. | 150 // at a time. |
| 151 struct QueuedEvent { | 151 struct QueuedEvent { |
| 152 QueuedEvent(); | 152 QueuedEvent(); |
| 153 ~QueuedEvent(); | 153 ~QueuedEvent(); |
| 154 | 154 |
| 155 mojom::EventPtr event; | 155 mojom::EventPtr event; |
| 156 scoped_ptr<ProcessedEventTarget> processed_target; | 156 scoped_ptr<ProcessedEventTarget> processed_target; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 // Inits the necessary state once the display is ready. |
| 160 void CallOnDisplayInitializedIfNecessary(); |
| 161 |
| 159 void OnEventAckTimeout(); | 162 void OnEventAckTimeout(); |
| 160 | 163 |
| 161 // Schedules an event to be processed later. | 164 // Schedules an event to be processed later. |
| 162 void QueueEvent(mojom::EventPtr event, | 165 void QueueEvent(mojom::EventPtr event, |
| 163 scoped_ptr<ProcessedEventTarget> processed_event_target); | 166 scoped_ptr<ProcessedEventTarget> processed_event_target); |
| 164 | 167 |
| 165 // Processes the next valid event in |event_queue_|. If the event has already | 168 // Processes the next valid event in |event_queue_|. If the event has already |
| 166 // been processed it is dispatched, otherwise the event is passed to the | 169 // been processed it is dispatched, otherwise the event is passed to the |
| 167 // EventDispatcher for processing. | 170 // EventDispatcher for processing. |
| 168 void ProcessNextEventFromQueue(); | 171 void ProcessNextEventFromQueue(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void ReleaseNativeCapture() override; | 206 void ReleaseNativeCapture() override; |
| 204 void OnServerWindowCaptureLost(ServerWindow* window) override; | 207 void OnServerWindowCaptureLost(ServerWindow* window) override; |
| 205 void DispatchInputEventToWindow(ServerWindow* target, | 208 void DispatchInputEventToWindow(ServerWindow* target, |
| 206 bool in_nonclient_area, | 209 bool in_nonclient_area, |
| 207 mojom::EventPtr event) override; | 210 mojom::EventPtr event) override; |
| 208 | 211 |
| 209 // ServerWindowObserver: | 212 // ServerWindowObserver: |
| 210 void OnWindowDestroyed(ServerWindow* window) override; | 213 void OnWindowDestroyed(ServerWindow* window) override; |
| 211 | 214 |
| 212 const uint32_t id_; | 215 const uint32_t id_; |
| 213 WindowTreeHostDelegate* delegate_; | 216 scoped_ptr<WindowTreeHostConnection> window_tree_host_connection_; |
| 217 WindowTreeImpl* window_tree_ = nullptr; |
| 214 ConnectionManager* const connection_manager_; | 218 ConnectionManager* const connection_manager_; |
| 215 EventDispatcher event_dispatcher_; | 219 EventDispatcher event_dispatcher_; |
| 216 scoped_ptr<ServerWindow> root_; | 220 scoped_ptr<ServerWindow> root_; |
| 217 scoped_ptr<DisplayManager> display_manager_; | 221 scoped_ptr<DisplayManager> display_manager_; |
| 218 scoped_ptr<FocusController> focus_controller_; | 222 scoped_ptr<FocusController> focus_controller_; |
| 219 mojom::WindowTree* tree_awaiting_input_ack_; | 223 mojom::WindowTree* tree_awaiting_input_ack_; |
| 220 | 224 |
| 221 // The last cursor set. Used to track whether we need to change the cursor. | 225 // The last cursor set. Used to track whether we need to change the cursor. |
| 222 int32_t last_cursor_; | 226 int32_t last_cursor_; |
| 223 | 227 |
| 224 ServerWindowTracker activation_parents_; | 228 ServerWindowTracker activation_parents_; |
| 225 | 229 |
| 226 // Set of windows with surfaces that need to be destroyed once the frame | 230 // Set of windows with surfaces that need to be destroyed once the frame |
| 227 // draws. | 231 // draws. |
| 228 std::set<ServerWindow*> windows_needing_frame_destruction_; | 232 std::set<ServerWindow*> windows_needing_frame_destruction_; |
| 229 | 233 |
| 230 std::queue<scoped_ptr<QueuedEvent>> event_queue_; | 234 std::queue<scoped_ptr<QueuedEvent>> event_queue_; |
| 231 base::OneShotTimer event_ack_timer_; | 235 base::OneShotTimer event_ack_timer_; |
| 232 | 236 |
| 233 mojom::FrameDecorationValuesPtr frame_decoration_values_; | 237 mojom::FrameDecorationValuesPtr frame_decoration_values_; |
| 234 | 238 |
| 235 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostImpl); | 239 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostImpl); |
| 236 }; | 240 }; |
| 237 | 241 |
| 238 } // namespace ws | 242 } // namespace ws |
| 239 } // namespace mus | 243 } // namespace mus |
| 240 | 244 |
| 241 #endif // COMPONENTS_MUS_WS_WINDOW_TREE_HOST_IMPL_H_ | 245 #endif // COMPONENTS_MUS_WS_WINDOW_TREE_HOST_IMPL_H_ |
| OLD | NEW |