Chromium Code Reviews| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 event_dispatcher->UpdateNonClientAreaForCurrentWindow(); | 599 event_dispatcher->UpdateNonClientAreaForCurrentWindow(); |
| 600 display_root->display()->UpdateNativeCursor( | 600 display_root->display()->UpdateNativeCursor( |
| 601 event_dispatcher->GetCurrentMouseCursor()); | 601 event_dispatcher->GetCurrentMouseCursor()); |
| 602 } | 602 } |
| 603 | 603 |
| 604 bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { | 604 bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { |
| 605 const auto iter = high_contrast_mode_.find(user); | 605 const auto iter = high_contrast_mode_.find(user); |
| 606 return (iter == high_contrast_mode_.end()) ? false : iter->second; | 606 return (iter == high_contrast_mode_.end()) ? false : iter->second; |
| 607 } | 607 } |
| 608 | 608 |
| 609 ServerWindow* WindowServer::FindCompositorFrameSinkParent( | |
| 610 ServerWindow* window) { | |
| 611 if (!window->parent()) | |
| 612 return nullptr; | |
| 613 | |
| 614 // TODO(kylechar): Add a bool to ServerWindow to indicate if the window is | |
| 615 // backed by a CompositorFrameSink (eg. it will submit CompositorFrames). | |
| 616 | |
| 617 // If the parent of |window| is part of a WindowTree, the WindowTree root that | |
|
sky
2017/02/28 20:42:54
Can you describe why does this code need to check
kylechar
2017/02/28 20:54:05
A new cc::Surface that corresponds to |window| was
kylechar
2017/02/28 20:54:52
Want the comments for this method expanded to expl
| |
| 618 // contains |window| should be backed by a CompositorFrameSink. | |
| 619 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); | |
| 620 if (window_tree) { | |
| 621 for (const ServerWindow* root : window_tree->roots()) { | |
| 622 if (root->Contains(window)) | |
| 623 // TODO(kylechar): Walk up parents until one with the backed by | |
| 624 // CompositorFrameSink bool is found instead. | |
| 625 return const_cast<ServerWindow*>(root); | |
| 626 } | |
| 627 } | |
| 628 | |
| 629 return nullptr; | |
| 630 } | |
| 631 | |
| 609 ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) { | 632 ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) { |
| 610 Display* display = display_manager_->GetDisplayContaining(window); | 633 Display* display = display_manager_->GetDisplayContaining(window); |
| 611 return display ? display->root_window() : nullptr; | 634 return display ? display->root_window() : nullptr; |
| 612 } | 635 } |
| 613 | 636 |
| 614 void WindowServer::OnWindowDestroyed(ServerWindow* window) { | 637 void WindowServer::OnWindowDestroyed(ServerWindow* window) { |
| 615 ProcessWindowDeleted(window); | 638 ProcessWindowDeleted(window); |
| 616 } | 639 } |
| 617 | 640 |
| 618 void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window, | 641 void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 // If we're deleting a window, then this is a superfluous message. | 786 // If we're deleting a window, then this is a superfluous message. |
| 764 if (current_operation_type() == OperationType::DELETE_WINDOW) | 787 if (current_operation_type() == OperationType::DELETE_WINDOW) |
| 765 return; | 788 return; |
| 766 for (auto& pair : tree_map_) { | 789 for (auto& pair : tree_map_) { |
| 767 pair.second->ProcessTransientWindowRemoved(window, transient_child, | 790 pair.second->ProcessTransientWindowRemoved(window, transient_child, |
| 768 IsOperationSource(pair.first)); | 791 IsOperationSource(pair.first)); |
| 769 } | 792 } |
| 770 } | 793 } |
| 771 | 794 |
| 772 void WindowServer::OnGpuServiceInitialized() { | 795 void WindowServer::OnGpuServiceInitialized() { |
| 773 // TODO(kylechar): When gpu channel is removed, this can instead happen | |
| 774 // earlier, after GpuHost::OnInitialized(). | |
| 775 delegate_->StartDisplayInit(); | 796 delegate_->StartDisplayInit(); |
| 776 } | 797 } |
| 777 | 798 |
| 778 void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { | 799 void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { |
| 779 WindowId window_id( | 800 WindowId window_id( |
| 780 WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id())); | 801 WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id())); |
| 781 ServerWindow* window = GetWindow(window_id); | 802 ServerWindow* window = GetWindow(window_id); |
| 803 | |
| 782 // If the window doesn't have a parent then we have nothing to propagate. | 804 // If the window doesn't have a parent then we have nothing to propagate. |
| 783 if (!window) | 805 if (!window) { |
| 806 display_compositor_->DropTemporaryReference(surface_info.id()); | |
| 784 return; | 807 return; |
| 808 } | |
| 809 | |
| 810 ServerWindow* compositing_parent = nullptr; | |
| 785 | 811 |
| 786 // FrameGenerator will add an appropriate reference for the new surface. | 812 // FrameGenerator will add an appropriate reference for the new surface. |
| 787 DCHECK(display_manager_->GetDisplayContaining(window)); | 813 DCHECK(display_manager_->GetDisplayContaining(window)); |
| 788 auto* display = display_manager_->GetDisplayContaining(window); | 814 auto* display = display_manager_->GetDisplayContaining(window); |
| 789 if (window == display->GetActiveRootWindow()) { | 815 if (window == display->GetActiveRootWindow()) { |
| 790 display->platform_display()->GetFrameGenerator()->OnSurfaceCreated( | 816 display->platform_display()->GetFrameGenerator()->OnSurfaceCreated( |
| 791 surface_info); | 817 surface_info); |
| 818 compositing_parent = display->root_window(); | |
| 792 } | 819 } |
| 793 | 820 |
| 794 // This is only used for testing to observe that a window has a | 821 // This is only used for testing to observe that a window has a |
| 795 // CompositorFrame. | 822 // CompositorFrame. |
| 796 if (!window_paint_callback_.is_null()) | 823 if (!window_paint_callback_.is_null()) |
| 797 window_paint_callback_.Run(window); | 824 window_paint_callback_.Run(window); |
| 798 | 825 |
| 799 if (!window->parent()) | 826 if (!window->parent()) { |
| 827 // If |window| is a display root then a surface reference has already been | |
| 828 // added by the DisplayCompositor. If not then nothing embeds |window|. | |
| 829 display_compositor_->DropTemporaryReference(surface_info.id()); | |
| 800 return; | 830 return; |
| 831 } | |
| 801 | 832 |
| 802 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); | 833 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); |
| 803 if (window_tree) | 834 if (window_tree) |
| 804 window_tree->ProcessWindowSurfaceChanged(window, surface_info); | 835 window_tree->ProcessWindowSurfaceChanged(window, surface_info); |
| 836 | |
| 837 if (!compositing_parent) | |
| 838 compositing_parent = FindCompositorFrameSinkParent(window); | |
| 839 | |
| 840 if (compositing_parent) { | |
| 841 // The parent ServerWindow backed by a CompositorFrameSink is expected to | |
| 842 // add surface reference to the new surface. Let the DisplayCompositor know | |
| 843 // who the parent is in case something happens to the parent before it can | |
| 844 // add a surface reference. This ensures there are no dangling temporary | |
| 845 // references. | |
| 846 compositing_parent->GetOrCreateCompositorFrameSinkManager() | |
| 847 ->ClaimTemporaryReference(surface_info.id()); | |
| 848 } else { | |
| 849 display_compositor_->DropTemporaryReference(surface_info.id()); | |
| 850 } | |
| 805 } | 851 } |
| 806 | 852 |
| 807 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, | 853 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, |
| 808 const UserId& active_id) { | 854 const UserId& active_id) { |
| 809 } | 855 } |
| 810 | 856 |
| 811 void WindowServer::OnUserIdAdded(const UserId& id) { | 857 void WindowServer::OnUserIdAdded(const UserId& id) { |
| 812 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 858 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
| 813 } | 859 } |
| 814 | 860 |
| 815 void WindowServer::OnUserIdRemoved(const UserId& id) { | 861 void WindowServer::OnUserIdRemoved(const UserId& id) { |
| 816 activity_monitor_map_.erase(id); | 862 activity_monitor_map_.erase(id); |
| 817 } | 863 } |
| 818 | 864 |
| 819 } // namespace ws | 865 } // namespace ws |
| 820 } // namespace ui | 866 } // namespace ui |
| OLD | NEW |