Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: ui/display/manager/display_layout.cc

Issue 1913613002: Add place holder to move gfx::Display/Screen to ui/display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/display/manager/display_layout.h ('k') | ui/display/screen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "ui/gfx/display.h" 15 #include "ui/display/display.h"
16 #include "ui/gfx/geometry/insets.h" 16 #include "ui/gfx/geometry/insets.h"
17 17
18 namespace display { 18 namespace display {
19 namespace { 19 namespace {
20 20
21 // DisplayPlacement Positions 21 // DisplayPlacement Positions
22 const char kTop[] = "top"; 22 const char kTop[] = "top";
23 const char kRight[] = "right"; 23 const char kRight[] = "right";
24 const char kBottom[] = "bottom"; 24 const char kBottom[] = "bottom";
25 const char kLeft[] = "left"; 25 const char kLeft[] = "left";
(...skipping 16 matching lines...) Expand all
42 [id](const gfx::Display& display) { return display.id() == id; }); 42 [id](const gfx::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(gfx::Display::kInvalidDisplayID), 52 : display_id(display::Display::kInvalidDisplayID),
53 parent_display_id(gfx::Display::kInvalidDisplayID), 53 parent_display_id(display::Display::kInvalidDisplayID),
54 position(DisplayPlacement::RIGHT), 54 position(DisplayPlacement::RIGHT),
55 offset(0) {} 55 offset(0) {}
56 56
57 DisplayPlacement::DisplayPlacement(Position pos, int offset) 57 DisplayPlacement::DisplayPlacement(Position pos, int offset)
58 : display_id(gfx::Display::kInvalidDisplayID), 58 : display_id(display::Display::kInvalidDisplayID),
59 parent_display_id(gfx::Display::kInvalidDisplayID), 59 parent_display_id(display::Display::kInvalidDisplayID),
60 position(pos), 60 position(pos),
61 offset(offset) { 61 offset(offset) {
62 DCHECK_LE(TOP, position); 62 DCHECK_LE(TOP, position);
63 DCHECK_GE(LEFT, position); 63 DCHECK_GE(LEFT, position);
64 // Set the default value to |position| in case position is invalid. DCHECKs 64 // Set the default value to |position| in case position is invalid. DCHECKs
65 // above doesn't stop in Release builds. 65 // above doesn't stop in Release builds.
66 if (TOP > position || LEFT < position) 66 if (TOP > position || LEFT < position)
67 this->position = RIGHT; 67 this->position = RIGHT;
68 68
69 DCHECK_GE(kMaxValidOffset, abs(offset)); 69 DCHECK_GE(kMaxValidOffset, abs(offset));
(...skipping 20 matching lines...) Expand all
90 position = RIGHT; 90 position = RIGHT;
91 break; 91 break;
92 } 92 }
93 offset = -offset; 93 offset = -offset;
94 std::swap(display_id, parent_display_id); 94 std::swap(display_id, parent_display_id);
95 return *this; 95 return *this;
96 } 96 }
97 97
98 std::string DisplayPlacement::ToString() const { 98 std::string DisplayPlacement::ToString() const {
99 std::stringstream s; 99 std::stringstream s;
100 if (display_id != gfx::Display::kInvalidDisplayID) 100 if (display_id != display::Display::kInvalidDisplayID)
101 s << "id=" << display_id << ", "; 101 s << "id=" << display_id << ", ";
102 if (parent_display_id != gfx::Display::kInvalidDisplayID) 102 if (parent_display_id != display::Display::kInvalidDisplayID)
103 s << "parent=" << parent_display_id << ", "; 103 s << "parent=" << parent_display_id << ", ";
104 s << PositionToString(position) << ", "; 104 s << PositionToString(position) << ", ";
105 s << offset; 105 s << offset;
106 return s.str(); 106 return s.str();
107 } 107 }
108 108
109 // static 109 // static
110 std::string DisplayPlacement::PositionToString(Position position) { 110 std::string DisplayPlacement::PositionToString(Position position) {
111 switch (position) { 111 switch (position) {
112 case TOP: 112 case TOP:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 return false; 149 return false;
150 } 150 }
151 151
152 //////////////////////////////////////////////////////////////////////////////// 152 ////////////////////////////////////////////////////////////////////////////////
153 // DisplayLayout 153 // DisplayLayout
154 154
155 DisplayLayout::DisplayLayout() 155 DisplayLayout::DisplayLayout()
156 : mirrored(false), 156 : mirrored(false),
157 default_unified(true), 157 default_unified(true),
158 primary_id(gfx::Display::kInvalidDisplayID) {} 158 primary_id(display::Display::kInvalidDisplayID) {}
159 159
160 DisplayLayout::~DisplayLayout() {} 160 DisplayLayout::~DisplayLayout() {}
161 161
162 void DisplayLayout::ApplyToDisplayList(DisplayList* display_list, 162 void DisplayLayout::ApplyToDisplayList(DisplayList* display_list,
163 std::vector<int64_t>* updated_ids, 163 std::vector<int64_t>* updated_ids,
164 int minimum_offset_overlap) const { 164 int minimum_offset_overlap) const {
165 // Layout from primary, then dependent displays. 165 // Layout from primary, then dependent displays.
166 std::set<int64_t> parents; 166 std::set<int64_t> parents;
167 parents.insert(primary_id); 167 parents.insert(primary_id);
168 while (parents.size()) { 168 while (parents.size()) {
(...skipping 26 matching lines...) Expand all
195 195
196 bool has_primary_as_parent = false; 196 bool has_primary_as_parent = false;
197 int64_t id = 0; 197 int64_t id = 0;
198 198
199 for (const auto& placement : layout.placement_list) { 199 for (const auto& placement : layout.placement_list) {
200 // Placements are sorted by display_id. 200 // Placements are sorted by display_id.
201 if (id >= placement.display_id) { 201 if (id >= placement.display_id) {
202 LOG(ERROR) << "PlacementList must be sorted by display_id"; 202 LOG(ERROR) << "PlacementList must be sorted by display_id";
203 return false; 203 return false;
204 } 204 }
205 if (placement.display_id == gfx::Display::kInvalidDisplayID) { 205 if (placement.display_id == display::Display::kInvalidDisplayID) {
206 LOG(ERROR) << "display_id is not initialized"; 206 LOG(ERROR) << "display_id is not initialized";
207 return false; 207 return false;
208 } 208 }
209 if (placement.parent_display_id == gfx::Display::kInvalidDisplayID) { 209 if (placement.parent_display_id == display::Display::kInvalidDisplayID) {
210 LOG(ERROR) << "display_parent_id is not initialized"; 210 LOG(ERROR) << "display_parent_id is not initialized";
211 return false; 211 return false;
212 } 212 }
213 if (placement.display_id == placement.parent_display_id) { 213 if (placement.display_id == placement.parent_display_id) {
214 LOG(ERROR) << "display_id must not be same as parent_display_id"; 214 LOG(ERROR) << "display_id must not be same as parent_display_id";
215 return false; 215 return false;
216 } 216 }
217 if (!IsIdInList(placement.display_id, list)) { 217 if (!IsIdInList(placement.display_id, list)) {
218 LOG(ERROR) << "display_id is not in the id list:" << placement.ToString(); 218 LOG(ERROR) << "display_id is not in the id list:" << placement.ToString();
219 return false; 219 return false;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « ui/display/manager/display_layout.h ('k') | ui/display/screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698