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/display/multi_display_manager.h" | 5 #include "ash/display/multi_display_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 const Window* window) const { | 147 const Window* window) const { |
148 if (!window) | 148 if (!window) |
149 return displays_[0]; | 149 return displays_[0]; |
150 const RootWindow* root = window->GetRootWindow(); | 150 const RootWindow* root = window->GetRootWindow(); |
151 MultiDisplayManager* manager = const_cast<MultiDisplayManager*>(this); | 151 MultiDisplayManager* manager = const_cast<MultiDisplayManager*>(this); |
152 return root ? manager->FindDisplayForRootWindow(root) : GetInvalidDisplay(); | 152 return root ? manager->FindDisplayForRootWindow(root) : GetInvalidDisplay(); |
153 } | 153 } |
154 | 154 |
155 const gfx::Display& MultiDisplayManager::GetDisplayNearestPoint( | 155 const gfx::Display& MultiDisplayManager::GetDisplayNearestPoint( |
156 const gfx::Point& point) const { | 156 const gfx::Point& point) const { |
157 if (!internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) | 157 if (!DisplayController::IsExtendedDesktopEnabled()) |
158 return displays_[0]; | 158 return displays_[0]; |
159 | |
160 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); | 159 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); |
161 iter != displays_.end(); ++iter) { | 160 iter != displays_.end(); ++iter) { |
162 const gfx::Display& display = *iter; | 161 const gfx::Display& display = *iter; |
163 if (display.bounds().Contains(point)) | 162 if (display.bounds().Contains(point)) |
164 return display; | 163 return display; |
165 } | 164 } |
166 // Fallback to the primary display if there is no root display containing | 165 // Fallback to the primary display if there is no root display containing |
167 // the |point|. | 166 // the |point|. |
168 return displays_[0]; | 167 return displays_[0]; |
169 } | 168 } |
170 | 169 |
171 const gfx::Display& MultiDisplayManager::GetDisplayMatching( | 170 const gfx::Display& MultiDisplayManager::GetDisplayMatching( |
172 const gfx::Rect& rect) const { | 171 const gfx::Rect& rect) const { |
173 if (!internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) | 172 if (!DisplayController::IsExtendedDesktopEnabled()) |
174 return displays_[0]; | 173 return displays_[0]; |
175 if (rect.IsEmpty()) | 174 if (rect.IsEmpty()) |
176 return GetDisplayNearestPoint(rect.origin()); | 175 return GetDisplayNearestPoint(rect.origin()); |
177 | 176 |
178 int max = 0; | 177 int max = 0; |
179 const gfx::Display* matching = 0; | 178 const gfx::Display* matching = 0; |
180 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); | 179 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); |
181 iter != displays_.end(); ++iter) { | 180 iter != displays_.end(); ++iter) { |
182 const gfx::Display& display = *iter; | 181 const gfx::Display& display = *iter; |
183 gfx::Rect intersect = display.bounds().Intersect(rect); | 182 gfx::Rect intersect = display.bounds().Intersect(rect); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 if ((*iter).id() == id) | 268 if ((*iter).id() == id) |
270 return *iter; | 269 return *iter; |
271 } | 270 } |
272 DLOG(FATAL) << "Could not find display by id:" << id; | 271 DLOG(FATAL) << "Could not find display by id:" << id; |
273 return GetInvalidDisplay(); | 272 return GetInvalidDisplay(); |
274 } | 273 } |
275 | 274 |
276 void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) { | 275 void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) { |
277 gfx::Display display = CreateDisplayFromSpec(spec); | 276 gfx::Display display = CreateDisplayFromSpec(spec); |
278 | 277 |
279 if (internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) { | 278 if (DisplayController::IsExtendedDesktopEnabled()) { |
280 const gfx::Insets insets = display.GetWorkAreaInsets(); | 279 const gfx::Insets insets = display.GetWorkAreaInsets(); |
281 const gfx::Rect& native_bounds = display.bounds_in_pixel(); | 280 const gfx::Rect& native_bounds = display.bounds_in_pixel(); |
282 display.set_bounds( | 281 display.set_bounds( |
283 gfx::Rect(native_bounds.origin(), display.bounds().size())); | 282 gfx::Rect(native_bounds.origin(), display.bounds().size())); |
284 display.UpdateWorkAreaFromInsets(insets); | 283 display.UpdateWorkAreaFromInsets(insets); |
285 } | 284 } |
286 displays_.push_back(display); | 285 displays_.push_back(display); |
287 } | 286 } |
288 | 287 |
289 } // namespace internal | 288 } // namespace internal |
290 } // namespace ash | 289 } // namespace ash |
OLD | NEW |