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/window_server.h" | 5 #include "components/mus/ws/window_server.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "components/mus/ws/window_manager_window_tree_factory.h" | 23 #include "components/mus/ws/window_manager_window_tree_factory.h" |
24 #include "components/mus/ws/window_server_delegate.h" | 24 #include "components/mus/ws/window_server_delegate.h" |
25 #include "components/mus/ws/window_tree.h" | 25 #include "components/mus/ws/window_tree.h" |
26 #include "components/mus/ws/window_tree_binding.h" | 26 #include "components/mus/ws/window_tree_binding.h" |
27 #include "services/shell/public/cpp/connection.h" | 27 #include "services/shell/public/cpp/connection.h" |
28 #include "ui/gfx/geometry/size_conversions.h" | 28 #include "ui/gfx/geometry/size_conversions.h" |
29 | 29 |
30 namespace mus { | 30 namespace mus { |
31 namespace ws { | 31 namespace ws { |
32 | 32 |
| 33 struct WindowServer::CurrentMoveLoopState { |
| 34 uint32_t change_id; |
| 35 ServerWindow* window; |
| 36 WindowTree* initiator; |
| 37 gfx::Rect revert_bounds; |
| 38 }; |
| 39 |
33 WindowServer::WindowServer( | 40 WindowServer::WindowServer( |
34 WindowServerDelegate* delegate, | 41 WindowServerDelegate* delegate, |
35 const scoped_refptr<mus::SurfacesState>& surfaces_state) | 42 const scoped_refptr<mus::SurfacesState>& surfaces_state) |
36 : delegate_(delegate), | 43 : delegate_(delegate), |
37 surfaces_state_(surfaces_state), | 44 surfaces_state_(surfaces_state), |
38 next_client_id_(1), | 45 next_client_id_(1), |
39 display_manager_(new DisplayManager(this, &user_id_tracker_)), | 46 display_manager_(new DisplayManager(this, &user_id_tracker_)), |
40 current_operation_(nullptr), | 47 current_operation_(nullptr), |
41 in_destructor_(false), | 48 in_destructor_(false), |
42 next_wm_change_id_(0), | 49 next_wm_change_id_(0), |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 !window || window->id().client_id != wm_tree->id() || | 324 !window || window->id().client_id != wm_tree->id() || |
318 !window->children().empty() || GetTreeWithRoot(window)) { | 325 !window->children().empty() || GetTreeWithRoot(window)) { |
319 WindowManagerSentBogusMessage(); | 326 WindowManagerSentBogusMessage(); |
320 return; | 327 return; |
321 } | 328 } |
322 | 329 |
323 tree->OnWindowManagerCreatedTopLevelWindow(window_manager_change_id, | 330 tree->OnWindowManagerCreatedTopLevelWindow(window_manager_change_id, |
324 change.client_change_id, window); | 331 change.client_change_id, window); |
325 } | 332 } |
326 | 333 |
| 334 void WindowServer::WindowManagerCompletedMoveLoop( |
| 335 uint32_t window_manager_change_id, |
| 336 const ServerWindow* window, |
| 337 bool completed) { |
| 338 InFlightWindowManagerChange change; |
| 339 if (!GetAndClearInFlightWindowManagerChange(window_manager_change_id, |
| 340 &change)) { |
| 341 return; |
| 342 } |
| 343 if (!window) { |
| 344 WindowManagerSentBogusMessage(); |
| 345 return; |
| 346 } |
| 347 |
| 348 WindowTree* tree = GetTreeWithId(change.client_id); |
| 349 tree->OnChangeCompleted(change.client_change_id, completed); |
| 350 } |
| 351 |
327 void WindowServer::ProcessWindowBoundsChanged(const ServerWindow* window, | 352 void WindowServer::ProcessWindowBoundsChanged(const ServerWindow* window, |
328 const gfx::Rect& old_bounds, | 353 const gfx::Rect& old_bounds, |
329 const gfx::Rect& new_bounds) { | 354 const gfx::Rect& new_bounds) { |
330 for (auto& pair : tree_map_) { | 355 for (auto& pair : tree_map_) { |
331 pair.second->ProcessWindowBoundsChanged(window, old_bounds, new_bounds, | 356 pair.second->ProcessWindowBoundsChanged(window, old_bounds, new_bounds, |
332 IsOperationSource(pair.first)); | 357 IsOperationSource(pair.first)); |
333 } | 358 } |
334 } | 359 } |
335 | 360 |
336 void WindowServer::ProcessClientAreaChanged( | 361 void WindowServer::ProcessClientAreaChanged( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 433 } |
409 | 434 |
410 void WindowServer::SetPaintCallback( | 435 void WindowServer::SetPaintCallback( |
411 const base::Callback<void(ServerWindow*)>& callback) { | 436 const base::Callback<void(ServerWindow*)>& callback) { |
412 DCHECK(delegate_->IsTestConfig()) << "Paint callbacks are expensive, and " | 437 DCHECK(delegate_->IsTestConfig()) << "Paint callbacks are expensive, and " |
413 << "allowed only in tests."; | 438 << "allowed only in tests."; |
414 DCHECK(window_paint_callback_.is_null() || callback.is_null()); | 439 DCHECK(window_paint_callback_.is_null() || callback.is_null()); |
415 window_paint_callback_ = callback; | 440 window_paint_callback_ = callback; |
416 } | 441 } |
417 | 442 |
| 443 void WindowServer::StartMoveLoop(uint32_t change_id, |
| 444 ServerWindow* window, |
| 445 WindowTree* initiator, |
| 446 const gfx::Rect& revert_bounds) { |
| 447 current_move_loop_.reset( |
| 448 new CurrentMoveLoopState{change_id, window, initiator, revert_bounds}); |
| 449 } |
| 450 |
| 451 void WindowServer::EndMoveLoop() { |
| 452 current_move_loop_.reset(); |
| 453 } |
| 454 |
| 455 uint32_t WindowServer::GetCurrentMoveLoopChangeId() { |
| 456 if (current_move_loop_) |
| 457 return current_move_loop_->change_id; |
| 458 return 0; |
| 459 } |
| 460 |
| 461 ServerWindow* WindowServer::GetCurrentMoveLoopWindow() { |
| 462 if (current_move_loop_) |
| 463 return current_move_loop_->window; |
| 464 return nullptr; |
| 465 } |
| 466 |
| 467 WindowTree* WindowServer::GetCurrentMoveLoopInitiator() { |
| 468 if (current_move_loop_) |
| 469 return current_move_loop_->initiator; |
| 470 return nullptr; |
| 471 } |
| 472 |
| 473 gfx::Rect WindowServer::GetCurrentMoveLoopRevertBounds() { |
| 474 if (current_move_loop_) |
| 475 return current_move_loop_->revert_bounds; |
| 476 return gfx::Rect(); |
| 477 } |
| 478 |
418 bool WindowServer::GetAndClearInFlightWindowManagerChange( | 479 bool WindowServer::GetAndClearInFlightWindowManagerChange( |
419 uint32_t window_manager_change_id, | 480 uint32_t window_manager_change_id, |
420 InFlightWindowManagerChange* change) { | 481 InFlightWindowManagerChange* change) { |
421 // There are valid reasons as to why we wouldn't know about the id. The | 482 // There are valid reasons as to why we wouldn't know about the id. The |
422 // most likely is the client disconnected before the response from the window | 483 // most likely is the client disconnected before the response from the window |
423 // manager came back. | 484 // manager came back. |
424 auto iter = in_flight_wm_change_map_.find(window_manager_change_id); | 485 auto iter = in_flight_wm_change_map_.find(window_manager_change_id); |
425 if (iter == in_flight_wm_change_map_.end()) | 486 if (iter == in_flight_wm_change_map_.end()) |
426 return false; | 487 return false; |
427 | 488 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 void WindowServer::OnUserIdAdded(const UserId& id) { | 759 void WindowServer::OnUserIdAdded(const UserId& id) { |
699 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 760 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
700 } | 761 } |
701 | 762 |
702 void WindowServer::OnUserIdRemoved(const UserId& id) { | 763 void WindowServer::OnUserIdRemoved(const UserId& id) { |
703 activity_monitor_map_.erase(id); | 764 activity_monitor_map_.erase(id); |
704 } | 765 } |
705 | 766 |
706 } // namespace ws | 767 } // namespace ws |
707 } // namespace mus | 768 } // namespace mus |
OLD | NEW |