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

Side by Side Diff: ash/display/mirror_window_controller.cc

Issue 2840043003: chromeos: Makes mushrome use simplified display management (Closed)
Patch Set: merge 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 | « ash/aura/shell_port_classic.cc ('k') | ash/display/window_tree_host_manager.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ash/display/mirror_window_controller.h" 5 #include "ash/display/mirror_window_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #if defined(USE_X11) 9 #if defined(USE_X11)
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 transformer.reset(CreateRootWindowTransformerForUnifiedDesktop( 166 transformer.reset(CreateRootWindowTransformerForUnifiedDesktop(
167 primary.bounds(), display)); 167 primary.bounds(), display));
168 } else { 168 } else {
169 NOTREACHED(); 169 NOTREACHED();
170 } 170 }
171 171
172 if (mirroring_host_info_map_.find(display_info.id()) == 172 if (mirroring_host_info_map_.find(display_info.id()) ==
173 mirroring_host_info_map_.end()) { 173 mirroring_host_info_map_.end()) {
174 AshWindowTreeHostInitParams init_params; 174 AshWindowTreeHostInitParams init_params;
175 init_params.initial_bounds = display_info.bounds_in_native(); 175 init_params.initial_bounds = display_info.bounds_in_native();
176 init_params.display_id = display_info.id();
177 init_params.device_scale_factor = display_info.device_scale_factor();
178 init_params.ui_scale_factor = display_info.configured_ui_scale();
176 MirroringHostInfo* host_info = new MirroringHostInfo; 179 MirroringHostInfo* host_info = new MirroringHostInfo;
177 host_info->ash_host = AshWindowTreeHost::Create(init_params); 180 host_info->ash_host = AshWindowTreeHost::Create(init_params);
178 mirroring_host_info_map_[display_info.id()] = host_info; 181 mirroring_host_info_map_[display_info.id()] = host_info;
179 182
180 aura::WindowTreeHost* host = host_info->ash_host->AsWindowTreeHost(); 183 aura::WindowTreeHost* host = host_info->ash_host->AsWindowTreeHost();
181 host->SetSharedInputMethod( 184 // TODO: Config::MUS should not install an InputMethod.
182 Shell::Get()->window_tree_host_manager()->input_method()); 185 // http://crbug.com/706913
186 if (!host->has_input_method()) {
187 host->SetSharedInputMethod(
188 Shell::Get()->window_tree_host_manager()->input_method());
189 }
183 host->window()->SetName( 190 host->window()->SetName(
184 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); 191 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++));
185 host->compositor()->SetBackgroundColor(SK_ColorBLACK); 192 host->compositor()->SetBackgroundColor(SK_ColorBLACK);
186 // No need to remove the observer because the WindowTreeHostManager 193 // No need to remove the observer because the WindowTreeHostManager
187 // outlives the host. 194 // outlives the host.
188 host->AddObserver(Shell::Get()->window_tree_host_manager()); 195 host->AddObserver(Shell::Get()->window_tree_host_manager());
189 host->AddObserver(this); 196 host->AddObserver(this);
190 // TODO(oshima): TouchHUD is using idkey. 197 // TODO(oshima): TouchHUD is using idkey.
191 InitRootWindowSettings(host->window())->display_id = display_info.id(); 198 InitRootWindowSettings(host->window())->display_id = display_info.id();
192 host->InitHost(); 199 host->InitHost();
(...skipping 22 matching lines...) Expand all
215 222
216 aura::Window* mirror_window = host_info->mirror_window = 223 aura::Window* mirror_window = host_info->mirror_window =
217 new aura::Window(nullptr); 224 new aura::Window(nullptr);
218 mirror_window->Init(ui::LAYER_SOLID_COLOR); 225 mirror_window->Init(ui::LAYER_SOLID_COLOR);
219 host->window()->AddChild(mirror_window); 226 host->window()->AddChild(mirror_window);
220 host_info->ash_host->SetRootWindowTransformer(std::move(transformer)); 227 host_info->ash_host->SetRootWindowTransformer(std::move(transformer));
221 mirror_window->SetBounds(host->window()->bounds()); 228 mirror_window->SetBounds(host->window()->bounds());
222 mirror_window->Show(); 229 mirror_window->Show();
223 if (reflector_) { 230 if (reflector_) {
224 reflector_->AddMirroringLayer(mirror_window->layer()); 231 reflector_->AddMirroringLayer(mirror_window->layer());
225 } else { 232 } else if (aura::Env::GetInstance()->context_factory_private()) {
226 reflector_ = 233 reflector_ =
227 aura::Env::GetInstance() 234 aura::Env::GetInstance()
228 ->context_factory_private() 235 ->context_factory_private()
229 ->CreateReflector( 236 ->CreateReflector(
230 Shell::GetPrimaryRootWindow()->GetHost()->compositor(), 237 Shell::GetPrimaryRootWindow()->GetHost()->compositor(),
231 mirror_window->layer()); 238 mirror_window->layer());
239 } else {
240 // TODO: Config::MUS needs to support reflector.
241 // http://crbug.com/601869.
242 NOTIMPLEMENTED();
232 } 243 }
233 } else { 244 } else {
234 AshWindowTreeHost* ash_host = 245 AshWindowTreeHost* ash_host =
235 mirroring_host_info_map_[display_info.id()]->ash_host.get(); 246 mirroring_host_info_map_[display_info.id()]->ash_host.get();
236 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); 247 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
237 GetRootWindowSettings(host->window())->display_id = display_info.id(); 248 GetRootWindowSettings(host->window())->display_id = display_info.id();
238 ash_host->SetRootWindowTransformer(std::move(transformer)); 249 ash_host->SetRootWindowTransformer(std::move(transformer));
239 host->SetBoundsInPixels(display_info.bounds_in_native()); 250 host->SetBoundsInPixels(display_info.bounds_in_native());
240 } 251 }
241 } 252 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 298 }
288 } 299 }
289 300
290 void MirrorWindowController::OnHostResized(const aura::WindowTreeHost* host) { 301 void MirrorWindowController::OnHostResized(const aura::WindowTreeHost* host) {
291 for (auto& pair : mirroring_host_info_map_) { 302 for (auto& pair : mirroring_host_info_map_) {
292 MirroringHostInfo* info = pair.second; 303 MirroringHostInfo* info = pair.second;
293 if (info->ash_host->AsWindowTreeHost() == host) { 304 if (info->ash_host->AsWindowTreeHost() == host) {
294 if (info->mirror_window_host_size == host->GetBoundsInPixels().size()) 305 if (info->mirror_window_host_size == host->GetBoundsInPixels().size())
295 return; 306 return;
296 info->mirror_window_host_size = host->GetBoundsInPixels().size(); 307 info->mirror_window_host_size = host->GetBoundsInPixels().size();
297 reflector_->OnMirroringCompositorResized(); 308 // TODO: |reflector_| should always be non-null here, but isn't in MUS
309 // yet because of http://crbug.com/601869.
310 if (reflector_)
311 reflector_->OnMirroringCompositorResized();
298 // No need to update the transformer as new transformer is already set 312 // No need to update the transformer as new transformer is already set
299 // in UpdateWindow. 313 // in UpdateWindow.
300 Shell::Get() 314 Shell::Get()
301 ->window_tree_host_manager() 315 ->window_tree_host_manager()
302 ->cursor_window_controller() 316 ->cursor_window_controller()
303 ->UpdateLocation(); 317 ->UpdateLocation();
304 return; 318 return;
305 } 319 }
306 } 320 }
307 } 321 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 aura::client::SetScreenPositionClient(host->window(), nullptr); 369 aura::client::SetScreenPositionClient(host->window(), nullptr);
356 370
357 NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>( 371 NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>(
358 aura::client::GetCaptureClient(host->window())); 372 aura::client::GetCaptureClient(host->window()));
359 aura::client::SetCaptureClient(host->window(), nullptr); 373 aura::client::SetCaptureClient(host->window(), nullptr);
360 delete capture_client; 374 delete capture_client;
361 375
362 host->RemoveObserver(Shell::Get()->window_tree_host_manager()); 376 host->RemoveObserver(Shell::Get()->window_tree_host_manager());
363 host->RemoveObserver(this); 377 host->RemoveObserver(this);
364 host_info->ash_host->PrepareForShutdown(); 378 host_info->ash_host->PrepareForShutdown();
365 reflector_->RemoveMirroringLayer(host_info->mirror_window->layer()); 379 // TODO: |reflector_| should always be non-null here, but isn't in MUS yet
380 // because of http://crbug.com/601869.
381 if (reflector_)
382 reflector_->RemoveMirroringLayer(host_info->mirror_window->layer());
366 383
367 // EventProcessor may be accessed after this call if the mirroring window 384 // EventProcessor may be accessed after this call if the mirroring window
368 // was deleted as a result of input event (e.g. shortcut), so don't delete 385 // was deleted as a result of input event (e.g. shortcut), so don't delete
369 // now. 386 // now.
370 if (delay_host_deletion) 387 if (delay_host_deletion)
371 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); 388 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info);
372 else 389 else
373 delete host_info; 390 delete host_info;
374 } 391 }
375 392
376 } // namespace ash 393 } // namespace ash
OLDNEW
« no previous file with comments | « ash/aura/shell_port_classic.cc ('k') | ash/display/window_tree_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698