OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/mus/ws/connection_manager.h" | 5 #include "components/mus/ws/connection_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "components/mus/ws/client_connection.h" | 9 #include "components/mus/ws/client_connection.h" |
10 #include "components/mus/ws/connection_manager_delegate.h" | 10 #include "components/mus/ws/connection_manager_delegate.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 DCHECK(service_connection_it != connection_map_.end()); | 131 DCHECK(service_connection_it != connection_map_.end()); |
132 | 132 |
133 // Tear down the associated WindowTree connection. | 133 // Tear down the associated WindowTree connection. |
134 // TODO(fsamuel): I don't think this is quite right, we should tear down all | 134 // TODO(fsamuel): I don't think this is quite right, we should tear down all |
135 // connections within the root's viewport. We should probably employ an | 135 // connections within the root's viewport. We should probably employ an |
136 // observer pattern to do this. Each WindowTreeImpl should track its | 136 // observer pattern to do this. Each WindowTreeImpl should track its |
137 // parent's lifetime. | 137 // parent's lifetime. |
138 host_connection_map_.erase(it); | 138 host_connection_map_.erase(it); |
139 OnConnectionError(service_connection_it->second); | 139 OnConnectionError(service_connection_it->second); |
140 | 140 |
| 141 for (auto& pair : connection_map_) { |
| 142 pair.second->service()->OnWillDestroyWindowTreeHost( |
| 143 connection->window_tree_host()); |
| 144 } |
| 145 |
141 // If we have no more roots left, let the app know so it can terminate. | 146 // If we have no more roots left, let the app know so it can terminate. |
142 if (!host_connection_map_.size()) | 147 if (!host_connection_map_.size()) |
143 delegate_->OnNoMoreRootConnections(); | 148 delegate_->OnNoMoreRootConnections(); |
144 } | 149 } |
145 | 150 |
146 WindowTreeImpl* ConnectionManager::EmbedAtWindow( | 151 WindowTreeImpl* ConnectionManager::EmbedAtWindow( |
147 ServerWindow* root, | 152 ServerWindow* root, |
148 uint32_t policy_bitmask, | 153 uint32_t policy_bitmask, |
149 mojom::WindowTreeClientPtr client) { | 154 mojom::WindowTreeClientPtr client) { |
150 mojom::WindowTreePtr service_ptr; | 155 mojom::WindowTreePtr service_ptr; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 InFlightWindowManagerChange change; | 268 InFlightWindowManagerChange change; |
264 if (!GetAndClearInFlightWindowManagerChange(window_manager_change_id, | 269 if (!GetAndClearInFlightWindowManagerChange(window_manager_change_id, |
265 &change)) { | 270 &change)) { |
266 return; | 271 return; |
267 } | 272 } |
268 | 273 |
269 WindowTreeImpl* connection = GetConnection(change.connection_id); | 274 WindowTreeImpl* connection = GetConnection(change.connection_id); |
270 connection->OnChangeCompleted(change.client_change_id, success); | 275 connection->OnChangeCompleted(change.client_change_id, success); |
271 } | 276 } |
272 | 277 |
| 278 void ConnectionManager::WindowManagerCreatedTopLevelWindow( |
| 279 WindowTreeImpl* wm_connection, |
| 280 uint32_t window_manager_change_id, |
| 281 Id transport_window_id) { |
| 282 InFlightWindowManagerChange change; |
| 283 if (!GetAndClearInFlightWindowManagerChange(window_manager_change_id, |
| 284 &change)) { |
| 285 return; |
| 286 } |
| 287 |
| 288 const WindowId window_id(WindowIdFromTransportId(transport_window_id)); |
| 289 const ServerWindow* window = GetWindow(window_id); |
| 290 WindowTreeImpl* connection = GetConnection(change.connection_id); |
| 291 // The window manager should have created the window already, and it should |
| 292 // be ready for embedding. |
| 293 if (!connection->IsWaitingForNewTopLevelWindow(window_manager_change_id) || |
| 294 !window || window->id().connection_id != wm_connection->id() || |
| 295 !window->children().empty() || GetConnectionWithRoot(window)) { |
| 296 WindowManagerSentBogusMessage(connection); |
| 297 return; |
| 298 } |
| 299 |
| 300 connection->OnWindowManagerCreatedTopLevelWindow( |
| 301 window_manager_change_id, change.client_change_id, window_id); |
| 302 } |
| 303 |
273 void ConnectionManager::ProcessWindowBoundsChanged( | 304 void ConnectionManager::ProcessWindowBoundsChanged( |
274 const ServerWindow* window, | 305 const ServerWindow* window, |
275 const gfx::Rect& old_bounds, | 306 const gfx::Rect& old_bounds, |
276 const gfx::Rect& new_bounds) { | 307 const gfx::Rect& new_bounds) { |
277 for (auto& pair : connection_map_) { | 308 for (auto& pair : connection_map_) { |
278 pair.second->service()->ProcessWindowBoundsChanged( | 309 pair.second->service()->ProcessWindowBoundsChanged( |
279 window, old_bounds, new_bounds, IsOperationSource(pair.first)); | 310 window, old_bounds, new_bounds, IsOperationSource(pair.first)); |
280 } | 311 } |
281 } | 312 } |
282 | 313 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 return; | 579 return; |
549 for (auto& pair : connection_map_) { | 580 for (auto& pair : connection_map_) { |
550 pair.second->service()->ProcessTransientWindowRemoved( | 581 pair.second->service()->ProcessTransientWindowRemoved( |
551 window, transient_child, IsOperationSource(pair.first)); | 582 window, transient_child, IsOperationSource(pair.first)); |
552 } | 583 } |
553 } | 584 } |
554 | 585 |
555 } // namespace ws | 586 } // namespace ws |
556 | 587 |
557 } // namespace mus | 588 } // namespace mus |
OLD | NEW |