| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 WindowTree* WindowServer::GetTreeWithClientName( | 187 WindowTree* WindowServer::GetTreeWithClientName( |
| 188 const std::string& client_name) { | 188 const std::string& client_name) { |
| 189 for (const auto& entry : tree_map_) { | 189 for (const auto& entry : tree_map_) { |
| 190 if (entry.second->name() == client_name) | 190 if (entry.second->name() == client_name) |
| 191 return entry.second.get(); | 191 return entry.second.get(); |
| 192 } | 192 } |
| 193 return nullptr; | 193 return nullptr; |
| 194 } | 194 } |
| 195 | 195 |
| 196 WindowTree* WindowServer::GetTreeForExternalWindowMode() { |
| 197 DCHECK_LE(1u, tree_map_.size()); |
| 198 DCHECK(IsInExternalWindowMode()); |
| 199 return tree_map_.begin()->second.get(); |
| 200 } |
| 201 |
| 196 ServerWindow* WindowServer::GetWindow(const WindowId& id) { | 202 ServerWindow* WindowServer::GetWindow(const WindowId& id) { |
| 197 // kInvalidClientId is used for Display and WindowManager nodes. | 203 // kInvalidClientId is used for Display and WindowManager nodes. |
| 198 if (id.client_id == kInvalidClientId) { | 204 if (id.client_id == kInvalidClientId) { |
| 199 for (Display* display : display_manager_->displays()) { | 205 for (Display* display : display_manager_->displays()) { |
| 200 ServerWindow* window = display->GetRootWithId(id); | 206 ServerWindow* window = display->GetRootWithId(id); |
| 201 if (window) | 207 if (window) |
| 202 return window; | 208 return window; |
| 203 } | 209 } |
| 204 // WindowManagerDisplayRoots are destroyed by the client and not held by | 210 // WindowManagerDisplayRoots are destroyed by the client and not held by |
| 205 // the Display. | 211 // the Display. |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 | 578 |
| 573 void WindowServer::FinishOperation() { | 579 void WindowServer::FinishOperation() { |
| 574 // PrepareForOperation/FinishOperation should be balanced. | 580 // PrepareForOperation/FinishOperation should be balanced. |
| 575 CHECK(current_operation_); | 581 CHECK(current_operation_); |
| 576 current_operation_ = nullptr; | 582 current_operation_ = nullptr; |
| 577 } | 583 } |
| 578 | 584 |
| 579 void WindowServer::UpdateNativeCursorFromMouseLocation(ServerWindow* window) { | 585 void WindowServer::UpdateNativeCursorFromMouseLocation(ServerWindow* window) { |
| 580 WindowManagerDisplayRoot* display_root = | 586 WindowManagerDisplayRoot* display_root = |
| 581 display_manager_->GetWindowManagerDisplayRoot(window); | 587 display_manager_->GetWindowManagerDisplayRoot(window); |
| 582 if (display_root) { | 588 if (display_root && display_root->window_manager_state()) { |
| 583 EventDispatcher* event_dispatcher = | 589 EventDispatcher* event_dispatcher = |
| 584 display_root->window_manager_state()->event_dispatcher(); | 590 display_root->window_manager_state()->event_dispatcher(); |
| 585 event_dispatcher->UpdateCursorProviderByLastKnownLocation(); | 591 event_dispatcher->UpdateCursorProviderByLastKnownLocation(); |
| 586 display_root->display()->UpdateNativeCursor( | 592 display_root->display()->UpdateNativeCursor( |
| 587 event_dispatcher->GetCurrentMouseCursor()); | 593 event_dispatcher->GetCurrentMouseCursor()); |
| 588 } | 594 } |
| 589 } | 595 } |
| 590 | 596 |
| 591 void WindowServer::UpdateNativeCursorIfOver(ServerWindow* window) { | 597 void WindowServer::UpdateNativeCursorIfOver(ServerWindow* window) { |
| 592 WindowManagerDisplayRoot* display_root = | 598 WindowManagerDisplayRoot* display_root = |
| 593 display_manager_->GetWindowManagerDisplayRoot(window); | 599 display_manager_->GetWindowManagerDisplayRoot(window); |
| 594 if (!display_root) | 600 if (!display_root || !display_root->window_manager_state()) |
| 595 return; | 601 return; |
| 596 | 602 |
| 597 EventDispatcher* event_dispatcher = | 603 EventDispatcher* event_dispatcher = |
| 598 display_root->window_manager_state()->event_dispatcher(); | 604 display_root->window_manager_state()->event_dispatcher(); |
| 599 if (window != event_dispatcher->GetWindowForMouseCursor()) | 605 if (window != event_dispatcher->GetWindowForMouseCursor()) |
| 600 return; | 606 return; |
| 601 | 607 |
| 602 event_dispatcher->UpdateNonClientAreaForCurrentWindow(); | 608 event_dispatcher->UpdateNonClientAreaForCurrentWindow(); |
| 603 display_root->display()->UpdateNativeCursor( | 609 display_root->display()->UpdateNativeCursor( |
| 604 event_dispatcher->GetCurrentMouseCursor()); | 610 event_dispatcher->GetCurrentMouseCursor()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 } | 664 } |
| 659 | 665 |
| 660 void WindowServer::OnWindowHierarchyChanged(ServerWindow* window, | 666 void WindowServer::OnWindowHierarchyChanged(ServerWindow* window, |
| 661 ServerWindow* new_parent, | 667 ServerWindow* new_parent, |
| 662 ServerWindow* old_parent) { | 668 ServerWindow* old_parent) { |
| 663 if (in_destructor_) | 669 if (in_destructor_) |
| 664 return; | 670 return; |
| 665 | 671 |
| 666 WindowManagerDisplayRoot* display_root = | 672 WindowManagerDisplayRoot* display_root = |
| 667 display_manager_->GetWindowManagerDisplayRoot(window); | 673 display_manager_->GetWindowManagerDisplayRoot(window); |
| 668 if (display_root) | 674 if (display_root && display_root->window_manager_state()) |
| 669 display_root->window_manager_state() | 675 display_root->window_manager_state() |
| 670 ->ReleaseCaptureBlockedByAnyModalWindow(); | 676 ->ReleaseCaptureBlockedByAnyModalWindow(); |
| 671 | 677 |
| 672 ProcessWindowHierarchyChanged(window, new_parent, old_parent); | 678 ProcessWindowHierarchyChanged(window, new_parent, old_parent); |
| 673 | 679 |
| 674 if (old_parent) { | 680 if (old_parent) { |
| 675 display_compositor_->UnregisterFrameSinkHierarchy( | 681 display_compositor_->UnregisterFrameSinkHierarchy( |
| 676 old_parent->frame_sink_id(), window->frame_sink_id()); | 682 old_parent->frame_sink_id(), window->frame_sink_id()); |
| 677 } | 683 } |
| 678 if (new_parent) { | 684 if (new_parent) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 IsOperationSource(pair.first)); | 743 IsOperationSource(pair.first)); |
| 738 } | 744 } |
| 739 } | 745 } |
| 740 | 746 |
| 741 void WindowServer::OnWindowVisibilityChanged(ServerWindow* window) { | 747 void WindowServer::OnWindowVisibilityChanged(ServerWindow* window) { |
| 742 if (in_destructor_) | 748 if (in_destructor_) |
| 743 return; | 749 return; |
| 744 | 750 |
| 745 WindowManagerDisplayRoot* display_root = | 751 WindowManagerDisplayRoot* display_root = |
| 746 display_manager_->GetWindowManagerDisplayRoot(window); | 752 display_manager_->GetWindowManagerDisplayRoot(window); |
| 747 if (display_root) | 753 if (display_root && display_root->window_manager_state()) |
| 748 display_root->window_manager_state()->ReleaseCaptureBlockedByModalWindow( | 754 display_root->window_manager_state()->ReleaseCaptureBlockedByModalWindow( |
| 749 window); | 755 window); |
| 750 } | 756 } |
| 751 | 757 |
| 752 void WindowServer::OnWindowPredefinedCursorChanged(ServerWindow* window, | 758 void WindowServer::OnWindowPredefinedCursorChanged(ServerWindow* window, |
| 753 mojom::Cursor cursor_id) { | 759 mojom::Cursor cursor_id) { |
| 754 if (in_destructor_) | 760 if (in_destructor_) |
| 755 return; | 761 return; |
| 756 | 762 |
| 757 ProcessWillChangeWindowPredefinedCursor(window, cursor_id); | 763 ProcessWillChangeWindowPredefinedCursor(window, cursor_id); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 void WindowServer::OnUserIdAdded(const UserId& id) { | 860 void WindowServer::OnUserIdAdded(const UserId& id) { |
| 855 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 861 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
| 856 } | 862 } |
| 857 | 863 |
| 858 void WindowServer::OnUserIdRemoved(const UserId& id) { | 864 void WindowServer::OnUserIdRemoved(const UserId& id) { |
| 859 activity_monitor_map_.erase(id); | 865 activity_monitor_map_.erase(id); |
| 860 } | 866 } |
| 861 | 867 |
| 862 } // namespace ws | 868 } // namespace ws |
| 863 } // namespace ui | 869 } // namespace ui |
| OLD | NEW |