| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 162 } |
| 163 | 163 |
| 164 void MultiMonitorManager::Init() { | 164 void MultiMonitorManager::Init() { |
| 165 // TODO(oshima): Move this logic to MonitorChangeObserver. | 165 // TODO(oshima): Move this logic to MonitorChangeObserver. |
| 166 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 166 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 167 switches::kAuraHostWindowSize); | 167 switches::kAuraHostWindowSize); |
| 168 vector<string> parts; | 168 vector<string> parts; |
| 169 base::SplitString(size_str, ',', &parts); | 169 base::SplitString(size_str, ',', &parts); |
| 170 for (vector<string>::const_iterator iter = parts.begin(); | 170 for (vector<string>::const_iterator iter = parts.begin(); |
| 171 iter != parts.end(); ++iter) { | 171 iter != parts.end(); ++iter) { |
| 172 monitors_.push_back(CreateMonitorFromSpec(*iter)); | 172 monitors_.push_back(CreateMonitorFromSpec( |
| 173 default_device_scale_factor(), *iter)); |
| 173 } | 174 } |
| 174 if (monitors_.empty()) | 175 if (monitors_.empty()) |
| 175 monitors_.push_back(CreateMonitorFromSpec("" /* default */)); | 176 monitors_.push_back(CreateMonitorFromSpec( |
| 177 default_device_scale_factor(), "" /* default */)); |
| 176 } | 178 } |
| 177 | 179 |
| 178 void MultiMonitorManager::AddRemoveMonitorImpl() { | 180 void MultiMonitorManager::AddRemoveMonitorImpl() { |
| 179 std::vector<Monitor> new_monitors; | 181 std::vector<Monitor> new_monitors; |
| 180 if (monitors_.size() > 1) { | 182 if (monitors_.size() > 1) { |
| 181 // Remove if there is more than one monitor. | 183 // Remove if there is more than one monitor. |
| 182 int count = monitors_.size() - 1; | 184 int count = monitors_.size() - 1; |
| 183 for (Monitors::const_iterator iter = monitors_.begin(); count-- > 0; ++iter) | 185 for (Monitors::const_iterator iter = monitors_.begin(); count-- > 0; ++iter) |
| 184 new_monitors.push_back(*iter); | 186 new_monitors.push_back(*iter); |
| 185 } else { | 187 } else { |
| 186 // Add if there is only one monitor. | 188 // Add if there is only one monitor. |
| 187 new_monitors.push_back(monitors_[0]); | 189 new_monitors.push_back(monitors_[0]); |
| 188 new_monitors.push_back(CreateMonitorFromSpec("50+50-1280x768")); | 190 new_monitors.push_back(CreateMonitorFromSpec( |
| 191 default_device_scale_factor(), "50+50-1280x768")); |
| 189 } | 192 } |
| 190 if (new_monitors.size()) | 193 if (new_monitors.size()) |
| 191 OnNativeMonitorsChanged(new_monitors); | 194 OnNativeMonitorsChanged(new_monitors); |
| 192 } | 195 } |
| 193 | 196 |
| 194 void MultiMonitorManager::CycleMonitorImpl() { | 197 void MultiMonitorManager::CycleMonitorImpl() { |
| 195 if (monitors_.size() > 1) { | 198 if (monitors_.size() > 1) { |
| 196 std::vector<Monitor> new_monitors; | 199 std::vector<Monitor> new_monitors; |
| 197 for (Monitors::const_iterator iter = monitors_.begin() + 1; | 200 for (Monitors::const_iterator iter = monitors_.begin() + 1; |
| 198 iter != monitors_.end(); ++iter) { | 201 iter != monitors_.end(); ++iter) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 209 iter != monitors_.end(); ++iter) { | 212 iter != monitors_.end(); ++iter) { |
| 210 if ((*iter).id() == id) | 213 if ((*iter).id() == id) |
| 211 return *iter; | 214 return *iter; |
| 212 } | 215 } |
| 213 DLOG(FATAL) << "Could not find monitor by id:" << id; | 216 DLOG(FATAL) << "Could not find monitor by id:" << id; |
| 214 return GetInvalidMonitor(); | 217 return GetInvalidMonitor(); |
| 215 } | 218 } |
| 216 | 219 |
| 217 } // namespace internal | 220 } // namespace internal |
| 218 } // namespace ash | 221 } // namespace ash |
| OLD | NEW |