| 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/multi_monitor_manager.h" | 5 #include "ash/monitor/multi_monitor_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 const gfx::Display& display) { | 117 const gfx::Display& display) { |
| 118 RootWindow* root_window = new RootWindow(display.bounds_in_pixel()); | 118 RootWindow* root_window = new RootWindow(display.bounds_in_pixel()); |
| 119 // No need to remove RootWindowObserver because | 119 // No need to remove RootWindowObserver because |
| 120 // the MonitorManager object outlives RootWindow objects. | 120 // the MonitorManager object outlives RootWindow objects. |
| 121 root_window->AddRootWindowObserver(this); | 121 root_window->AddRootWindowObserver(this); |
| 122 root_window->SetProperty(kMonitorIdKey, display.id()); | 122 root_window->SetProperty(kMonitorIdKey, display.id()); |
| 123 root_window->Init(); | 123 root_window->Init(); |
| 124 return root_window; | 124 return root_window; |
| 125 } | 125 } |
| 126 | 126 |
| 127 const gfx::Display& MultiMonitorManager::GetDisplayAt(size_t index) { | 127 gfx::Display* MultiMonitorManager::GetDisplayAt(size_t index) { |
| 128 return index < displays_.size() ? displays_[index] : GetInvalidDisplay(); | 128 return index < displays_.size() ? &displays_[index] : NULL; |
| 129 } | 129 } |
| 130 | 130 |
| 131 size_t MultiMonitorManager::GetNumDisplays() const { | 131 size_t MultiMonitorManager::GetNumDisplays() const { |
| 132 return displays_.size(); | 132 return displays_.size(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 const gfx::Display& MultiMonitorManager::GetDisplayNearestWindow( | 135 const gfx::Display& MultiMonitorManager::GetDisplayNearestWindow( |
| 136 const Window* window) const { | 136 const Window* window) const { |
| 137 if (!window) { | 137 if (!window) { |
| 138 MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); | 138 MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); |
| 139 return manager->GetDisplayAt(0); | 139 return *manager->GetDisplayAt(0); |
| 140 } | 140 } |
| 141 const RootWindow* root = window->GetRootWindow(); | 141 const RootWindow* root = window->GetRootWindow(); |
| 142 MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); | 142 MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); |
| 143 return root ? manager->FindDisplayForRootWindow(root) : GetInvalidDisplay(); | 143 return root ? manager->FindDisplayForRootWindow(root) : GetInvalidDisplay(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 const gfx::Display& MultiMonitorManager::GetDisplayNearestPoint( | 146 const gfx::Display& MultiMonitorManager::GetDisplayNearestPoint( |
| 147 const gfx::Point& point) const { | 147 const gfx::Point& point) const { |
| 148 // TODO(oshima): For m19, mouse is constrained within | 148 // TODO(oshima): For m19, mouse is constrained within |
| 149 // the primary window. | 149 // the primary window. |
| 150 MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); | 150 MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); |
| 151 return manager->GetDisplayAt(0); | 151 return *manager->GetDisplayAt(0); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void MultiMonitorManager::OnRootWindowResized(const aura::RootWindow* root, | 154 void MultiMonitorManager::OnRootWindowResized(const aura::RootWindow* root, |
| 155 const gfx::Size& old_size) { | 155 const gfx::Size& old_size) { |
| 156 if (!use_fullscreen_host_window()) { | 156 if (!use_fullscreen_host_window()) { |
| 157 gfx::Display& display = FindDisplayForRootWindow(root); | 157 gfx::Display& display = FindDisplayForRootWindow(root); |
| 158 display.SetSize(root->GetHostSize()); | 158 display.SetSize(root->GetHostSize()); |
| 159 NotifyBoundsChanged(display); | 159 NotifyBoundsChanged(display); |
| 160 } | 160 } |
| 161 } | 161 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 iter != displays_.end(); ++iter) { | 238 iter != displays_.end(); ++iter) { |
| 239 if ((*iter).id() == id) | 239 if ((*iter).id() == id) |
| 240 return *iter; | 240 return *iter; |
| 241 } | 241 } |
| 242 DLOG(FATAL) << "Could not find display by id:" << id; | 242 DLOG(FATAL) << "Could not find display by id:" << id; |
| 243 return GetInvalidDisplay(); | 243 return GetInvalidDisplay(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace internal | 246 } // namespace internal |
| 247 } // namespace ash | 247 } // namespace ash |
| OLD | NEW |