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

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

Issue 1150913002: Save and restore unified mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix leak 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 unified diff | Download patch
« no previous file with comments | « ash/display/display_layout_store.cc ('k') | ash/display/display_manager_unittest.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) 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_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 default_multi_display_mode_(EXTENDED), 133 default_multi_display_mode_(EXTENDED),
134 mirroring_display_id_(gfx::Display::kInvalidDisplayID), 134 mirroring_display_id_(gfx::Display::kInvalidDisplayID),
135 registered_internal_display_rotation_lock_(false), 135 registered_internal_display_rotation_lock_(false),
136 registered_internal_display_rotation_(gfx::Display::ROTATE_0), 136 registered_internal_display_rotation_(gfx::Display::ROTATE_0),
137 weak_ptr_factory_(this) { 137 weak_ptr_factory_(this) {
138 #if defined(OS_CHROMEOS) 138 #if defined(OS_CHROMEOS)
139 // Enable only on the device so that DisplayManagerFontTest passes. 139 // Enable only on the device so that DisplayManagerFontTest passes.
140 if (base::SysInfo::IsRunningOnChromeOS()) 140 if (base::SysInfo::IsRunningOnChromeOS())
141 DisplayInfo::SetUse125DSFForUIScaling(true); 141 DisplayInfo::SetUse125DSFForUIScaling(true);
142 142
143 if (switches::UnifiedDesktopEnabled())
144 default_multi_display_mode_ = UNIFIED;
145
146 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); 143 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS();
147 #endif 144 #endif
148 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_.get()); 145 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_.get());
149 gfx::Screen* current_native = 146 gfx::Screen* current_native =
150 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); 147 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
151 // If there is no native, or the native was for shutdown, 148 // If there is no native, or the native was for shutdown,
152 // use ash's screen. 149 // use ash's screen.
153 if (!current_native || 150 if (!current_native ||
154 current_native == screen_for_shutdown) { 151 current_native == screen_for_shutdown) {
155 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); 152 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 DisplayModeMatcher(new_mode)); 631 DisplayModeMatcher(new_mode));
635 // Update the actual resolution selected as the resolution request may fail. 632 // Update the actual resolution selected as the resolution request may fail.
636 if (display_modes_iter == display_modes.end()) 633 if (display_modes_iter == display_modes.end())
637 display_modes_.erase(iter->id()); 634 display_modes_.erase(iter->id());
638 else if (display_modes_.find(iter->id()) != display_modes_.end()) 635 else if (display_modes_.find(iter->id()) != display_modes_.end())
639 display_modes_[iter->id()] = *display_modes_iter; 636 display_modes_[iter->id()] = *display_modes_iter;
640 } 637 }
641 if (gfx::Display::HasInternalDisplay() && !internal_display_connected && 638 if (gfx::Display::HasInternalDisplay() && !internal_display_connected &&
642 display_info_.find(gfx::Display::InternalDisplayId()) == 639 display_info_.find(gfx::Display::InternalDisplayId()) ==
643 display_info_.end()) { 640 display_info_.end()) {
641 // Create a dummy internal display if the chrome restarted
642 // in docked mode.
644 DisplayInfo internal_display_info( 643 DisplayInfo internal_display_info(
645 gfx::Display::InternalDisplayId(), 644 gfx::Display::InternalDisplayId(),
646 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME), 645 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME),
647 false /*Internal display must not have overscan */); 646 false /*Internal display must not have overscan */);
648 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600)); 647 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600));
649 display_info_[gfx::Display::InternalDisplayId()] = internal_display_info; 648 display_info_[gfx::Display::InternalDisplayId()] = internal_display_info;
650 } 649 }
650
651 #if defined(OS_CHROMEOS)
652 if (new_display_info_list.size() > 1) {
653 std::sort(new_display_info_list.begin(), new_display_info_list.end(),
654 DisplayInfoSortFunctor());
655 DisplayIdPair pair = std::make_pair(new_display_info_list[0].id(),
656 new_display_info_list[1].id());
657 DisplayLayout layout = layout_store_->GetRegisteredDisplayLayout(pair);
658 default_multi_display_mode_ =
659 (layout.default_unified && switches::UnifiedDesktopEnabled())
660 ? UNIFIED
661 : EXTENDED;
662 // Mirror mode is set by DisplayConfigurator on the device.
663 // Emulate it when running on linux desktop.
664 if (!base::SysInfo::IsRunningOnChromeOS() && layout.mirrored)
665 SetMultiDisplayMode(MIRRORING);
666 }
667 #endif
668
651 UpdateDisplays(new_display_info_list); 669 UpdateDisplays(new_display_info_list);
652 } 670 }
653 671
654 void DisplayManager::UpdateDisplays() { 672 void DisplayManager::UpdateDisplays() {
655 DisplayInfoList display_info_list; 673 DisplayInfoList display_info_list;
656 for (const auto& display : active_display_list_) 674 for (const auto& display : active_display_list_)
657 display_info_list.push_back(GetDisplayInfo(display.id())); 675 display_info_list.push_back(GetDisplayInfo(display.id()));
658 AddMirrorDisplayInfoIfAny(&display_info_list); 676 AddMirrorDisplayInfoIfAny(&display_info_list);
659 UpdateDisplays(display_info_list); 677 UpdateDisplays(display_info_list);
660 } 678 }
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1351 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1334 secondary_display->UpdateWorkAreaFromInsets(insets); 1352 secondary_display->UpdateWorkAreaFromInsets(insets);
1335 } 1353 }
1336 1354
1337 void DisplayManager::RunPendingTasksForTest() { 1355 void DisplayManager::RunPendingTasksForTest() {
1338 if (!software_mirroring_display_list_.empty()) 1356 if (!software_mirroring_display_list_.empty())
1339 base::RunLoop().RunUntilIdle(); 1357 base::RunLoop().RunUntilIdle();
1340 } 1358 }
1341 1359
1342 } // namespace ash 1360 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_layout_store.cc ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698