OLD | NEW |
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/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 const gfx::Insets& insets) { | 633 const gfx::Insets& insets) { |
634 const aura::Window* root_window = window->GetRootWindow(); | 634 const aura::Window* root_window = window->GetRootWindow(); |
635 int64 id = GetRootWindowSettings(root_window)->display_id; | 635 int64 id = GetRootWindowSettings(root_window)->display_id; |
636 // if id is |kInvaildDisplayID|, it's being deleted. | 636 // if id is |kInvaildDisplayID|, it's being deleted. |
637 DCHECK(id != gfx::Display::kInvalidDisplayID); | 637 DCHECK(id != gfx::Display::kInvalidDisplayID); |
638 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); | 638 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); |
639 } | 639 } |
640 | 640 |
641 void DisplayController::OnDisplayAdded(const gfx::Display& display) { | 641 void DisplayController::OnDisplayAdded(const gfx::Display& display) { |
642 #if defined(OS_CHROMEOS) | 642 #if defined(OS_CHROMEOS) |
643 if (GetDisplayManager()->default_multi_display_mode() == | 643 // If we're switching from/to offscreen WTH, we need to |
644 DisplayManager::UNIFIED) { | 644 // create new WTH for primary display instead of reusing. |
645 if (primary_display_id == gfx::Display::kInvalidDisplayID) | 645 if (primary_tree_host_for_replace_ && |
646 primary_display_id = display.id(); | 646 (GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) |
| 647 ->display_id == DisplayManager::kUnifiedDisplayId || |
| 648 display.id() == DisplayManager::kUnifiedDisplayId)) { |
| 649 DCHECK_EQ(gfx::Display::kInvalidDisplayID, primary_display_id); |
| 650 primary_display_id = display.id(); |
| 651 |
647 AshWindowTreeHost* ash_host = | 652 AshWindowTreeHost* ash_host = |
648 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); | 653 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); |
649 RootWindowController::CreateForSecondaryDisplay(ash_host); | 654 RootWindowController::CreateForSecondaryDisplay(ash_host); |
650 | 655 |
651 // Magnifier controllers keep pointers to the current root window. | 656 // Magnifier controllers keep pointers to the current root window. |
652 // Update them here to avoid accessing them later. | 657 // Update them here to avoid accessing them later. |
653 Shell::GetInstance()->magnification_controller()->SwitchTargetRootWindow( | 658 Shell::GetInstance()->magnification_controller()->SwitchTargetRootWindow( |
654 ash_host->AsWindowTreeHost()->window(), false); | 659 ash_host->AsWindowTreeHost()->window(), false); |
655 Shell::GetInstance() | 660 Shell::GetInstance() |
656 ->partial_magnification_controller() | 661 ->partial_magnification_controller() |
657 ->SwitchTargetRootWindow(ash_host->AsWindowTreeHost()->window()); | 662 ->SwitchTargetRootWindow(ash_host->AsWindowTreeHost()->window()); |
658 | 663 |
659 if (primary_tree_host_for_replace_) { | 664 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_; |
660 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_; | 665 primary_tree_host_for_replace_ = nullptr; |
661 primary_tree_host_for_replace_ = nullptr; | |
662 | 666 |
663 // Show the shelf if the original WTH had a visible system | 667 // Show the shelf if the original WTH had a visible system |
664 // tray. It may or may not be visible depending on OOBE state. | 668 // tray. It may or may not be visible depending on OOBE state. |
665 ash::SystemTray* old_tray = | 669 ash::SystemTray* old_tray = |
666 GetRootWindowController(to_delete->AsWindowTreeHost()->window()) | 670 GetRootWindowController(to_delete->AsWindowTreeHost()->window()) |
667 ->GetSystemTray(); | 671 ->GetSystemTray(); |
668 ash::SystemTray* new_tray = | 672 ash::SystemTray* new_tray = |
669 ash::Shell::GetInstance()->GetPrimarySystemTray(); | 673 ash::Shell::GetInstance()->GetPrimarySystemTray(); |
670 if (old_tray->GetWidget()->IsVisible()) { | 674 if (old_tray->GetWidget()->IsVisible()) { |
671 new_tray->SetVisible(true); | 675 new_tray->SetVisible(true); |
672 new_tray->GetWidget()->Show(); | 676 new_tray->GetWidget()->Show(); |
673 } | 677 } |
674 | 678 |
675 DeleteHost(to_delete); | 679 DeleteHost(to_delete); |
676 #ifndef NDEBUG | 680 #ifndef NDEBUG |
677 auto iter = std::find_if( | 681 auto iter = std::find_if( |
678 window_tree_hosts_.begin(), window_tree_hosts_.end(), | 682 window_tree_hosts_.begin(), window_tree_hosts_.end(), |
679 [to_delete](const std::pair<int64, AshWindowTreeHost*>& pair) { | 683 [to_delete](const std::pair<int64, AshWindowTreeHost*>& pair) { |
680 return pair.second == to_delete; | 684 return pair.second == to_delete; |
681 }); | 685 }); |
682 DCHECK(iter == window_tree_hosts_.end()); | 686 DCHECK(iter == window_tree_hosts_.end()); |
683 #endif | 687 #endif |
684 // the host has already been removed from the window_tree_host_. | 688 // the host has already been removed from the window_tree_host_. |
685 } | |
686 } else | 689 } else |
687 #endif | 690 #endif |
688 // TODO(oshima): It should be possible to consolidate logic for | 691 // TODO(oshima): It should be possible to consolidate logic for |
689 // unified and non unified, but I'm keeping them separated to minimize | 692 // unified and non unified, but I'm keeping them separated to minimize |
690 // the risk in M44. I'll consolidate this in M45. | 693 // the risk in M44. I'll consolidate this in M45. |
691 if (primary_tree_host_for_replace_) { | 694 if (primary_tree_host_for_replace_) { |
692 DCHECK(window_tree_hosts_.empty()); | 695 DCHECK(window_tree_hosts_.empty()); |
693 primary_display_id = display.id(); | 696 primary_display_id = display.id(); |
694 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_; | 697 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_; |
695 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) | 698 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 Shell::GetInstance()->display_configurator_animation() | 905 Shell::GetInstance()->display_configurator_animation() |
903 ->StartFadeInAnimation(); | 906 ->StartFadeInAnimation(); |
904 #endif | 907 #endif |
905 } | 908 } |
906 | 909 |
907 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { | 910 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { |
908 GetDisplayManager()->SetMirrorMode(mirror); | 911 GetDisplayManager()->SetMirrorMode(mirror); |
909 } | 912 } |
910 | 913 |
911 } // namespace ash | 914 } // namespace ash |
OLD | NEW |