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( | |
|
Fady Samuel
2017/02/24 18:07:38
nit: TODO that we should plumb a bool to ServerWin
kylechar
2017/02/28 18:07:17
Done.
| |
| 610 ServerWindow* window) { | |
| 611 DCHECK(window->parent()); | |
| 612 | |
| 613 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); | |
| 614 if (window_tree) { | |
| 615 // If the parent of |window| is part of a WindowTree, the WindowTree root | |
| 616 // that contains |window| should be backed by a CompositorFrameSink. | |
| 617 for (const ServerWindow* root : window_tree->roots()) { | |
| 618 if (root->Contains(window)) | |
| 619 // TODO(kylechar): There must be a better way to do this. | |
| 620 return const_cast<ServerWindow*>(root); | |
| 621 } | |
| 622 } | |
| 623 | |
| 624 // The parent of |window| might be a display root which isn't part of a | |
| 625 // WindowTree. Display roots will always be backed by a CompositorFrameSink. | |
| 626 Display* display = display_manager_->GetDisplayContaining(window); | |
| 627 if (display && display->root_window() == window->parent()) | |
| 628 return display->root_window(); | |
| 629 | |
| 630 return nullptr; | |
| 631 } | |
| 632 | |
| 609 ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) { | 633 ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) { |
| 610 Display* display = display_manager_->GetDisplayContaining(window); | 634 Display* display = display_manager_->GetDisplayContaining(window); |
| 611 return display ? display->root_window() : nullptr; | 635 return display ? display->root_window() : nullptr; |
| 612 } | 636 } |
| 613 | 637 |
| 614 void WindowServer::OnWindowDestroyed(ServerWindow* window) { | 638 void WindowServer::OnWindowDestroyed(ServerWindow* window) { |
| 615 ProcessWindowDeleted(window); | 639 ProcessWindowDeleted(window); |
| 616 } | 640 } |
| 617 | 641 |
| 618 void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window, | 642 void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 // If we're deleting a window, then this is a superfluous message. | 778 // If we're deleting a window, then this is a superfluous message. |
| 755 if (current_operation_type() == OperationType::DELETE_WINDOW) | 779 if (current_operation_type() == OperationType::DELETE_WINDOW) |
| 756 return; | 780 return; |
| 757 for (auto& pair : tree_map_) { | 781 for (auto& pair : tree_map_) { |
| 758 pair.second->ProcessTransientWindowRemoved(window, transient_child, | 782 pair.second->ProcessTransientWindowRemoved(window, transient_child, |
| 759 IsOperationSource(pair.first)); | 783 IsOperationSource(pair.first)); |
| 760 } | 784 } |
| 761 } | 785 } |
| 762 | 786 |
| 763 void WindowServer::OnGpuServiceInitialized() { | 787 void WindowServer::OnGpuServiceInitialized() { |
| 764 // TODO(kylechar): When gpu channel is removed, this can instead happen | |
| 765 // earlier, after GpuHost::OnInitialized(). | |
| 766 delegate_->StartDisplayInit(); | 788 delegate_->StartDisplayInit(); |
| 767 } | 789 } |
| 768 | 790 |
| 769 void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { | 791 void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { |
| 770 WindowId window_id( | 792 WindowId window_id( |
| 771 WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id())); | 793 WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id())); |
| 772 ServerWindow* window = GetWindow(window_id); | 794 ServerWindow* window = GetWindow(window_id); |
| 773 // If the window doesn't have a parent then we have nothing to propagate. | 795 // If the window doesn't have a parent then we have nothing to propagate. |
| 774 if (!window) | 796 if (!window) { |
| 797 display_compositor_->DropTemporaryReference(surface_info.id()); | |
| 775 return; | 798 return; |
| 799 } | |
| 776 | 800 |
| 777 // FrameGenerator will add an appropriate reference for the new surface. | 801 // FrameGenerator will add an appropriate reference for the new surface. |
| 778 DCHECK(display_manager_->GetDisplayContaining(window)); | 802 DCHECK(display_manager_->GetDisplayContaining(window)); |
| 779 auto* display = display_manager_->GetDisplayContaining(window); | 803 auto* display = display_manager_->GetDisplayContaining(window); |
| 780 if (window == display->GetActiveRootWindow()) { | 804 if (window == display->GetActiveRootWindow()) { |
| 781 display->platform_display()->GetFrameGenerator()->OnSurfaceCreated( | 805 display->platform_display()->GetFrameGenerator()->OnSurfaceCreated( |
| 782 surface_info); | 806 surface_info); |
| 783 } | 807 } |
| 784 | 808 |
| 785 // This is only used for testing to observe that a window has a | 809 // This is only used for testing to observe that a window has a |
| 786 // CompositorFrame. | 810 // CompositorFrame. |
| 787 if (!window_paint_callback_.is_null()) | 811 if (!window_paint_callback_.is_null()) |
| 788 window_paint_callback_.Run(window); | 812 window_paint_callback_.Run(window); |
| 789 | 813 |
| 790 if (!window->parent()) | 814 if (!window->parent()) { |
| 815 // If |window| is a display root then a surface reference has already been | |
| 816 // added by the DisplayCompositor. | |
| 817 display_compositor_->DropTemporaryReference(surface_info.id()); | |
| 791 return; | 818 return; |
| 819 } | |
| 792 | 820 |
| 793 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); | 821 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); |
| 794 if (window_tree) | 822 if (window_tree) |
| 795 window_tree->ProcessWindowSurfaceChanged(window, surface_info); | 823 window_tree->ProcessWindowSurfaceChanged(window, surface_info); |
| 824 | |
| 825 ServerWindow* parent = FindCompositorFrameSinkParent(window); | |
|
Fady Samuel
2017/02/24 18:07:38
nit: compositing_parent
kylechar
2017/02/28 18:07:16
Done.
| |
| 826 if (parent) { | |
| 827 auto* frame_sink_manager = parent->GetOrCreateCompositorFrameSinkManager(); | |
| 828 frame_sink_manager->ClaimTemporaryReference(surface_info.id()); | |
|
Fady Samuel
2017/02/24 18:07:38
Add a comment here about what this is doing.
kylechar
2017/02/28 18:07:15
Done.
| |
| 829 } else { | |
| 830 display_compositor_->DropTemporaryReference(surface_info.id()); | |
| 831 } | |
| 796 } | 832 } |
| 797 | 833 |
| 798 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, | 834 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, |
| 799 const UserId& active_id) { | 835 const UserId& active_id) { |
| 800 } | 836 } |
| 801 | 837 |
| 802 void WindowServer::OnUserIdAdded(const UserId& id) { | 838 void WindowServer::OnUserIdAdded(const UserId& id) { |
| 803 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 839 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
| 804 } | 840 } |
| 805 | 841 |
| 806 void WindowServer::OnUserIdRemoved(const UserId& id) { | 842 void WindowServer::OnUserIdRemoved(const UserId& id) { |
| 807 activity_monitor_map_.erase(id); | 843 activity_monitor_map_.erase(id); |
| 808 } | 844 } |
| 809 | 845 |
| 810 } // namespace ws | 846 } // namespace ws |
| 811 } // namespace ui | 847 } // namespace ui |
| OLD | NEW |