| 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/display_layout.h" | 5 #include "ui/display/display_layout.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 DCHECK_GE(kMaxValidOffset, abs(offset)); | 375 DCHECK_GE(kMaxValidOffset, abs(offset)); |
| 376 } | 376 } |
| 377 | 377 |
| 378 DisplayPlacement::DisplayPlacement(const DisplayPlacement& placement) | 378 DisplayPlacement::DisplayPlacement(const DisplayPlacement& placement) |
| 379 : display_id(placement.display_id), | 379 : display_id(placement.display_id), |
| 380 parent_display_id(placement.parent_display_id), | 380 parent_display_id(placement.parent_display_id), |
| 381 position(placement.position), | 381 position(placement.position), |
| 382 offset(placement.offset), | 382 offset(placement.offset), |
| 383 offset_reference(placement.offset_reference) {} | 383 offset_reference(placement.offset_reference) {} |
| 384 | 384 |
| 385 bool DisplayPlacement::operator==(const DisplayPlacement& other) const { |
| 386 return display_id == other.display_id && |
| 387 parent_display_id == other.parent_display_id && |
| 388 position == other.position && |
| 389 offset == other.offset && |
| 390 offset_reference == other.offset_reference; |
| 391 } |
| 392 |
| 393 bool DisplayPlacement::operator!=(const DisplayPlacement& other) const { |
| 394 return !operator==(other); |
| 395 } |
| 396 |
| 385 DisplayPlacement& DisplayPlacement::Swap() { | 397 DisplayPlacement& DisplayPlacement::Swap() { |
| 386 switch (position) { | 398 switch (position) { |
| 387 case TOP: | 399 case TOP: |
| 388 position = BOTTOM; | 400 position = BOTTOM; |
| 389 break; | 401 break; |
| 390 case BOTTOM: | 402 case BOTTOM: |
| 391 position = TOP; | 403 position = TOP; |
| 392 break; | 404 break; |
| 393 case RIGHT: | 405 case RIGHT: |
| 394 position = LEFT; | 406 position = LEFT; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 std::unique_ptr<DisplayLayout> copy(new DisplayLayout); | 574 std::unique_ptr<DisplayLayout> copy(new DisplayLayout); |
| 563 for (const auto& placement : placement_list) | 575 for (const auto& placement : placement_list) |
| 564 copy->placement_list.push_back(placement); | 576 copy->placement_list.push_back(placement); |
| 565 copy->mirrored = mirrored; | 577 copy->mirrored = mirrored; |
| 566 copy->default_unified = default_unified; | 578 copy->default_unified = default_unified; |
| 567 copy->primary_id = primary_id; | 579 copy->primary_id = primary_id; |
| 568 return copy; | 580 return copy; |
| 569 } | 581 } |
| 570 | 582 |
| 571 bool DisplayLayout::HasSamePlacementList(const DisplayLayout& layout) const { | 583 bool DisplayLayout::HasSamePlacementList(const DisplayLayout& layout) const { |
| 572 if (placement_list.size() != layout.placement_list.size()) | 584 return placement_list == layout.placement_list; |
| 573 return false; | |
| 574 for (size_t index = 0; index < placement_list.size(); index++) { | |
| 575 const DisplayPlacement& placement1 = placement_list[index]; | |
| 576 const DisplayPlacement& placement2 = layout.placement_list[index]; | |
| 577 if (placement1.position != placement2.position || | |
| 578 placement1.offset != placement2.offset || | |
| 579 placement1.display_id != placement2.display_id || | |
| 580 placement1.parent_display_id != placement2.parent_display_id) { | |
| 581 return false; | |
| 582 } | |
| 583 } | |
| 584 return true; | |
| 585 } | 585 } |
| 586 | 586 |
| 587 std::string DisplayLayout::ToString() const { | 587 std::string DisplayLayout::ToString() const { |
| 588 std::stringstream s; | 588 std::stringstream s; |
| 589 s << "primary=" << primary_id; | 589 s << "primary=" << primary_id; |
| 590 if (mirrored) | 590 if (mirrored) |
| 591 s << ", mirrored"; | 591 s << ", mirrored"; |
| 592 if (default_unified) | 592 if (default_unified) |
| 593 s << ", default_unified"; | 593 s << ", default_unified"; |
| 594 bool added = false; | 594 bool added = false; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 | 663 |
| 664 gfx::Insets insets = target_display->GetWorkAreaInsets(); | 664 gfx::Insets insets = target_display->GetWorkAreaInsets(); |
| 665 target_display->set_bounds( | 665 target_display->set_bounds( |
| 666 gfx::Rect(new_target_origin, target_bounds.size())); | 666 gfx::Rect(new_target_origin, target_bounds.size())); |
| 667 target_display->UpdateWorkAreaFromInsets(insets); | 667 target_display->UpdateWorkAreaFromInsets(insets); |
| 668 | 668 |
| 669 return old_bounds != target_display->bounds(); | 669 return old_bounds != target_display->bounds(); |
| 670 } | 670 } |
| 671 | 671 |
| 672 } // namespace display | 672 } // namespace display |
| OLD | NEW |