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

Unified Diff: ash/monitor/monitor_controller.cc

Issue 9835068: Don't delete Primary root window and monitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 9 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/monitor/multi_monitor_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/monitor/monitor_controller.cc
diff --git a/ash/monitor/monitor_controller.cc b/ash/monitor/monitor_controller.cc
index 397e5abb1f65f2414046aac49b6392d892909922..3ebfea4877601869e060c759a113a21eda047e24 100644
--- a/ash/monitor/monitor_controller.cc
+++ b/ash/monitor/monitor_controller.cc
@@ -58,6 +58,11 @@ void MonitorController::OnMonitorBoundsChanged(const aura::Monitor* monitor) {
}
void MonitorController::OnMonitorAdded(aura::Monitor* monitor) {
+ if (root_windows_.empty()) {
+ root_windows_[monitor] = Shell::GetRootWindow();
+ Shell::GetRootWindow()->SetHostBounds(monitor->bounds());
+ return;
+ }
aura::RootWindow* root = aura::Env::GetInstance()->monitor_manager()->
CreateRootWindowForMonitor(monitor);
root_windows_[monitor] = root;
@@ -66,8 +71,15 @@ void MonitorController::OnMonitorAdded(aura::Monitor* monitor) {
void MonitorController::OnMonitorRemoved(const aura::Monitor* monitor) {
aura::RootWindow* root = root_windows_[monitor];
- root_windows_.erase(monitor);
- delete root;
+ DCHECK(root);
+ // Primary monitor should never be removed by MonitorManager.
+ DCHECK(root != Shell::GetRootWindow());
+ // Monitor for root window will be deleted when the Primary RootWindow
+ // is deleted by the Shell.
+ if (root != Shell::GetRootWindow()) {
+ root_windows_.erase(monitor);
+ delete root;
+ }
}
void MonitorController::Init() {
« no previous file with comments | « no previous file | ash/monitor/multi_monitor_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698