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

Side by Side 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: cleanup 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/monitor/multi_monitor_manager.h » ('j') | ash/monitor/multi_monitor_manager.h » ('J')
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/monitor/monitor_controller.h" 5 #include "ash/monitor/monitor_controller.h"
6 6
7 #include "ash/monitor/multi_monitor_manager.h" 7 #include "ash/monitor/multi_monitor_manager.h"
8 #include "ash/monitor/secondary_monitor_view.h" 8 #include "ash/monitor/secondary_monitor_view.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/base_layout_manager.h" 10 #include "ash/wm/base_layout_manager.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 root_windows_.erase(monitor); 51 root_windows_.erase(monitor);
52 STLDeleteContainerPairSecondPointers( 52 STLDeleteContainerPairSecondPointers(
53 root_windows_.begin(), root_windows_.end()); 53 root_windows_.begin(), root_windows_.end());
54 } 54 }
55 55
56 void MonitorController::OnMonitorBoundsChanged(const aura::Monitor* monitor) { 56 void MonitorController::OnMonitorBoundsChanged(const aura::Monitor* monitor) {
57 root_windows_[monitor]->SetHostBounds(monitor->bounds()); 57 root_windows_[monitor]->SetHostBounds(monitor->bounds());
58 } 58 }
59 59
60 void MonitorController::OnMonitorAdded(aura::Monitor* monitor) { 60 void MonitorController::OnMonitorAdded(aura::Monitor* monitor) {
61 if (root_windows_.empty()) {
62 root_windows_[monitor] = Shell::GetRootWindow();
63 Shell::GetRootWindow()->SetHostBounds(monitor->bounds());
64 return;
65 }
61 aura::RootWindow* root = aura::Env::GetInstance()->monitor_manager()-> 66 aura::RootWindow* root = aura::Env::GetInstance()->monitor_manager()->
62 CreateRootWindowForMonitor(monitor); 67 CreateRootWindowForMonitor(monitor);
63 root_windows_[monitor] = root; 68 root_windows_[monitor] = root;
64 SetupAsSecondaryMonitor(root); 69 SetupAsSecondaryMonitor(root);
65 } 70 }
66 71
67 void MonitorController::OnMonitorRemoved(const aura::Monitor* monitor) { 72 void MonitorController::OnMonitorRemoved(const aura::Monitor* monitor) {
68 aura::RootWindow* root = root_windows_[monitor]; 73 aura::RootWindow* root = root_windows_[monitor];
69 root_windows_.erase(monitor); 74 DCHECK(root);
70 delete root; 75 // Monitor for root window will be deleted when the Primary RootWindow
76 // is deleted by the Shell.
77 if (root != Shell::GetRootWindow()) {
78 root_windows_.erase(monitor);
79 delete root;
80 }
71 } 81 }
72 82
73 void MonitorController::Init() { 83 void MonitorController::Init() {
74 aura::MonitorManager* monitor_manager = 84 aura::MonitorManager* monitor_manager =
75 aura::Env::GetInstance()->monitor_manager(); 85 aura::Env::GetInstance()->monitor_manager();
76 for (size_t i = 0; i < monitor_manager->GetNumMonitors(); ++i) { 86 for (size_t i = 0; i < monitor_manager->GetNumMonitors(); ++i) {
77 aura::Monitor* monitor = monitor_manager->GetMonitorAt(i); 87 aura::Monitor* monitor = monitor_manager->GetMonitorAt(i);
78 const aura::Monitor* key = monitor; 88 const aura::Monitor* key = monitor;
79 if (i == 0) { 89 if (i == 0) {
80 // Primary monitor 90 // Primary monitor
81 root_windows_[key] = Shell::GetRootWindow(); 91 root_windows_[key] = Shell::GetRootWindow();
82 Shell::GetRootWindow()->SetHostBounds(monitor->bounds()); 92 Shell::GetRootWindow()->SetHostBounds(monitor->bounds());
83 } else { 93 } else {
84 aura::RootWindow* root = 94 aura::RootWindow* root =
85 monitor_manager->CreateRootWindowForMonitor(monitor); 95 monitor_manager->CreateRootWindowForMonitor(monitor);
86 root_windows_[key] = root; 96 root_windows_[key] = root;
87 SetupAsSecondaryMonitor(root); 97 SetupAsSecondaryMonitor(root);
88 } 98 }
89 } 99 }
90 } 100 }
91 101
92 } // namespace internal 102 } // namespace internal
93 } // namespace ash 103 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/monitor/multi_monitor_manager.h » ('j') | ash/monitor/multi_monitor_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698