Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: services/ui/ws/window_server.cc

Issue 2904993003: chromeos: changes how DisplayManagerObservers are notified (Closed)
Patch Set: cleanup Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/ws/window_server.h ('k') | services/ui/ws/window_server_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "services/ui/ws/display.h" 13 #include "services/ui/ws/display.h"
14 #include "services/ui/ws/display_creation_config.h"
14 #include "services/ui/ws/display_manager.h" 15 #include "services/ui/ws/display_manager.h"
15 #include "services/ui/ws/frame_generator.h" 16 #include "services/ui/ws/frame_generator.h"
16 #include "services/ui/ws/gpu_host.h" 17 #include "services/ui/ws/gpu_host.h"
17 #include "services/ui/ws/operation.h" 18 #include "services/ui/ws/operation.h"
18 #include "services/ui/ws/server_window.h" 19 #include "services/ui/ws/server_window.h"
19 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" 20 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h"
20 #include "services/ui/ws/user_activity_monitor.h" 21 #include "services/ui/ws/user_activity_monitor.h"
21 #include "services/ui/ws/window_coordinate_conversions.h" 22 #include "services/ui/ws/window_coordinate_conversions.h"
22 #include "services/ui/ws/window_manager_access_policy.h" 23 #include "services/ui/ws/window_manager_access_policy.h"
23 #include "services/ui/ws/window_manager_display_root.h" 24 #include "services/ui/ws/window_manager_display_root.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 63
63 WindowServer::WindowServer(WindowServerDelegate* delegate) 64 WindowServer::WindowServer(WindowServerDelegate* delegate)
64 : delegate_(delegate), 65 : delegate_(delegate),
65 next_client_id_(1), 66 next_client_id_(1),
66 display_manager_(new DisplayManager(this, &user_id_tracker_)), 67 display_manager_(new DisplayManager(this, &user_id_tracker_)),
67 current_operation_(nullptr), 68 current_operation_(nullptr),
68 in_destructor_(false), 69 in_destructor_(false),
69 next_wm_change_id_(0), 70 next_wm_change_id_(0),
70 gpu_host_(new GpuHost(this)), 71 gpu_host_(new GpuHost(this)),
71 window_manager_window_tree_factory_set_(this, &user_id_tracker_), 72 window_manager_window_tree_factory_set_(this, &user_id_tracker_),
72 frame_sink_manager_client_binding_(this) { 73 frame_sink_manager_client_binding_(this),
74 display_creation_config_(DisplayCreationConfig::UNKNOWN) {
73 user_id_tracker_.AddObserver(this); 75 user_id_tracker_.AddObserver(this);
74 OnUserIdAdded(user_id_tracker_.active_id()); 76 OnUserIdAdded(user_id_tracker_.active_id());
75 gpu_host_->CreateFrameSinkManager( 77 gpu_host_->CreateFrameSinkManager(
76 mojo::MakeRequest(&frame_sink_manager_), 78 mojo::MakeRequest(&frame_sink_manager_),
77 frame_sink_manager_client_binding_.CreateInterfacePtrAndBind()); 79 frame_sink_manager_client_binding_.CreateInterfacePtrAndBind());
78 } 80 }
79 81
80 WindowServer::~WindowServer() { 82 WindowServer::~WindowServer() {
81 in_destructor_ = true; 83 in_destructor_ = true;
82 84
83 for (auto& pair : tree_map_) 85 for (auto& pair : tree_map_)
84 pair.second->PrepareForWindowServerShutdown(); 86 pair.second->PrepareForWindowServerShutdown();
85 87
86 // Destroys the window trees results in querying for the display. Tear down 88 // Destroys the window trees results in querying for the display. Tear down
87 // the displays first so that the trees are notified of the display going 89 // the displays first so that the trees are notified of the display going
88 // away while the display is still valid. 90 // away while the display is still valid.
89 display_manager_->DestroyAllDisplays(); 91 display_manager_->DestroyAllDisplays();
90 92
91 while (!tree_map_.empty()) 93 while (!tree_map_.empty())
92 DestroyTree(tree_map_.begin()->second.get()); 94 DestroyTree(tree_map_.begin()->second.get());
93 95
94 display_manager_.reset(); 96 display_manager_.reset();
95 } 97 }
96 98
99 void WindowServer::SetDisplayCreationConfig(DisplayCreationConfig config) {
100 DCHECK(tree_map_.empty());
101 DCHECK_EQ(DisplayCreationConfig::UNKNOWN, display_creation_config_);
102 display_creation_config_ = config;
103 display_manager_->OnDisplayCreationConfigSet();
104 }
105
97 ServerWindow* WindowServer::CreateServerWindow( 106 ServerWindow* WindowServer::CreateServerWindow(
98 const WindowId& id, 107 const WindowId& id,
99 const std::map<std::string, std::vector<uint8_t>>& properties) { 108 const std::map<std::string, std::vector<uint8_t>>& properties) {
100 ServerWindow* window = new ServerWindow(this, id, properties); 109 ServerWindow* window = new ServerWindow(this, id, properties);
101 window->AddObserver(this); 110 window->AddObserver(this);
102 return window; 111 return window;
103 } 112 }
104 113
105 ClientSpecificId WindowServer::GetAndAdvanceNextClientId() { 114 ClientSpecificId WindowServer::GetAndAdvanceNextClientId() {
106 const ClientSpecificId id = next_client_id_++; 115 const ClientSpecificId id = next_client_id_++;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 WindowTree* tree = tree_impl_ptr.get(); 152 WindowTree* tree = tree_impl_ptr.get();
144 tree_map_[tree->id()] = std::move(tree_impl_ptr); 153 tree_map_[tree->id()] = std::move(tree_impl_ptr);
145 tree->Init(std::move(binding), std::move(tree_ptr)); 154 tree->Init(std::move(binding), std::move(tree_ptr));
146 } 155 }
147 156
148 WindowTree* WindowServer::CreateTreeForWindowManager( 157 WindowTree* WindowServer::CreateTreeForWindowManager(
149 const UserId& user_id, 158 const UserId& user_id,
150 mojom::WindowTreeRequest window_tree_request, 159 mojom::WindowTreeRequest window_tree_request,
151 mojom::WindowTreeClientPtr window_tree_client, 160 mojom::WindowTreeClientPtr window_tree_client,
152 bool automatically_create_display_roots) { 161 bool automatically_create_display_roots) {
162 delegate_->OnWillCreateTreeForWindowManager(
163 automatically_create_display_roots);
164
153 std::unique_ptr<WindowTree> window_tree(new WindowTree( 165 std::unique_ptr<WindowTree> window_tree(new WindowTree(
154 this, user_id, nullptr, base::WrapUnique(new WindowManagerAccessPolicy))); 166 this, user_id, nullptr, base::WrapUnique(new WindowManagerAccessPolicy)));
155 std::unique_ptr<WindowTreeBinding> window_tree_binding = 167 std::unique_ptr<WindowTreeBinding> window_tree_binding =
156 delegate_->CreateWindowTreeBinding( 168 delegate_->CreateWindowTreeBinding(
157 WindowServerDelegate::BindingType::WINDOW_MANAGER, this, 169 WindowServerDelegate::BindingType::WINDOW_MANAGER, this,
158 window_tree.get(), &window_tree_request, &window_tree_client); 170 window_tree.get(), &window_tree_request, &window_tree_client);
159 if (!window_tree_binding) { 171 if (!window_tree_binding) {
160 window_tree_binding = base::MakeUnique<DefaultWindowTreeBinding>( 172 window_tree_binding = base::MakeUnique<DefaultWindowTreeBinding>(
161 window_tree.get(), this, std::move(window_tree_request), 173 window_tree.get(), this, std::move(window_tree_request),
162 std::move(window_tree_client)); 174 std::move(window_tree_client));
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 void WindowServer::OnUserIdAdded(const UserId& id) { 883 void WindowServer::OnUserIdAdded(const UserId& id) {
872 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); 884 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr);
873 } 885 }
874 886
875 void WindowServer::OnUserIdRemoved(const UserId& id) { 887 void WindowServer::OnUserIdRemoved(const UserId& id) {
876 activity_monitor_map_.erase(id); 888 activity_monitor_map_.erase(id);
877 } 889 }
878 890
879 } // namespace ws 891 } // namespace ws
880 } // namespace ui 892 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_server.h ('k') | services/ui/ws/window_server_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698