OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/display/manager/display_layout.h" | 5 #include "ui/display/manager/display_layout.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 // to change this value in case to support even larger displays. | 29 // to change this value in case to support even larger displays. |
30 const int kMaxValidOffset = 10000; | 30 const int kMaxValidOffset = 10000; |
31 | 31 |
32 bool IsIdInList(int64_t id, const DisplayIdList& list) { | 32 bool IsIdInList(int64_t id, const DisplayIdList& list) { |
33 const auto iter = | 33 const auto iter = |
34 std::find_if(list.begin(), list.end(), | 34 std::find_if(list.begin(), list.end(), |
35 [id](int64_t display_id) { return display_id == id; }); | 35 [id](int64_t display_id) { return display_id == id; }); |
36 return iter != list.end(); | 36 return iter != list.end(); |
37 } | 37 } |
38 | 38 |
39 Display* FindDisplayById(DisplayList* display_list, int64_t id) { | 39 Display* FindDisplayById(Displays* display_list, int64_t id) { |
40 auto iter = | 40 auto iter = |
41 std::find_if(display_list->begin(), display_list->end(), | 41 std::find_if(display_list->begin(), display_list->end(), |
42 [id](const Display& display) { return display.id() == id; }); | 42 [id](const Display& display) { return display.id() == id; }); |
43 return &(*iter); | 43 return &(*iter); |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
49 // DisplayPlacement | 49 // DisplayPlacement |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 //////////////////////////////////////////////////////////////////////////////// | 175 //////////////////////////////////////////////////////////////////////////////// |
176 // DisplayLayout | 176 // DisplayLayout |
177 | 177 |
178 DisplayLayout::DisplayLayout() | 178 DisplayLayout::DisplayLayout() |
179 : mirrored(false), | 179 : mirrored(false), |
180 default_unified(true), | 180 default_unified(true), |
181 primary_id(Display::kInvalidDisplayID) {} | 181 primary_id(Display::kInvalidDisplayID) {} |
182 | 182 |
183 DisplayLayout::~DisplayLayout() {} | 183 DisplayLayout::~DisplayLayout() {} |
184 | 184 |
185 void DisplayLayout::ApplyToDisplayList(DisplayList* display_list, | 185 void DisplayLayout::ApplyToDisplayList(Displays* display_list, |
186 std::vector<int64_t>* updated_ids, | 186 std::vector<int64_t>* updated_ids, |
187 int minimum_offset_overlap) const { | 187 int minimum_offset_overlap) const { |
188 // Layout from primary, then dependent displays. | 188 // Layout from primary, then dependent displays. |
189 std::set<int64_t> parents; | 189 std::set<int64_t> parents; |
190 parents.insert(primary_id); | 190 parents.insert(primary_id); |
191 while (parents.size()) { | 191 while (parents.size()) { |
192 int64_t parent_id = *parents.begin(); | 192 int64_t parent_id = *parents.begin(); |
193 parents.erase(parent_id); | 193 parents.erase(parent_id); |
194 for (const DisplayPlacement& placement : placement_list) { | 194 for (const DisplayPlacement& placement : placement_list) { |
195 if (placement.parent_display_id == parent_id) { | 195 if (placement.parent_display_id == parent_id) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 std::find_if(placement_list.begin(), placement_list.end(), | 303 std::find_if(placement_list.begin(), placement_list.end(), |
304 [display_id](const DisplayPlacement& placement) { | 304 [display_id](const DisplayPlacement& placement) { |
305 return placement.display_id == display_id; | 305 return placement.display_id == display_id; |
306 }); | 306 }); |
307 return (iter == placement_list.end()) ? DisplayPlacement() | 307 return (iter == placement_list.end()) ? DisplayPlacement() |
308 : DisplayPlacement(*iter); | 308 : DisplayPlacement(*iter); |
309 } | 309 } |
310 | 310 |
311 // static | 311 // static |
312 bool DisplayLayout::ApplyDisplayPlacement(const DisplayPlacement& placement, | 312 bool DisplayLayout::ApplyDisplayPlacement(const DisplayPlacement& placement, |
313 DisplayList* display_list, | 313 Displays* display_list, |
314 int minimum_offset_overlap) { | 314 int minimum_offset_overlap) { |
315 const Display& parent_display = | 315 const Display& parent_display = |
316 *FindDisplayById(display_list, placement.parent_display_id); | 316 *FindDisplayById(display_list, placement.parent_display_id); |
317 DCHECK(parent_display.is_valid()); | 317 DCHECK(parent_display.is_valid()); |
318 Display* target_display = FindDisplayById(display_list, placement.display_id); | 318 Display* target_display = FindDisplayById(display_list, placement.display_id); |
319 gfx::Rect old_bounds(target_display->bounds()); | 319 gfx::Rect old_bounds(target_display->bounds()); |
320 DCHECK(target_display); | 320 DCHECK(target_display); |
321 | 321 |
322 const gfx::Rect& parent_bounds = parent_display.bounds(); | 322 const gfx::Rect& parent_bounds = parent_display.bounds(); |
323 const gfx::Rect& target_bounds = target_display->bounds(); | 323 const gfx::Rect& target_bounds = target_display->bounds(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 363 |
364 gfx::Insets insets = target_display->GetWorkAreaInsets(); | 364 gfx::Insets insets = target_display->GetWorkAreaInsets(); |
365 target_display->set_bounds( | 365 target_display->set_bounds( |
366 gfx::Rect(new_target_origin, target_bounds.size())); | 366 gfx::Rect(new_target_origin, target_bounds.size())); |
367 target_display->UpdateWorkAreaFromInsets(insets); | 367 target_display->UpdateWorkAreaFromInsets(insets); |
368 | 368 |
369 return old_bounds != target_display->bounds(); | 369 return old_bounds != target_display->bounds(); |
370 } | 370 } |
371 | 371 |
372 } // namespace display | 372 } // namespace display |
OLD | NEW |