| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_manager.h" | 5 #include "ui/display/manager/display_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 DisplayIdList list = GetCurrentDisplayIdList(); | 201 DisplayIdList list = GetCurrentDisplayIdList(); |
| 202 return layout_store_->GetRegisteredDisplayLayout(list); | 202 return layout_store_->GetRegisteredDisplayLayout(list); |
| 203 } | 203 } |
| 204 LOG(ERROR) << "DisplayLayout is requested for single display"; | 204 LOG(ERROR) << "DisplayLayout is requested for single display"; |
| 205 // On release build, just fallback to default instead of blowing up. | 205 // On release build, just fallback to default instead of blowing up. |
| 206 static DisplayLayout layout; | 206 static DisplayLayout layout; |
| 207 layout.primary_id = active_display_list_[0].id(); | 207 layout.primary_id = active_display_list_[0].id(); |
| 208 return layout; | 208 return layout; |
| 209 } | 209 } |
| 210 | 210 |
| 211 const DisplayLayout& DisplayManager::GetCurrentResolvedDisplayLayout() const { |
| 212 return current_resolved_layout_ ? *current_resolved_layout_ |
| 213 : GetCurrentDisplayLayout(); |
| 214 } |
| 215 |
| 211 DisplayIdList DisplayManager::GetCurrentDisplayIdList() const { | 216 DisplayIdList DisplayManager::GetCurrentDisplayIdList() const { |
| 212 if (IsInUnifiedMode()) { | 217 if (IsInUnifiedMode()) { |
| 213 return CreateDisplayIdList(software_mirroring_display_list_); | 218 return CreateDisplayIdList(software_mirroring_display_list_); |
| 214 } else if (IsInMirrorMode()) { | 219 } else if (IsInMirrorMode()) { |
| 215 if (software_mirroring_enabled()) { | 220 if (software_mirroring_enabled()) { |
| 216 CHECK_EQ(2u, num_connected_displays()); | 221 CHECK_EQ(2u, num_connected_displays()); |
| 217 // This comment is to make it easy to distinguish the crash | 222 // This comment is to make it easy to distinguish the crash |
| 218 // between two checks. | 223 // between two checks. |
| 219 CHECK_EQ(1u, active_display_list_.size()); | 224 CHECK_EQ(1u, active_display_list_.size()); |
| 220 } | 225 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 239 | 244 |
| 240 if (layout->HasSamePlacementList(current_layout)) | 245 if (layout->HasSamePlacementList(current_layout)) |
| 241 return; | 246 return; |
| 242 | 247 |
| 243 layout_store_->RegisterLayoutForDisplayIdList(list, std::move(layout)); | 248 layout_store_->RegisterLayoutForDisplayIdList(list, std::move(layout)); |
| 244 if (delegate_) | 249 if (delegate_) |
| 245 delegate_->PreDisplayConfigurationChange(false); | 250 delegate_->PreDisplayConfigurationChange(false); |
| 246 | 251 |
| 247 // TODO(oshima): Call UpdateDisplays instead. | 252 // TODO(oshima): Call UpdateDisplays instead. |
| 248 std::vector<int64_t> updated_ids; | 253 std::vector<int64_t> updated_ids; |
| 249 ApplyDisplayLayout(GetCurrentDisplayLayout(), &active_display_list_, | 254 current_resolved_layout_ = GetCurrentDisplayLayout().Copy(); |
| 255 ApplyDisplayLayout(current_resolved_layout_.get(), &active_display_list_, |
| 250 &updated_ids); | 256 &updated_ids); |
| 251 for (int64_t id : updated_ids) { | 257 for (int64_t id : updated_ids) { |
| 252 NotifyMetricsChanged(GetDisplayForId(id), | 258 NotifyMetricsChanged(GetDisplayForId(id), |
| 253 DisplayObserver::DISPLAY_METRIC_BOUNDS | | 259 DisplayObserver::DISPLAY_METRIC_BOUNDS | |
| 254 DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 260 DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
| 255 } | 261 } |
| 256 | 262 |
| 257 if (delegate_) | 263 if (delegate_) |
| 258 delegate_->PostDisplayConfigurationChange(false); | 264 delegate_->PostDisplayConfigurationChange(false); |
| 259 } | 265 } |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 const DisplayLayout& layout = layout_store_->GetRegisteredDisplayLayout( | 1379 const DisplayLayout& layout = layout_store_->GetRegisteredDisplayLayout( |
| 1374 CreateDisplayIdList(*display_list)); | 1380 CreateDisplayIdList(*display_list)); |
| 1375 | 1381 |
| 1376 // Ignore if a user has a old format (should be extremely rare) | 1382 // Ignore if a user has a old format (should be extremely rare) |
| 1377 // and this will be replaced with DCHECK. | 1383 // and this will be replaced with DCHECK. |
| 1378 if (layout.primary_id == kInvalidDisplayId) | 1384 if (layout.primary_id == kInvalidDisplayId) |
| 1379 return; | 1385 return; |
| 1380 | 1386 |
| 1381 // display_list does not have translation set, so ApplyDisplayLayout cannot | 1387 // display_list does not have translation set, so ApplyDisplayLayout cannot |
| 1382 // provide accurate change information. We'll find the changes after the call. | 1388 // provide accurate change information. We'll find the changes after the call. |
| 1383 ApplyDisplayLayout(layout, display_list, nullptr); | 1389 current_resolved_layout_ = layout.Copy(); |
| 1390 ApplyDisplayLayout(current_resolved_layout_.get(), display_list, nullptr); |
| 1384 size_t num_displays = display_list->size(); | 1391 size_t num_displays = display_list->size(); |
| 1385 for (size_t index = 0; index < num_displays; ++index) { | 1392 for (size_t index = 0; index < num_displays; ++index) { |
| 1386 const Display& display = (*display_list)[index]; | 1393 const Display& display = (*display_list)[index]; |
| 1387 int64_t id = display.id(); | 1394 int64_t id = display.id(); |
| 1388 const Display* active_display = FindDisplayForId(id); | 1395 const Display* active_display = FindDisplayForId(id); |
| 1389 if (!active_display || (active_display->bounds() != display.bounds())) | 1396 if (!active_display || (active_display->bounds() != display.bounds())) |
| 1390 updated_indices->push_back(index); | 1397 updated_indices->push_back(index); |
| 1391 } | 1398 } |
| 1392 } | 1399 } |
| 1393 | 1400 |
| 1394 void DisplayManager::CreateMirrorWindowIfAny() { | 1401 void DisplayManager::CreateMirrorWindowIfAny() { |
| 1395 if (software_mirroring_display_list_.empty() || !delegate_) | 1402 if (software_mirroring_display_list_.empty() || !delegate_) |
| 1396 return; | 1403 return; |
| 1397 DisplayInfoList list; | 1404 DisplayInfoList list; |
| 1398 for (auto& display : software_mirroring_display_list_) | 1405 for (auto& display : software_mirroring_display_list_) |
| 1399 list.push_back(GetDisplayInfo(display.id())); | 1406 list.push_back(GetDisplayInfo(display.id())); |
| 1400 delegate_->CreateOrUpdateMirroringDisplay(list); | 1407 delegate_->CreateOrUpdateMirroringDisplay(list); |
| 1401 } | 1408 } |
| 1402 | 1409 |
| 1403 void DisplayManager::ApplyDisplayLayout(const DisplayLayout& layout, | 1410 void DisplayManager::ApplyDisplayLayout(DisplayLayout* layout, |
| 1404 Displays* display_list, | 1411 Displays* display_list, |
| 1405 std::vector<int64_t>* updated_ids) { | 1412 std::vector<int64_t>* updated_ids) { |
| 1406 layout.ApplyToDisplayList(display_list, updated_ids, | 1413 if (multi_display_mode_ == UNIFIED) { |
| 1407 kMinimumOverlapForInvalidOffset); | 1414 // Applying the layout in unified mode doesn't make sense, since there's no |
| 1415 // layout. |
| 1416 return; |
| 1417 } |
| 1418 |
| 1419 layout->ApplyToDisplayList(display_list, updated_ids, |
| 1420 kMinimumOverlapForInvalidOffset); |
| 1408 } | 1421 } |
| 1409 | 1422 |
| 1410 void DisplayManager::RunPendingTasksForTest() { | 1423 void DisplayManager::RunPendingTasksForTest() { |
| 1411 if (!software_mirroring_display_list_.empty()) | 1424 if (!software_mirroring_display_list_.empty()) |
| 1412 base::RunLoop().RunUntilIdle(); | 1425 base::RunLoop().RunUntilIdle(); |
| 1413 } | 1426 } |
| 1414 | 1427 |
| 1415 void DisplayManager::NotifyMetricsChanged(const Display& display, | 1428 void DisplayManager::NotifyMetricsChanged(const Display& display, |
| 1416 uint32_t metrics) { | 1429 uint32_t metrics) { |
| 1417 for (auto& observer : observers_) | 1430 for (auto& observer : observers_) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1437 } | 1450 } |
| 1438 | 1451 |
| 1439 const Display& DisplayManager::GetSecondaryDisplay() const { | 1452 const Display& DisplayManager::GetSecondaryDisplay() const { |
| 1440 CHECK_LE(2U, GetNumDisplays()); | 1453 CHECK_LE(2U, GetNumDisplays()); |
| 1441 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() | 1454 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() |
| 1442 ? GetDisplayAt(1) | 1455 ? GetDisplayAt(1) |
| 1443 : GetDisplayAt(0); | 1456 : GetDisplayAt(0); |
| 1444 } | 1457 } |
| 1445 | 1458 |
| 1446 } // namespace display | 1459 } // namespace display |
| OLD | NEW |