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

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

Issue 2519993002: Move kInvalidDisplayID to display_constants.h. (Closed)
Patch Set: Address comments. Created 4 years, 1 month 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/fake_display_snapshot.cc ('k') | ui/display/manager/display_layout_store.cc » ('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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
50 50
51 DisplayPlacement::DisplayPlacement() 51 DisplayPlacement::DisplayPlacement()
52 : DisplayPlacement(Display::kInvalidDisplayID, 52 : DisplayPlacement(kInvalidDisplayId,
53 Display::kInvalidDisplayID, 53 kInvalidDisplayId,
54 DisplayPlacement::RIGHT, 54 DisplayPlacement::RIGHT,
55 0, 55 0,
56 DisplayPlacement::TOP_LEFT) {} 56 DisplayPlacement::TOP_LEFT) {}
57 57
58 DisplayPlacement::DisplayPlacement(Position position, int offset) 58 DisplayPlacement::DisplayPlacement(Position position, int offset)
59 : DisplayPlacement(Display::kInvalidDisplayID, 59 : DisplayPlacement(kInvalidDisplayId,
60 Display::kInvalidDisplayID, 60 kInvalidDisplayId,
61 position, 61 position,
62 offset, 62 offset,
63 DisplayPlacement::TOP_LEFT) {} 63 DisplayPlacement::TOP_LEFT) {}
64 64
65 DisplayPlacement::DisplayPlacement(Position position, 65 DisplayPlacement::DisplayPlacement(Position position,
66 int offset, 66 int offset,
67 OffsetReference offset_reference) 67 OffsetReference offset_reference)
68 : DisplayPlacement(Display::kInvalidDisplayID, 68 : DisplayPlacement(kInvalidDisplayId,
69 Display::kInvalidDisplayID, 69 kInvalidDisplayId,
70 position, 70 position,
71 offset, 71 offset,
72 offset_reference) {} 72 offset_reference) {}
73 73
74 DisplayPlacement::DisplayPlacement(int64_t display_id, 74 DisplayPlacement::DisplayPlacement(int64_t display_id,
75 int64_t parent_display_id, 75 int64_t parent_display_id,
76 Position position, 76 Position position,
77 int offset, 77 int offset,
78 OffsetReference offset_reference) 78 OffsetReference offset_reference)
79 : display_id(display_id), 79 : display_id(display_id),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 position = RIGHT; 113 position = RIGHT;
114 break; 114 break;
115 } 115 }
116 offset = -offset; 116 offset = -offset;
117 std::swap(display_id, parent_display_id); 117 std::swap(display_id, parent_display_id);
118 return *this; 118 return *this;
119 } 119 }
120 120
121 std::string DisplayPlacement::ToString() const { 121 std::string DisplayPlacement::ToString() const {
122 std::stringstream s; 122 std::stringstream s;
123 if (display_id != Display::kInvalidDisplayID) 123 if (display_id != kInvalidDisplayId)
124 s << "id=" << display_id << ", "; 124 s << "id=" << display_id << ", ";
125 if (parent_display_id != Display::kInvalidDisplayID) 125 if (parent_display_id != kInvalidDisplayId)
126 s << "parent=" << parent_display_id << ", "; 126 s << "parent=" << parent_display_id << ", ";
127 s << PositionToString(position) << ", "; 127 s << PositionToString(position) << ", ";
128 s << offset; 128 s << offset;
129 return s.str(); 129 return s.str();
130 } 130 }
131 131
132 // static 132 // static
133 std::string DisplayPlacement::PositionToString(Position position) { 133 std::string DisplayPlacement::PositionToString(Position position) {
134 switch (position) { 134 switch (position) {
135 case TOP: 135 case TOP:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 LOG(ERROR) << "Invalid position value:" << string; 170 LOG(ERROR) << "Invalid position value:" << string;
171 171
172 return false; 172 return false;
173 } 173 }
174 174
175 //////////////////////////////////////////////////////////////////////////////// 175 ////////////////////////////////////////////////////////////////////////////////
176 // DisplayLayout 176 // DisplayLayout
177 177
178 DisplayLayout::DisplayLayout() 178 DisplayLayout::DisplayLayout()
179 : mirrored(false), 179 : mirrored(false), default_unified(true), primary_id(kInvalidDisplayId) {}
180 default_unified(true),
181 primary_id(Display::kInvalidDisplayID) {}
182 180
183 DisplayLayout::~DisplayLayout() {} 181 DisplayLayout::~DisplayLayout() {}
184 182
185 void DisplayLayout::ApplyToDisplayList(Displays* display_list, 183 void DisplayLayout::ApplyToDisplayList(Displays* display_list,
186 std::vector<int64_t>* updated_ids, 184 std::vector<int64_t>* updated_ids,
187 int minimum_offset_overlap) const { 185 int minimum_offset_overlap) const {
188 // Layout from primary, then dependent displays. 186 // Layout from primary, then dependent displays.
189 std::set<int64_t> parents; 187 std::set<int64_t> parents;
190 parents.insert(primary_id); 188 parents.insert(primary_id);
191 while (parents.size()) { 189 while (parents.size()) {
(...skipping 26 matching lines...) Expand all
218 216
219 bool has_primary_as_parent = false; 217 bool has_primary_as_parent = false;
220 int64_t id = 0; 218 int64_t id = 0;
221 219
222 for (const auto& placement : layout.placement_list) { 220 for (const auto& placement : layout.placement_list) {
223 // Placements are sorted by display_id. 221 // Placements are sorted by display_id.
224 if (id >= placement.display_id) { 222 if (id >= placement.display_id) {
225 LOG(ERROR) << "PlacementList must be sorted by display_id"; 223 LOG(ERROR) << "PlacementList must be sorted by display_id";
226 return false; 224 return false;
227 } 225 }
228 if (placement.display_id == Display::kInvalidDisplayID) { 226 if (placement.display_id == kInvalidDisplayId) {
229 LOG(ERROR) << "display_id is not initialized"; 227 LOG(ERROR) << "display_id is not initialized";
230 return false; 228 return false;
231 } 229 }
232 if (placement.parent_display_id == Display::kInvalidDisplayID) { 230 if (placement.parent_display_id == kInvalidDisplayId) {
233 LOG(ERROR) << "display_parent_id is not initialized"; 231 LOG(ERROR) << "display_parent_id is not initialized";
234 return false; 232 return false;
235 } 233 }
236 if (placement.display_id == placement.parent_display_id) { 234 if (placement.display_id == placement.parent_display_id) {
237 LOG(ERROR) << "display_id must not be same as parent_display_id"; 235 LOG(ERROR) << "display_id must not be same as parent_display_id";
238 return false; 236 return false;
239 } 237 }
240 if (!IsIdInList(placement.display_id, list)) { 238 if (!IsIdInList(placement.display_id, list)) {
241 LOG(ERROR) << "display_id is not in the id list:" << placement.ToString(); 239 LOG(ERROR) << "display_id is not in the id list:" << placement.ToString();
242 return false; 240 return false;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 361
364 gfx::Insets insets = target_display->GetWorkAreaInsets(); 362 gfx::Insets insets = target_display->GetWorkAreaInsets();
365 target_display->set_bounds( 363 target_display->set_bounds(
366 gfx::Rect(new_target_origin, target_bounds.size())); 364 gfx::Rect(new_target_origin, target_bounds.size()));
367 target_display->UpdateWorkAreaFromInsets(insets); 365 target_display->UpdateWorkAreaFromInsets(insets);
368 366
369 return old_bounds != target_display->bounds(); 367 return old_bounds != target_display->bounds();
370 } 368 }
371 369
372 } // namespace display 370 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/fake_display_snapshot.cc ('k') | ui/display/manager/display_layout_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698