OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/display_util.h" | 5 #include "ash/display/display_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
11 #include "ash/host/ash_window_tree_host.h" | 11 #include "ash/host/ash_window_tree_host.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "base/strings/string_number_conversions.h" | |
13 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
14 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
15 #include "ui/gfx/display.h" | 16 #include "ui/gfx/display.h" |
16 #include "ui/gfx/geometry/point.h" | 17 #include "ui/gfx/geometry/point.h" |
17 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
18 #include "ui/gfx/geometry/size_conversions.h" | 19 #include "ui/gfx/geometry/size_conversions.h" |
19 #include "ui/wm/core/coordinate_conversion.h" | 20 #include "ui/wm/core/coordinate_conversion.h" |
20 | 21 |
21 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
22 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 | 342 |
342 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, | 343 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, |
343 const gfx::Point& point_in_screen) { | 344 const gfx::Point& point_in_screen) { |
344 auto iter = std::find_if(displays.begin(), displays.end(), | 345 auto iter = std::find_if(displays.begin(), displays.end(), |
345 [point_in_screen](const gfx::Display& display) { | 346 [point_in_screen](const gfx::Display& display) { |
346 return display.bounds().Contains(point_in_screen); | 347 return display.bounds().Contains(point_in_screen); |
347 }); | 348 }); |
348 return iter == displays.end() ? -1 : (iter - displays.begin()); | 349 return iter == displays.end() ? -1 : (iter - displays.begin()); |
349 } | 350 } |
350 | 351 |
351 DisplayIdPair CreateDisplayIdPair(int64_t id1, int64_t id2) { | 352 DisplayIdList CreateDisplayIdList(int64_t id1, int64_t id2) { |
352 return CompareDisplayIds(id1, id2) ? std::make_pair(id1, id2) | 353 std::vector<int64_t> ids; |
353 : std::make_pair(id2, id1); | 354 ids.push_back(id1); |
355 ids.push_back(id2); | |
356 std::sort(ids.begin(), ids.end(), | |
357 [](int64_t a, int64_t b) { return CompareDisplayIds(a, b); }); | |
358 return ids; | |
359 } | |
360 | |
361 std::string DisplayIdListToString(const ash::DisplayIdList& list) { | |
362 return base::Int64ToString(list[0]) + "," + base::Int64ToString(list[1]); | |
stevenjb
2016/01/29 19:15:02
Maybe generalize this now?
| |
354 } | 363 } |
355 | 364 |
356 bool CompareDisplayIds(int64_t id1, int64_t id2) { | 365 bool CompareDisplayIds(int64_t id1, int64_t id2) { |
357 DCHECK_NE(id1, id2); | 366 DCHECK_NE(id1, id2); |
358 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID | 367 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID |
359 // in edid_parser.cc. | 368 // in edid_parser.cc. |
360 int index_1 = id1 & 0xFF; | 369 int index_1 = id1 & 0xFF; |
361 int index_2 = id2 & 0xFF; | 370 int index_2 = id2 & 0xFF; |
362 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; | 371 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; |
363 return gfx::Display::IsInternalDisplayId(id1) || | 372 return gfx::Display::IsInternalDisplayId(id1) || |
364 (index_1 < index_2 && !gfx::Display::IsInternalDisplayId(id2)); | 373 (index_1 < index_2 && !gfx::Display::IsInternalDisplayId(id2)); |
365 } | 374 } |
366 | 375 |
367 } // namespace ash | 376 } // namespace ash |
OLD | NEW |