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::GetMonitorAt(size_t index) { | 127 const gfx::Display& MultiMonitorManager::GetDisplayAt(size_t index) { |
128 return index < displays_.size() ? displays_[index] : GetInvalidDisplay(); | 128 return index < displays_.size() ? displays_[index] : GetInvalidDisplay(); |
129 } | 129 } |
130 | 130 |
131 size_t MultiMonitorManager::GetNumMonitors() const { | 131 size_t MultiMonitorManager::GetNumDisplays() const { |
132 return displays_.size(); | 132 return displays_.size(); |
133 } | 133 } |
134 | 134 |
135 const gfx::Display& MultiMonitorManager::GetMonitorNearestWindow( | 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->GetMonitorAt(0); | 139 return manager->GetDisplayAt(0); |
140 } | 140 } |
141 const RootWindow* root = window->GetRootWindow(); | 141 const RootWindow* root = window->GetRootWindow(); |
142 MultiMonitorManager* that = const_cast<MultiMonitorManager*>(this); | 142 MultiMonitorManager* that = const_cast<MultiMonitorManager*>(this); |
143 return root ? | 143 return root ? |
144 that->FindDisplayById(root->GetProperty(kMonitorIdKey)) : | 144 that->FindDisplayById(root->GetProperty(kMonitorIdKey)) : |
145 GetInvalidDisplay(); | 145 GetInvalidDisplay(); |
146 } | 146 } |
147 | 147 |
148 const gfx::Display& MultiMonitorManager::GetMonitorNearestPoint( | 148 const gfx::Display& MultiMonitorManager::GetDisplayNearestPoint( |
149 const gfx::Point& point) const { | 149 const gfx::Point& point) const { |
150 // TODO(oshima): For m19, mouse is constrained within | 150 // TODO(oshima): For m19, mouse is constrained within |
151 // the primary window. | 151 // the primary window. |
152 MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); | 152 MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); |
153 return manager->GetMonitorAt(0); | 153 return manager->GetDisplayAt(0); |
154 } | 154 } |
155 | 155 |
156 void MultiMonitorManager::OnRootWindowResized(const aura::RootWindow* root, | 156 void MultiMonitorManager::OnRootWindowResized(const aura::RootWindow* root, |
157 const gfx::Size& old_size) { | 157 const gfx::Size& old_size) { |
158 if (!use_fullscreen_host_window()) { | 158 if (!use_fullscreen_host_window()) { |
159 int monitor_id = root->GetProperty(kMonitorIdKey); | 159 int monitor_id = root->GetProperty(kMonitorIdKey); |
160 gfx::Display& display = FindDisplayById(monitor_id); | 160 gfx::Display& display = FindDisplayById(monitor_id); |
161 display.SetSize(root->GetHostSize()); | 161 display.SetSize(root->GetHostSize()); |
162 NotifyBoundsChanged(display); | 162 NotifyBoundsChanged(display); |
163 } | 163 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 iter != displays_.end(); ++iter) { | 239 iter != displays_.end(); ++iter) { |
240 if ((*iter).id() == id) | 240 if ((*iter).id() == id) |
241 return *iter; | 241 return *iter; |
242 } | 242 } |
243 DLOG(FATAL) << "Could not find display by id:" << id; | 243 DLOG(FATAL) << "Could not find display by id:" << id; |
244 return GetInvalidDisplay(); | 244 return GetInvalidDisplay(); |
245 } | 245 } |
246 | 246 |
247 } // namespace internal | 247 } // namespace internal |
248 } // namespace ash | 248 } // namespace ash |
OLD | NEW |