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

Unified Diff: ash/display/display_controller.cc

Issue 1126933004: Allow switching between extended and unified (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/display/display_manager.h » ('j') | ash/display/display_manager.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_controller.cc
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index ec9e478c0c3b87d2a56e645b17afbca941459bd4..c9d82a3c6944f0eb6d9050c00ea8bc0022726243 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -640,10 +640,15 @@ bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
void DisplayController::OnDisplayAdded(const gfx::Display& display) {
#if defined(OS_CHROMEOS)
- if (GetDisplayManager()->default_multi_display_mode() ==
- DisplayManager::UNIFIED) {
- if (primary_display_id == gfx::Display::kInvalidDisplayID)
- primary_display_id = display.id();
+ // If we're switching from/to offscreen WTH, we need to
+ // create new WTH for primary display instead of reusing.
+ if (primary_tree_host_for_replace_ &&
+ (GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_))
+ ->display_id == DisplayManager::kUnifiedDisplayId ||
+ display.id() == DisplayManager::kUnifiedDisplayId)) {
+ DCHECK_EQ(gfx::Display::kInvalidDisplayID, primary_display_id);
+ primary_display_id = display.id();
+
AshWindowTreeHost* ash_host =
AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams());
RootWindowController::CreateForSecondaryDisplay(ash_host);
@@ -656,33 +661,31 @@ void DisplayController::OnDisplayAdded(const gfx::Display& display) {
->partial_magnification_controller()
->SwitchTargetRootWindow(ash_host->AsWindowTreeHost()->window());
- if (primary_tree_host_for_replace_) {
- AshWindowTreeHost* to_delete = primary_tree_host_for_replace_;
- primary_tree_host_for_replace_ = nullptr;
-
- // Show the shelf if the original WTH had a visible system
- // tray. It may or may not be visible depending on OOBE state.
- ash::SystemTray* old_tray =
- GetRootWindowController(to_delete->AsWindowTreeHost()->window())
- ->GetSystemTray();
- ash::SystemTray* new_tray =
- ash::Shell::GetInstance()->GetPrimarySystemTray();
- if (old_tray->GetWidget()->IsVisible()) {
- new_tray->SetVisible(true);
- new_tray->GetWidget()->Show();
- }
+ AshWindowTreeHost* to_delete = primary_tree_host_for_replace_;
+ primary_tree_host_for_replace_ = nullptr;
+
+ // Show the shelf if the original WTH had a visible system
+ // tray. It may or may not be visible depending on OOBE state.
+ ash::SystemTray* old_tray =
+ GetRootWindowController(to_delete->AsWindowTreeHost()->window())
+ ->GetSystemTray();
+ ash::SystemTray* new_tray =
+ ash::Shell::GetInstance()->GetPrimarySystemTray();
+ if (old_tray->GetWidget()->IsVisible()) {
+ new_tray->SetVisible(true);
+ new_tray->GetWidget()->Show();
+ }
- DeleteHost(to_delete);
+ DeleteHost(to_delete);
#ifndef NDEBUG
- auto iter = std::find_if(
- window_tree_hosts_.begin(), window_tree_hosts_.end(),
- [to_delete](const std::pair<int64, AshWindowTreeHost*>& pair) {
- return pair.second == to_delete;
- });
- DCHECK(iter == window_tree_hosts_.end());
+ auto iter = std::find_if(
+ window_tree_hosts_.begin(), window_tree_hosts_.end(),
+ [to_delete](const std::pair<int64, AshWindowTreeHost*>& pair) {
+ return pair.second == to_delete;
+ });
+ DCHECK(iter == window_tree_hosts_.end());
#endif
- // the host has already been removed from the window_tree_host_.
- }
+ // the host has already been removed from the window_tree_host_.
} else
#endif
// TODO(oshima): It should be possible to consolidate logic for
« no previous file with comments | « no previous file | ash/display/display_manager.h » ('j') | ash/display/display_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698