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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 aura::Env::GetInstance()->monitor_manager()); | 50 aura::Env::GetInstance()->monitor_manager()); |
51 manager->AddRemoveMonitorImpl(); | 51 manager->AddRemoveMonitorImpl(); |
52 } | 52 } |
53 | 53 |
54 void MultiMonitorManager::CycleMonitor() { | 54 void MultiMonitorManager::CycleMonitor() { |
55 MultiMonitorManager* manager = static_cast<MultiMonitorManager*>( | 55 MultiMonitorManager* manager = static_cast<MultiMonitorManager*>( |
56 aura::Env::GetInstance()->monitor_manager()); | 56 aura::Env::GetInstance()->monitor_manager()); |
57 manager->CycleMonitorImpl(); | 57 manager->CycleMonitorImpl(); |
58 } | 58 } |
59 | 59 |
60 void MultiMonitorManager::ScaleMonitor() { | |
61 MultiMonitorManager* manager = static_cast<MultiMonitorManager*>( | |
62 aura::Env::GetInstance()->monitor_manager()); | |
63 manager->ScaleMonitorImpl(); | |
64 } | |
65 | |
60 void MultiMonitorManager::OnNativeMonitorsChanged( | 66 void MultiMonitorManager::OnNativeMonitorsChanged( |
61 const std::vector<Monitor>& new_monitors) { | 67 const std::vector<Monitor>& new_monitors) { |
62 size_t min = std::min(monitors_.size(), new_monitors.size()); | 68 size_t min = std::min(monitors_.size(), new_monitors.size()); |
63 | 69 |
64 // For m19, we only care about 1st monitor as primary, and | 70 // For m19, we only care about 1st monitor as primary, and |
65 // don't differentiate the rest of monitors as all secondary | 71 // don't differentiate the rest of monitors as all secondary |
66 // monitors have the same content. ID for primary monitor stays the same | 72 // monitors have the same content. ID for primary monitor stays the same |
67 // because we never remove it, we don't update IDs for other monitors | 73 // because we never remove it, we don't update IDs for other monitors |
68 // , for now, because they're the same. | 74 // , for now, because they're the same. |
69 // TODO(oshima): Fix this so that we can differentiate outputs | 75 // TODO(oshima): Fix this so that we can differentiate outputs |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 for (Monitors::const_iterator iter = monitors_.begin() + 1; | 203 for (Monitors::const_iterator iter = monitors_.begin() + 1; |
198 iter != monitors_.end(); ++iter) { | 204 iter != monitors_.end(); ++iter) { |
199 gfx::Monitor monitor = *iter; | 205 gfx::Monitor monitor = *iter; |
200 new_monitors.push_back(monitor); | 206 new_monitors.push_back(monitor); |
201 } | 207 } |
202 new_monitors.push_back(monitors_.front()); | 208 new_monitors.push_back(monitors_.front()); |
203 OnNativeMonitorsChanged(new_monitors); | 209 OnNativeMonitorsChanged(new_monitors); |
204 } | 210 } |
205 } | 211 } |
206 | 212 |
213 void MultiMonitorManager::ScaleMonitorImpl() { | |
214 if (monitors_.size() > 0) { | |
215 std::vector<Monitor> new_monitors; | |
216 for (Monitors::const_iterator iter = monitors_.begin(); | |
217 iter != monitors_.end(); ++iter) { | |
218 gfx::Monitor monitor = *iter; | |
219 float next = monitor.device_scale_factor() == 1.0f ? 2.0f : 1.0f; | |
Daniel Erat
2012/05/07 19:44:05
nit: s/next/factor/
oshima
2012/05/08 00:17:24
Done.
| |
220 monitor.SetScaleAndBounds( | |
221 next, gfx::Rect(monitor.bounds_in_pixel().origin(), | |
222 monitor.size().Scale(next))); | |
223 new_monitors.push_back(monitor); | |
224 } | |
225 OnNativeMonitorsChanged(new_monitors); | |
226 } | |
227 } | |
228 | |
207 gfx::Monitor& MultiMonitorManager::FindMonitorById(int id) { | 229 gfx::Monitor& MultiMonitorManager::FindMonitorById(int id) { |
208 for (Monitors::iterator iter = monitors_.begin(); | 230 for (Monitors::iterator iter = monitors_.begin(); |
209 iter != monitors_.end(); ++iter) { | 231 iter != monitors_.end(); ++iter) { |
210 if ((*iter).id() == id) | 232 if ((*iter).id() == id) |
211 return *iter; | 233 return *iter; |
212 } | 234 } |
213 DLOG(FATAL) << "Could not find monitor by id:" << id; | 235 DLOG(FATAL) << "Could not find monitor by id:" << id; |
214 return GetInvalidMonitor(); | 236 return GetInvalidMonitor(); |
215 } | 237 } |
216 | 238 |
217 } // namespace internal | 239 } // namespace internal |
218 } // namespace ash | 240 } // namespace ash |
OLD | NEW |