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

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

Issue 2911393002: Nix GetRootWindowController, use RootWindowController::ForWindow. (Closed)
Patch Set: Sync and rebase. Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/window_tree_host_manager.h" 5 #include "ash/display/window_tree_host_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 266 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
267 267
268 // Delete non primary root window controllers first, then 268 // Delete non primary root window controllers first, then
269 // delete the primary root window controller. 269 // delete the primary root window controller.
270 aura::Window::Windows root_windows = 270 aura::Window::Windows root_windows =
271 WindowTreeHostManager::GetAllRootWindows(); 271 WindowTreeHostManager::GetAllRootWindows();
272 std::vector<RootWindowController*> to_delete; 272 std::vector<RootWindowController*> to_delete;
273 RootWindowController* primary_rwc = nullptr; 273 RootWindowController* primary_rwc = nullptr;
274 for (aura::Window::Windows::iterator iter = root_windows.begin(); 274 for (aura::Window::Windows::iterator iter = root_windows.begin();
275 iter != root_windows.end(); ++iter) { 275 iter != root_windows.end(); ++iter) {
276 RootWindowController* rwc = GetRootWindowController(*iter); 276 RootWindowController* rwc = RootWindowController::ForWindow(*iter);
277 if (GetRootWindowSettings(*iter)->display_id == primary_id) 277 if (GetRootWindowSettings(*iter)->display_id == primary_id)
278 primary_rwc = rwc; 278 primary_rwc = rwc;
279 else 279 else
280 to_delete.push_back(rwc); 280 to_delete.push_back(rwc);
281 } 281 }
282 CHECK(primary_rwc); 282 CHECK(primary_rwc);
283 283
284 for (auto* rwc : to_delete) 284 for (auto* rwc : to_delete)
285 delete rwc; 285 delete rwc;
286 delete primary_rwc; 286 delete primary_rwc;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 int64_t display_id) { 343 int64_t display_id) {
344 const auto host = window_tree_hosts_.find(display_id); 344 const auto host = window_tree_hosts_.find(display_id);
345 return host == window_tree_hosts_.end() ? nullptr : host->second; 345 return host == window_tree_hosts_.end() ? nullptr : host->second;
346 } 346 }
347 347
348 aura::Window::Windows WindowTreeHostManager::GetAllRootWindows() { 348 aura::Window::Windows WindowTreeHostManager::GetAllRootWindows() {
349 aura::Window::Windows windows; 349 aura::Window::Windows windows;
350 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); 350 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin();
351 it != window_tree_hosts_.end(); ++it) { 351 it != window_tree_hosts_.end(); ++it) {
352 DCHECK(it->second); 352 DCHECK(it->second);
353 if (GetRootWindowController(GetWindow(it->second))) 353 if (RootWindowController::ForWindow(GetWindow(it->second)))
354 windows.push_back(GetWindow(it->second)); 354 windows.push_back(GetWindow(it->second));
355 } 355 }
356 return windows; 356 return windows;
357 } 357 }
358 358
359 gfx::Insets WindowTreeHostManager::GetOverscanInsets(int64_t display_id) const { 359 gfx::Insets WindowTreeHostManager::GetOverscanInsets(int64_t display_id) const {
360 return GetDisplayManager()->GetOverscanInsets(display_id); 360 return GetDisplayManager()->GetOverscanInsets(display_id);
361 } 361 }
362 362
363 void WindowTreeHostManager::SetOverscanInsets( 363 void WindowTreeHostManager::SetOverscanInsets(
364 int64_t display_id, 364 int64_t display_id,
365 const gfx::Insets& insets_in_dip) { 365 const gfx::Insets& insets_in_dip) {
366 GetDisplayManager()->SetOverscanInsets(display_id, insets_in_dip); 366 GetDisplayManager()->SetOverscanInsets(display_id, insets_in_dip);
367 } 367 }
368 368
369 std::vector<RootWindowController*> 369 std::vector<RootWindowController*>
370 WindowTreeHostManager::GetAllRootWindowControllers() { 370 WindowTreeHostManager::GetAllRootWindowControllers() {
371 std::vector<RootWindowController*> controllers; 371 std::vector<RootWindowController*> controllers;
372 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); 372 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin();
373 it != window_tree_hosts_.end(); ++it) { 373 it != window_tree_hosts_.end(); ++it) {
374 RootWindowController* controller = 374 RootWindowController* controller =
375 GetRootWindowController(GetWindow(it->second)); 375 RootWindowController::ForWindow(GetWindow(it->second));
376 if (controller) 376 if (controller)
377 controllers.push_back(controller); 377 controllers.push_back(controller);
378 } 378 }
379 return controllers; 379 return controllers;
380 } 380 }
381 381
382 void WindowTreeHostManager::SetPrimaryDisplayId(int64_t id) { 382 void WindowTreeHostManager::SetPrimaryDisplayId(int64_t id) {
383 // TODO(oshima): Move primary display management to DisplayManager. 383 // TODO(oshima): Move primary display management to DisplayManager.
384 DCHECK_NE(display::kInvalidDisplayId, id); 384 DCHECK_NE(display::kInvalidDisplayId, id);
385 if (id == display::kInvalidDisplayId || primary_display_id == id || 385 if (id == display::kInvalidDisplayId || primary_display_id == id ||
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 ->partial_magnification_controller() 576 ->partial_magnification_controller()
577 ->SwitchTargetRootWindowIfNeeded( 577 ->SwitchTargetRootWindowIfNeeded(
578 ash_host->AsWindowTreeHost()->window()); 578 ash_host->AsWindowTreeHost()->window());
579 579
580 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_; 580 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_;
581 primary_tree_host_for_replace_ = nullptr; 581 primary_tree_host_for_replace_ = nullptr;
582 582
583 // Show the shelf if the original WTH had a visible system 583 // Show the shelf if the original WTH had a visible system
584 // tray. It may or may not be visible depending on OOBE state. 584 // tray. It may or may not be visible depending on OOBE state.
585 ash::SystemTray* old_tray = 585 ash::SystemTray* old_tray =
586 GetRootWindowController(to_delete->AsWindowTreeHost()->window()) 586 RootWindowController::ForWindow(to_delete->AsWindowTreeHost()->window())
587 ->GetSystemTray(); 587 ->GetSystemTray();
588 ash::SystemTray* new_tray = ash::Shell::Get()->GetPrimarySystemTray(); 588 ash::SystemTray* new_tray = ash::Shell::Get()->GetPrimarySystemTray();
589 if (old_tray->GetWidget()->IsVisible()) { 589 if (old_tray->GetWidget()->IsVisible()) {
590 new_tray->SetVisible(true); 590 new_tray->SetVisible(true);
591 new_tray->GetWidget()->Show(); 591 new_tray->GetWidget()->Show();
592 } 592 }
593 593
594 DeleteHost(to_delete); 594 DeleteHost(to_delete);
595 #ifndef NDEBUG 595 #ifndef NDEBUG
596 auto iter = std::find_if( 596 auto iter = std::find_if(
(...skipping 26 matching lines...) Expand all
623 DCHECK(!window_tree_hosts_.empty()); 623 DCHECK(!window_tree_hosts_.empty());
624 AshWindowTreeHost* ash_host = 624 AshWindowTreeHost* ash_host =
625 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); 625 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams());
626 RootWindowController::CreateForSecondaryDisplay(ash_host); 626 RootWindowController::CreateForSecondaryDisplay(ash_host);
627 } 627 }
628 } 628 }
629 629
630 void WindowTreeHostManager::DeleteHost(AshWindowTreeHost* host_to_delete) { 630 void WindowTreeHostManager::DeleteHost(AshWindowTreeHost* host_to_delete) {
631 ClearDisplayPropertiesOnHost(host_to_delete); 631 ClearDisplayPropertiesOnHost(host_to_delete);
632 RootWindowController* controller = 632 RootWindowController* controller =
633 GetRootWindowController(GetWindow(host_to_delete)); 633 RootWindowController::ForWindow(GetWindow(host_to_delete));
634 DCHECK(controller); 634 DCHECK(controller);
635 controller->MoveWindowsTo(GetPrimaryRootWindow()); 635 controller->MoveWindowsTo(GetPrimaryRootWindow());
636 // Delete most of root window related objects, but don't delete 636 // Delete most of root window related objects, but don't delete
637 // root window itself yet because the stack may be using it. 637 // root window itself yet because the stack may be using it.
638 controller->Shutdown(); 638 controller->Shutdown();
639 if (primary_tree_host_for_replace_ == host_to_delete) 639 if (primary_tree_host_for_replace_ == host_to_delete)
640 primary_tree_host_for_replace_ = nullptr; 640 primary_tree_host_for_replace_ = nullptr;
641 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, controller); 641 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, controller);
642 } 642 }
643 643
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 857
858 window_tree_hosts_[display.id()] = ash_host; 858 window_tree_hosts_[display.id()] = ash_host;
859 SetDisplayPropertiesOnHost(ash_host, display); 859 SetDisplayPropertiesOnHost(ash_host, display);
860 860
861 if (switches::ConstrainPointerToRoot()) 861 if (switches::ConstrainPointerToRoot())
862 ash_host->ConfineCursorToRootWindow(); 862 ash_host->ConfineCursorToRootWindow();
863 return ash_host; 863 return ash_host;
864 } 864 }
865 865
866 } // namespace ash 866 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698