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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 const gfx::Display& MultiDisplayManager::GetDisplayMatching( | 342 const gfx::Display& MultiDisplayManager::GetDisplayMatching( |
343 const gfx::Rect& rect) const { | 343 const gfx::Rect& rect) const { |
344 if (rect.IsEmpty()) | 344 if (rect.IsEmpty()) |
345 return GetDisplayNearestPoint(rect.origin()); | 345 return GetDisplayNearestPoint(rect.origin()); |
346 | 346 |
347 int max = 0; | 347 int max = 0; |
348 const gfx::Display* matching = 0; | 348 const gfx::Display* matching = 0; |
349 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); | 349 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); |
350 iter != displays_.end(); ++iter) { | 350 iter != displays_.end(); ++iter) { |
351 const gfx::Display& display = *iter; | 351 const gfx::Display& display = *iter; |
352 gfx::Rect intersect = display.bounds(); | 352 gfx::Rect intersect = gfx::Intersection(display.bounds(), rect); |
353 intersect.Intersect(rect); | |
354 int area = intersect.width() * intersect.height(); | 353 int area = intersect.width() * intersect.height(); |
355 if (area > max) { | 354 if (area > max) { |
356 max = area; | 355 max = area; |
357 matching = &(*iter); | 356 matching = &(*iter); |
358 } | 357 } |
359 } | 358 } |
360 // Fallback to the primary display if there is no matching display. | 359 // Fallback to the primary display if there is no matching display. |
361 return matching ? *matching : DisplayController::GetPrimaryDisplay(); | 360 return matching ? *matching : DisplayController::GetPrimaryDisplay(); |
362 } | 361 } |
363 | 362 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 DisplayList::iterator iter_to_update = to_update->begin(); | 498 DisplayList::iterator iter_to_update = to_update->begin(); |
500 DisplayList::const_iterator iter = displays_.begin(); | 499 DisplayList::const_iterator iter = displays_.begin(); |
501 for (; iter != displays_.end() && iter_to_update != to_update->end(); | 500 for (; iter != displays_.end() && iter_to_update != to_update->end(); |
502 ++iter, ++iter_to_update) { | 501 ++iter, ++iter_to_update) { |
503 (*iter_to_update).set_id((*iter).id()); | 502 (*iter_to_update).set_id((*iter).id()); |
504 } | 503 } |
505 } | 504 } |
506 | 505 |
507 } // namespace internal | 506 } // namespace internal |
508 } // namespace ash | 507 } // namespace ash |
OLD | NEW |