| 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/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  Loading... | 
| 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   // Primary monitor should never be removed by MonitorManager. | 
|  | 76   DCHECK(root != Shell::GetRootWindow()); | 
|  | 77   // Monitor for root window will be deleted when the Primary RootWindow | 
|  | 78   // is deleted by the Shell. | 
|  | 79   if (root != Shell::GetRootWindow()) { | 
|  | 80     root_windows_.erase(monitor); | 
|  | 81     delete root; | 
|  | 82   } | 
| 71 } | 83 } | 
| 72 | 84 | 
| 73 void MonitorController::Init() { | 85 void MonitorController::Init() { | 
| 74   aura::MonitorManager* monitor_manager = | 86   aura::MonitorManager* monitor_manager = | 
| 75       aura::Env::GetInstance()->monitor_manager(); | 87       aura::Env::GetInstance()->monitor_manager(); | 
| 76   for (size_t i = 0; i < monitor_manager->GetNumMonitors(); ++i) { | 88   for (size_t i = 0; i < monitor_manager->GetNumMonitors(); ++i) { | 
| 77     aura::Monitor* monitor = monitor_manager->GetMonitorAt(i); | 89     aura::Monitor* monitor = monitor_manager->GetMonitorAt(i); | 
| 78     const aura::Monitor* key = monitor; | 90     const aura::Monitor* key = monitor; | 
| 79     if (i == 0) { | 91     if (i == 0) { | 
| 80       // Primary monitor | 92       // Primary monitor | 
| 81       root_windows_[key] = Shell::GetRootWindow(); | 93       root_windows_[key] = Shell::GetRootWindow(); | 
| 82       Shell::GetRootWindow()->SetHostBounds(monitor->bounds()); | 94       Shell::GetRootWindow()->SetHostBounds(monitor->bounds()); | 
| 83     } else { | 95     } else { | 
| 84       aura::RootWindow* root = | 96       aura::RootWindow* root = | 
| 85           monitor_manager->CreateRootWindowForMonitor(monitor); | 97           monitor_manager->CreateRootWindowForMonitor(monitor); | 
| 86       root_windows_[key] = root; | 98       root_windows_[key] = root; | 
| 87       SetupAsSecondaryMonitor(root); | 99       SetupAsSecondaryMonitor(root); | 
| 88     } | 100     } | 
| 89   } | 101   } | 
| 90 } | 102 } | 
| 91 | 103 | 
| 92 }  // namespace internal | 104 }  // namespace internal | 
| 93 }  // namespace ash | 105 }  // namespace ash | 
| OLD | NEW | 
|---|