| 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 "services/ui/ws/window_server.h" | 5 #include "services/ui/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 19 matching lines...) Expand all Loading... |
| 30 namespace ui { | 30 namespace ui { |
| 31 namespace ws { | 31 namespace ws { |
| 32 | 32 |
| 33 struct WindowServer::CurrentMoveLoopState { | 33 struct WindowServer::CurrentMoveLoopState { |
| 34 uint32_t change_id; | 34 uint32_t change_id; |
| 35 ServerWindow* window; | 35 ServerWindow* window; |
| 36 WindowTree* initiator; | 36 WindowTree* initiator; |
| 37 gfx::Rect revert_bounds; | 37 gfx::Rect revert_bounds; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 WindowServer::WindowServer( | 40 WindowServer::WindowServer(WindowServerDelegate* delegate) |
| 41 WindowServerDelegate* delegate, | |
| 42 const scoped_refptr<ui::SurfacesState>& surfaces_state) | |
| 43 : delegate_(delegate), | 41 : delegate_(delegate), |
| 44 surfaces_state_(surfaces_state), | 42 surfaces_state_(new SurfacesState()), |
| 45 next_client_id_(1), | 43 next_client_id_(1), |
| 46 display_manager_(new DisplayManager(this, &user_id_tracker_)), | 44 display_manager_(new DisplayManager(this, &user_id_tracker_)), |
| 47 current_operation_(nullptr), | 45 current_operation_(nullptr), |
| 48 in_destructor_(false), | 46 in_destructor_(false), |
| 49 next_wm_change_id_(0), | 47 next_wm_change_id_(0), |
| 50 window_manager_window_tree_factory_set_(this, &user_id_tracker_) { | 48 window_manager_window_tree_factory_set_(this, &user_id_tracker_) { |
| 51 user_id_tracker_.AddObserver(this); | 49 user_id_tracker_.AddObserver(this); |
| 52 OnUserIdAdded(user_id_tracker_.active_id()); | 50 OnUserIdAdded(user_id_tracker_.active_id()); |
| 53 } | 51 } |
| 54 | 52 |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 return current_move_loop_->initiator; | 475 return current_move_loop_->initiator; |
| 478 return nullptr; | 476 return nullptr; |
| 479 } | 477 } |
| 480 | 478 |
| 481 gfx::Rect WindowServer::GetCurrentMoveLoopRevertBounds() { | 479 gfx::Rect WindowServer::GetCurrentMoveLoopRevertBounds() { |
| 482 if (current_move_loop_) | 480 if (current_move_loop_) |
| 483 return current_move_loop_->revert_bounds; | 481 return current_move_loop_->revert_bounds; |
| 484 return gfx::Rect(); | 482 return gfx::Rect(); |
| 485 } | 483 } |
| 486 | 484 |
| 485 void WindowServer::OnFirstDisplayReady() { |
| 486 delegate_->OnFirstDisplayReady(); |
| 487 } |
| 488 |
| 489 void WindowServer::OnNoMoreDisplays() { |
| 490 delegate_->OnNoMoreDisplays(); |
| 491 } |
| 492 |
| 493 WindowManagerState* WindowServer::GetWindowManagerStateForUser( |
| 494 const UserId& user_id) { |
| 495 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( |
| 496 user_id); |
| 497 } |
| 498 |
| 499 ui::SurfacesState* WindowServer::GetSurfacesState() { |
| 500 return surfaces_state_.get(); |
| 501 } |
| 502 |
| 503 bool WindowServer::GetFrameDecorationsForUser( |
| 504 const UserId& user_id, |
| 505 mojom::FrameDecorationValuesPtr* values) { |
| 506 WindowManagerState* window_manager_state = |
| 507 window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( |
| 508 user_id); |
| 509 if (!window_manager_state) |
| 510 return false; |
| 511 if (values && window_manager_state->got_frame_decoration_values()) |
| 512 *values = window_manager_state->frame_decoration_values().Clone(); |
| 513 return window_manager_state->got_frame_decoration_values(); |
| 514 } |
| 515 |
| 487 bool WindowServer::GetAndClearInFlightWindowManagerChange( | 516 bool WindowServer::GetAndClearInFlightWindowManagerChange( |
| 488 uint32_t window_manager_change_id, | 517 uint32_t window_manager_change_id, |
| 489 InFlightWindowManagerChange* change) { | 518 InFlightWindowManagerChange* change) { |
| 490 // There are valid reasons as to why we wouldn't know about the id. The | 519 // There are valid reasons as to why we wouldn't know about the id. The |
| 491 // most likely is the client disconnected before the response from the window | 520 // most likely is the client disconnected before the response from the window |
| 492 // manager came back. | 521 // manager came back. |
| 493 auto iter = in_flight_wm_change_map_.find(window_manager_change_id); | 522 auto iter = in_flight_wm_change_map_.find(window_manager_change_id); |
| 494 if (iter == in_flight_wm_change_map_.end()) | 523 if (iter == in_flight_wm_change_map_.end()) |
| 495 return false; | 524 return false; |
| 496 | 525 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 int32_t cursor_id = 0; | 568 int32_t cursor_id = 0; |
| 540 if (event_dispatcher->GetCurrentMouseCursor(&cursor_id)) | 569 if (event_dispatcher->GetCurrentMouseCursor(&cursor_id)) |
| 541 display_root->display()->UpdateNativeCursor(cursor_id); | 570 display_root->display()->UpdateNativeCursor(cursor_id); |
| 542 } | 571 } |
| 543 | 572 |
| 544 bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { | 573 bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { |
| 545 const auto iter = high_contrast_mode_.find(user); | 574 const auto iter = high_contrast_mode_.find(user); |
| 546 return (iter == high_contrast_mode_.end()) ? false : iter->second; | 575 return (iter == high_contrast_mode_.end()) ? false : iter->second; |
| 547 } | 576 } |
| 548 | 577 |
| 549 ui::SurfacesState* WindowServer::GetSurfacesState() { | |
| 550 return surfaces_state_.get(); | |
| 551 } | |
| 552 | |
| 553 void WindowServer::OnScheduleWindowPaint(ServerWindow* window) { | 578 void WindowServer::OnScheduleWindowPaint(ServerWindow* window) { |
| 554 if (in_destructor_) | 579 if (in_destructor_) |
| 555 return; | 580 return; |
| 556 | 581 |
| 557 SchedulePaint(window, gfx::Rect(window->bounds().size())); | 582 SchedulePaint(window, gfx::Rect(window->bounds().size())); |
| 558 if (!window_paint_callback_.is_null()) | 583 if (!window_paint_callback_.is_null()) |
| 559 window_paint_callback_.Run(window); | 584 window_paint_callback_.Run(window); |
| 560 } | 585 } |
| 561 | 586 |
| 562 const ServerWindow* WindowServer::GetRootWindow( | 587 const ServerWindow* WindowServer::GetRootWindow( |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 ServerWindow* transient_child) { | 757 ServerWindow* transient_child) { |
| 733 // If we're deleting a window, then this is a superfluous message. | 758 // If we're deleting a window, then this is a superfluous message. |
| 734 if (current_operation_type() == OperationType::DELETE_WINDOW) | 759 if (current_operation_type() == OperationType::DELETE_WINDOW) |
| 735 return; | 760 return; |
| 736 for (auto& pair : tree_map_) { | 761 for (auto& pair : tree_map_) { |
| 737 pair.second->ProcessTransientWindowRemoved(window, transient_child, | 762 pair.second->ProcessTransientWindowRemoved(window, transient_child, |
| 738 IsOperationSource(pair.first)); | 763 IsOperationSource(pair.first)); |
| 739 } | 764 } |
| 740 } | 765 } |
| 741 | 766 |
| 742 void WindowServer::OnFirstDisplayReady() { | |
| 743 delegate_->OnFirstDisplayReady(); | |
| 744 } | |
| 745 | |
| 746 void WindowServer::OnNoMoreDisplays() { | |
| 747 delegate_->OnNoMoreDisplays(); | |
| 748 } | |
| 749 | |
| 750 bool WindowServer::GetFrameDecorationsForUser( | |
| 751 const UserId& user_id, | |
| 752 mojom::FrameDecorationValuesPtr* values) { | |
| 753 WindowManagerState* window_manager_state = | |
| 754 window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( | |
| 755 user_id); | |
| 756 if (!window_manager_state) | |
| 757 return false; | |
| 758 if (values && window_manager_state->got_frame_decoration_values()) | |
| 759 *values = window_manager_state->frame_decoration_values().Clone(); | |
| 760 return window_manager_state->got_frame_decoration_values(); | |
| 761 } | |
| 762 | |
| 763 WindowManagerState* WindowServer::GetWindowManagerStateForUser( | |
| 764 const UserId& user_id) { | |
| 765 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( | |
| 766 user_id); | |
| 767 } | |
| 768 | |
| 769 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, | 767 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, |
| 770 const UserId& active_id) { | 768 const UserId& active_id) { |
| 771 if (IsUserInHighContrastMode(previously_active_id) == | 769 if (IsUserInHighContrastMode(previously_active_id) == |
| 772 IsUserInHighContrastMode(active_id)) | 770 IsUserInHighContrastMode(active_id)) |
| 773 return; | 771 return; |
| 774 for (Display* display : display_manager_->displays()) { | 772 for (Display* display : display_manager_->displays()) { |
| 775 display->SchedulePaint(display->root_window(), | 773 display->SchedulePaint(display->root_window(), |
| 776 gfx::Rect(display->root_window()->bounds().size())); | 774 gfx::Rect(display->root_window()->bounds().size())); |
| 777 } | 775 } |
| 778 } | 776 } |
| 779 | 777 |
| 780 void WindowServer::OnUserIdAdded(const UserId& id) { | 778 void WindowServer::OnUserIdAdded(const UserId& id) { |
| 781 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 779 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
| 782 clipboard_map_[id] = base::MakeUnique<clipboard::ClipboardImpl>(); | 780 clipboard_map_[id] = base::MakeUnique<clipboard::ClipboardImpl>(); |
| 783 } | 781 } |
| 784 | 782 |
| 785 void WindowServer::OnUserIdRemoved(const UserId& id) { | 783 void WindowServer::OnUserIdRemoved(const UserId& id) { |
| 786 activity_monitor_map_.erase(id); | 784 activity_monitor_map_.erase(id); |
| 787 clipboard_map_.erase(id); | 785 clipboard_map_.erase(id); |
| 788 } | 786 } |
| 789 | 787 |
| 790 } // namespace ws | 788 } // namespace ws |
| 791 } // namespace ui | 789 } // namespace ui |
| OLD | NEW |