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

Side by Side Diff: mash/wm/window_manager_application.cc

Issue 1550693002: Global conversion of Pass()→std::move() on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 | « mash/wm/accelerator_registrar_impl.cc ('k') | mash/wm/window_manager_apptest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mash/wm/window_manager_application.h" 5 #include "mash/wm/window_manager_application.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "components/mus/common/util.h" 11 #include "components/mus/common/util.h"
11 #include "components/mus/public/cpp/event_matcher.h" 12 #include "components/mus/public/cpp/event_matcher.h"
12 #include "components/mus/public/cpp/window.h" 13 #include "components/mus/public/cpp/window.h"
13 #include "components/mus/public/cpp/window_tree_connection.h" 14 #include "components/mus/public/cpp/window_tree_connection.h"
14 #include "components/mus/public/cpp/window_tree_host_factory.h" 15 #include "components/mus/public/cpp/window_tree_host_factory.h"
15 #include "mash/wm/accelerator_registrar_impl.h" 16 #include "mash/wm/accelerator_registrar_impl.h"
16 #include "mash/wm/background_layout.h" 17 #include "mash/wm/background_layout.h"
17 #include "mash/wm/shadow_controller.h" 18 #include "mash/wm/shadow_controller.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { 76 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) {
76 app_ = app; 77 app_ = app;
77 tracing_.Initialize(app); 78 tracing_.Initialize(app);
78 window_manager_.reset(new WindowManagerImpl()); 79 window_manager_.reset(new WindowManagerImpl());
79 // Don't bind to the WindowManager immediately. Wait for OnEmbed() first. 80 // Don't bind to the WindowManager immediately. Wait for OnEmbed() first.
80 mus::mojom::WindowManagerPtr window_manager; 81 mus::mojom::WindowManagerPtr window_manager;
81 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( 82 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>(
82 mojo::GetProxy(&window_manager))); 83 mojo::GetProxy(&window_manager)));
83 mus::mojom::WindowTreeHostClientPtr host_client; 84 mus::mojom::WindowTreeHostClientPtr host_client;
84 host_client_binding_.Bind(GetProxy(&host_client)); 85 host_client_binding_.Bind(GetProxy(&host_client));
85 mus::CreateSingleWindowTreeHost(app, host_client.Pass(), this, 86 mus::CreateSingleWindowTreeHost(app, std::move(host_client), this,
86 &window_tree_host_, window_manager.Pass(), 87 &window_tree_host_, std::move(window_manager),
87 window_manager_.get()); 88 window_manager_.get());
88 } 89 }
89 90
90 bool WindowManagerApplication::ConfigureIncomingConnection( 91 bool WindowManagerApplication::ConfigureIncomingConnection(
91 mojo::ApplicationConnection* connection) { 92 mojo::ApplicationConnection* connection) {
92 connection->AddService<mus::mojom::AcceleratorRegistrar>(this); 93 connection->AddService<mus::mojom::AcceleratorRegistrar>(this);
93 connection->AddService<mus::mojom::WindowManager>(this); 94 connection->AddService<mus::mojom::WindowManager>(this);
94 return true; 95 return true;
95 } 96 }
96 97
97 void WindowManagerApplication::OnAccelerator(uint32_t id, 98 void WindowManagerApplication::OnAccelerator(uint32_t id,
98 mus::mojom::EventPtr event) { 99 mus::mojom::EventPtr event) {
99 switch (id) { 100 switch (id) {
100 case kWindowSwitchCmd: 101 case kWindowSwitchCmd:
101 window_tree_host_->ActivateNextWindow(); 102 window_tree_host_->ActivateNextWindow();
102 break; 103 break;
103 default: 104 default:
104 for (auto* registrar : accelerator_registrars_) { 105 for (auto* registrar : accelerator_registrars_) {
105 if (registrar->OwnsAccelerator(id)) { 106 if (registrar->OwnsAccelerator(id)) {
106 registrar->ProcessAccelerator(id, event.Pass()); 107 registrar->ProcessAccelerator(id, std::move(event));
107 break; 108 break;
108 } 109 }
109 } 110 }
110 } 111 }
111 } 112 }
112 113
113 void WindowManagerApplication::OnEmbed(mus::Window* root) { 114 void WindowManagerApplication::OnEmbed(mus::Window* root) {
114 root_ = root; 115 root_ = root;
115 root_->AddObserver(this); 116 root_->AddObserver(this);
116 CreateContainers(); 117 CreateContainers();
117 background_layout_.reset(new BackgroundLayout( 118 background_layout_.reset(new BackgroundLayout(
118 GetWindowForContainer(mojom::CONTAINER_USER_BACKGROUND))); 119 GetWindowForContainer(mojom::CONTAINER_USER_BACKGROUND)));
119 shelf_layout_.reset( 120 shelf_layout_.reset(
120 new ShelfLayout(GetWindowForContainer(mojom::CONTAINER_USER_SHELF))); 121 new ShelfLayout(GetWindowForContainer(mojom::CONTAINER_USER_SHELF)));
121 122
122 mus::Window* window = GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS); 123 mus::Window* window = GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS);
123 window_layout_.reset( 124 window_layout_.reset(
124 new WindowLayout(GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS))); 125 new WindowLayout(GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS)));
125 window_tree_host_->AddActivationParent(window->id()); 126 window_tree_host_->AddActivationParent(window->id());
126 window_tree_host_->SetTitle("Mash"); 127 window_tree_host_->SetTitle("Mash");
127 128
128 AddAccelerators(); 129 AddAccelerators();
129 130
130 ui_init_.reset(new ui::mojo::UIInit(views::GetDisplaysFromWindow(root))); 131 ui_init_.reset(new ui::mojo::UIInit(views::GetDisplaysFromWindow(root)));
131 aura_init_.reset(new views::AuraInit(app_, "mash_wm_resources.pak")); 132 aura_init_.reset(new views::AuraInit(app_, "mash_wm_resources.pak"));
132 window_manager_->Initialize(this); 133 window_manager_->Initialize(this);
133 134
134 for (auto request : requests_) 135 for (auto request : requests_)
135 window_manager_binding_.AddBinding(window_manager_.get(), request->Pass()); 136 window_manager_binding_.AddBinding(window_manager_.get(),
137 std::move(*request));
136 requests_.clear(); 138 requests_.clear();
137 139
138 shadow_controller_.reset(new ShadowController(root->connection())); 140 shadow_controller_.reset(new ShadowController(root->connection()));
139 } 141 }
140 142
141 void WindowManagerApplication::OnConnectionLost( 143 void WindowManagerApplication::OnConnectionLost(
142 mus::WindowTreeConnection* connection) { 144 mus::WindowTreeConnection* connection) {
143 // TODO(sky): shutdown. 145 // TODO(sky): shutdown.
144 NOTIMPLEMENTED(); 146 NOTIMPLEMENTED();
145 shadow_controller_.reset(); 147 shadow_controller_.reset();
146 } 148 }
147 149
148 void WindowManagerApplication::Create( 150 void WindowManagerApplication::Create(
149 mojo::ApplicationConnection* connection, 151 mojo::ApplicationConnection* connection,
150 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { 152 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) {
151 static int accelerator_registrar_count = 0; 153 static int accelerator_registrar_count = 0;
152 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { 154 if (accelerator_registrar_count == std::numeric_limits<int>::max()) {
153 // Restart from zero if we have reached the limit. It is technically 155 // Restart from zero if we have reached the limit. It is technically
154 // possible to end up with multiple active registrars with the same 156 // possible to end up with multiple active registrars with the same
155 // namespace, but it is highly unlikely. In the event that multiple 157 // namespace, but it is highly unlikely. In the event that multiple
156 // registrars have the same namespace, this new registrar will be unable to 158 // registrars have the same namespace, this new registrar will be unable to
157 // install accelerators. 159 // install accelerators.
158 accelerator_registrar_count = 0; 160 accelerator_registrar_count = 0;
159 } 161 }
160 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( 162 accelerator_registrars_.insert(new AcceleratorRegistrarImpl(
161 window_tree_host_.get(), ++accelerator_registrar_count, request.Pass(), 163 window_tree_host_.get(), ++accelerator_registrar_count,
164 std::move(request),
162 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, 165 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed,
163 base::Unretained(this)))); 166 base::Unretained(this))));
164 } 167 }
165 168
166 void WindowManagerApplication::Create( 169 void WindowManagerApplication::Create(
167 mojo::ApplicationConnection* connection, 170 mojo::ApplicationConnection* connection,
168 mojo::InterfaceRequest<mus::mojom::WindowManager> request) { 171 mojo::InterfaceRequest<mus::mojom::WindowManager> request) {
169 if (root_) { 172 if (root_) {
170 window_manager_binding_.AddBinding(window_manager_.get(), request.Pass()); 173 window_manager_binding_.AddBinding(window_manager_.get(),
174 std::move(request));
171 } else { 175 } else {
172 requests_.push_back( 176 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>(
173 new mojo::InterfaceRequest<mus::mojom::WindowManager>(request.Pass())); 177 std::move(request)));
174 } 178 }
175 } 179 }
176 180
177 void WindowManagerApplication::OnWindowDestroyed(mus::Window* window) { 181 void WindowManagerApplication::OnWindowDestroyed(mus::Window* window) {
178 DCHECK_EQ(window, root_); 182 DCHECK_EQ(window, root_);
179 root_->RemoveObserver(this); 183 root_->RemoveObserver(this);
180 // Delete the |window_manager_| here so that WindowManager doesn't have to 184 // Delete the |window_manager_| here so that WindowManager doesn't have to
181 // worry about the possibility of |root_| being null. 185 // worry about the possibility of |root_| being null.
182 window_manager_.reset(); 186 window_manager_.reset();
183 root_ = nullptr; 187 root_ = nullptr;
184 } 188 }
185 189
186 void WindowManagerApplication::CreateContainers() { 190 void WindowManagerApplication::CreateContainers() {
187 for (uint16_t container = 191 for (uint16_t container =
188 static_cast<uint16_t>(mojom::CONTAINER_ALL_USER_BACKGROUND); 192 static_cast<uint16_t>(mojom::CONTAINER_ALL_USER_BACKGROUND);
189 container < static_cast<uint16_t>(mojom::CONTAINER_COUNT); ++container) { 193 container < static_cast<uint16_t>(mojom::CONTAINER_COUNT); ++container) {
190 mus::Window* window = root_->connection()->NewWindow(); 194 mus::Window* window = root_->connection()->NewWindow();
191 DCHECK_EQ(mus::LoWord(window->id()), container) 195 DCHECK_EQ(mus::LoWord(window->id()), container)
192 << "Containers must be created before other windows!"; 196 << "Containers must be created before other windows!";
193 window->SetBounds(root_->bounds()); 197 window->SetBounds(root_->bounds());
194 window->SetVisible(true); 198 window->SetVisible(true);
195 root_->AddChild(window); 199 root_->AddChild(window);
196 } 200 }
197 } 201 }
198 202
199 } // namespace wm 203 } // namespace wm
200 } // namespace mash 204 } // namespace mash
OLDNEW
« no previous file with comments | « mash/wm/accelerator_registrar_impl.cc ('k') | mash/wm/window_manager_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698