| 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 gfx::Display* FindDisplayById(DisplayList* display_list, int64_t id) { | 39 display::Display* FindDisplayById(DisplayList* display_list, int64_t id) { |
| 40 auto iter = std::find_if( | 40 auto iter = std::find_if( |
| 41 display_list->begin(), display_list->end(), | 41 display_list->begin(), display_list->end(), |
| 42 [id](const gfx::Display& display) { return display.id() == id; }); | 42 [id](const display::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 |
| 50 | 50 |
| 51 DisplayPlacement::DisplayPlacement() | 51 DisplayPlacement::DisplayPlacement() |
| 52 : display_id(display::Display::kInvalidDisplayID), | 52 : display_id(display::Display::kInvalidDisplayID), |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 return placement.display_id == display_id; | 282 return placement.display_id == display_id; |
| 283 }); | 283 }); |
| 284 return (iter == placement_list.end()) ? DisplayPlacement() | 284 return (iter == placement_list.end()) ? DisplayPlacement() |
| 285 : DisplayPlacement(*iter); | 285 : DisplayPlacement(*iter); |
| 286 } | 286 } |
| 287 | 287 |
| 288 // static | 288 // static |
| 289 bool DisplayLayout::ApplyDisplayPlacement(const DisplayPlacement& placement, | 289 bool DisplayLayout::ApplyDisplayPlacement(const DisplayPlacement& placement, |
| 290 DisplayList* display_list, | 290 DisplayList* display_list, |
| 291 int minimum_offset_overlap) { | 291 int minimum_offset_overlap) { |
| 292 const gfx::Display& parent_display = | 292 const display::Display& parent_display = |
| 293 *FindDisplayById(display_list, placement.parent_display_id); | 293 *FindDisplayById(display_list, placement.parent_display_id); |
| 294 DCHECK(parent_display.is_valid()); | 294 DCHECK(parent_display.is_valid()); |
| 295 gfx::Display* target_display = | 295 display::Display* target_display = |
| 296 FindDisplayById(display_list, placement.display_id); | 296 FindDisplayById(display_list, placement.display_id); |
| 297 gfx::Rect old_bounds(target_display->bounds()); | 297 gfx::Rect old_bounds(target_display->bounds()); |
| 298 DCHECK(target_display); | 298 DCHECK(target_display); |
| 299 | 299 |
| 300 const gfx::Rect& parent_bounds = parent_display.bounds(); | 300 const gfx::Rect& parent_bounds = parent_display.bounds(); |
| 301 const gfx::Rect& target_bounds = target_display->bounds(); | 301 const gfx::Rect& target_bounds = target_display->bounds(); |
| 302 gfx::Point new_target_origin = parent_bounds.origin(); | 302 gfx::Point new_target_origin = parent_bounds.origin(); |
| 303 | 303 |
| 304 DisplayPlacement::Position position = placement.position; | 304 DisplayPlacement::Position position = placement.position; |
| 305 | 305 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 335 | 335 |
| 336 gfx::Insets insets = target_display->GetWorkAreaInsets(); | 336 gfx::Insets insets = target_display->GetWorkAreaInsets(); |
| 337 target_display->set_bounds( | 337 target_display->set_bounds( |
| 338 gfx::Rect(new_target_origin, target_bounds.size())); | 338 gfx::Rect(new_target_origin, target_bounds.size())); |
| 339 target_display->UpdateWorkAreaFromInsets(insets); | 339 target_display->UpdateWorkAreaFromInsets(insets); |
| 340 | 340 |
| 341 return old_bounds != target_display->bounds(); | 341 return old_bounds != target_display->bounds(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace display | 344 } // namespace display |
| OLD | NEW |