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

Side by Side Diff: ash/display/display_manager.cc

Issue 1631023002: Fix moving the mouse between two displays after the secondary display becomes primary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Rename UpdateDisplaysTo to UpdateDisplaysWith Created 4 years, 11 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 | « ash/display/display_manager.h ('k') | ash/display/extended_mouse_warp_controller.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 (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 "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } else { 317 } else {
318 info.set_clear_overscan_insets(false); 318 info.set_clear_overscan_insets(false);
319 info.SetOverscanInsets(insets_in_dip); 319 info.SetOverscanInsets(insets_in_dip);
320 } 320 }
321 update = true; 321 update = true;
322 } 322 }
323 display_info_list.push_back(info); 323 display_info_list.push_back(info);
324 } 324 }
325 if (update) { 325 if (update) {
326 AddMirrorDisplayInfoIfAny(&display_info_list); 326 AddMirrorDisplayInfoIfAny(&display_info_list);
327 UpdateDisplays(display_info_list); 327 UpdateDisplaysWith(display_info_list);
328 } else { 328 } else {
329 display_info_[display_id].SetOverscanInsets(insets_in_dip); 329 display_info_[display_id].SetOverscanInsets(insets_in_dip);
330 } 330 }
331 } 331 }
332 332
333 void DisplayManager::SetDisplayRotation(int64_t display_id, 333 void DisplayManager::SetDisplayRotation(int64_t display_id,
334 gfx::Display::Rotation rotation, 334 gfx::Display::Rotation rotation,
335 gfx::Display::RotationSource source) { 335 gfx::Display::RotationSource source) {
336 if (IsInUnifiedMode()) 336 if (IsInUnifiedMode())
337 return; 337 return;
338 338
339 DisplayInfoList display_info_list; 339 DisplayInfoList display_info_list;
340 bool is_active = false; 340 bool is_active = false;
341 for (const auto& display : active_display_list_) { 341 for (const auto& display : active_display_list_) {
342 DisplayInfo info = GetDisplayInfo(display.id()); 342 DisplayInfo info = GetDisplayInfo(display.id());
343 if (info.id() == display_id) { 343 if (info.id() == display_id) {
344 if (info.GetRotation(source) == rotation && 344 if (info.GetRotation(source) == rotation &&
345 info.GetActiveRotation() == rotation) { 345 info.GetActiveRotation() == rotation) {
346 return; 346 return;
347 } 347 }
348 info.SetRotation(rotation, source); 348 info.SetRotation(rotation, source);
349 is_active = true; 349 is_active = true;
350 } 350 }
351 display_info_list.push_back(info); 351 display_info_list.push_back(info);
352 } 352 }
353 if (is_active) { 353 if (is_active) {
354 AddMirrorDisplayInfoIfAny(&display_info_list); 354 AddMirrorDisplayInfoIfAny(&display_info_list);
355 UpdateDisplays(display_info_list); 355 UpdateDisplaysWith(display_info_list);
356 } else if (display_info_.find(display_id) != display_info_.end()) { 356 } else if (display_info_.find(display_id) != display_info_.end()) {
357 // Inactive displays can reactivate, ensure they have been updated. 357 // Inactive displays can reactivate, ensure they have been updated.
358 display_info_[display_id].SetRotation(rotation, source); 358 display_info_[display_id].SetRotation(rotation, source);
359 } 359 }
360 } 360 }
361 361
362 bool DisplayManager::SetDisplayMode(int64_t display_id, 362 bool DisplayManager::SetDisplayMode(int64_t display_id,
363 const DisplayMode& display_mode) { 363 const DisplayMode& display_mode) {
364 bool change_ui_scale = GetDisplayIdForUIScaling() == display_id; 364 bool change_ui_scale = GetDisplayIdForUIScaling() == display_id;
365 365
(...skipping 24 matching lines...) Expand all
390 if (info.device_scale_factor() != display_mode.device_scale_factor) { 390 if (info.device_scale_factor() != display_mode.device_scale_factor) {
391 info.set_device_scale_factor(display_mode.device_scale_factor); 391 info.set_device_scale_factor(display_mode.device_scale_factor);
392 display_property_changed = true; 392 display_property_changed = true;
393 } 393 }
394 } 394 }
395 } 395 }
396 display_info_list.push_back(info); 396 display_info_list.push_back(info);
397 } 397 }
398 if (display_property_changed) { 398 if (display_property_changed) {
399 AddMirrorDisplayInfoIfAny(&display_info_list); 399 AddMirrorDisplayInfoIfAny(&display_info_list);
400 UpdateDisplays(display_info_list); 400 UpdateDisplaysWith(display_info_list);
401 } 401 }
402 if (resolution_changed && IsInUnifiedMode()) { 402 if (resolution_changed && IsInUnifiedMode()) {
403 ReconfigureDisplays(); 403 ReconfigureDisplays();
404 #if defined(OS_CHROMEOS) 404 #if defined(OS_CHROMEOS)
405 } else if (resolution_changed && base::SysInfo::IsRunningOnChromeOS()) { 405 } else if (resolution_changed && base::SysInfo::IsRunningOnChromeOS()) {
406 Shell::GetInstance()->display_configurator()->OnConfigurationChanged(); 406 Shell::GetInstance()->display_configurator()->OnConfigurationChanged();
407 #endif 407 #endif
408 } 408 }
409 return resolution_changed || display_property_changed; 409 return resolution_changed || display_property_changed;
410 } 410 }
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 DisplayIdPair pair = CreateDisplayIdPair(new_display_info_list[0].id(), 625 DisplayIdPair pair = CreateDisplayIdPair(new_display_info_list[0].id(),
626 new_display_info_list[1].id()); 626 new_display_info_list[1].id());
627 DisplayLayout layout = layout_store_->GetRegisteredDisplayLayout(pair); 627 DisplayLayout layout = layout_store_->GetRegisteredDisplayLayout(pair);
628 // Mirror mode is set by DisplayConfigurator on the device. 628 // Mirror mode is set by DisplayConfigurator on the device.
629 // Emulate it when running on linux desktop. 629 // Emulate it when running on linux desktop.
630 if (layout.mirrored) 630 if (layout.mirrored)
631 SetMultiDisplayMode(MIRRORING); 631 SetMultiDisplayMode(MIRRORING);
632 } 632 }
633 #endif 633 #endif
634 634
635 UpdateDisplays(new_display_info_list); 635 UpdateDisplaysWith(new_display_info_list);
636 } 636 }
637 637
638 void DisplayManager::UpdateDisplays() { 638 void DisplayManager::UpdateDisplays() {
639 DisplayInfoList display_info_list; 639 DisplayInfoList display_info_list;
640 for (const auto& display : active_display_list_) 640 for (const auto& display : active_display_list_)
641 display_info_list.push_back(GetDisplayInfo(display.id())); 641 display_info_list.push_back(GetDisplayInfo(display.id()));
642 AddMirrorDisplayInfoIfAny(&display_info_list); 642 AddMirrorDisplayInfoIfAny(&display_info_list);
643 UpdateDisplays(display_info_list); 643 UpdateDisplaysWith(display_info_list);
644 } 644 }
645 645
646 void DisplayManager::UpdateDisplays( 646 void DisplayManager::UpdateDisplaysWith(
647 const std::vector<DisplayInfo>& updated_display_info_list) { 647 const std::vector<DisplayInfo>& updated_display_info_list) {
648 #if defined(OS_WIN) 648 #if defined(OS_WIN)
649 DCHECK_EQ(1u, updated_display_info_list.size()) << 649 DCHECK_EQ(1u, updated_display_info_list.size()) <<
650 ": Multiple display test does not work on Windows bots. Please " 650 ": Multiple display test does not work on Windows bots. Please "
651 "skip (don't disable) the test using SupportsMultipleDisplays()"; 651 "skip (don't disable) the test using SupportsMultipleDisplays()";
652 #endif 652 #endif
653 653
654 DisplayInfoList new_display_info_list = updated_display_info_list; 654 DisplayInfoList new_display_info_list = updated_display_info_list;
655 std::sort(active_display_list_.begin(), active_display_list_.end(), 655 std::sort(active_display_list_.begin(), active_display_list_.end(),
656 DisplaySortFunctor()); 656 DisplaySortFunctor());
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 // Layout the 2nd display below the primary as with the real device. 964 // Layout the 2nd display below the primary as with the real device.
965 gfx::Rect host_bounds = first_display.bounds_in_native(); 965 gfx::Rect host_bounds = first_display.bounds_in_native();
966 new_display_info_list.push_back( 966 new_display_info_list.push_back(
967 DisplayInfo::CreateFromSpec(base::StringPrintf( 967 DisplayInfo::CreateFromSpec(base::StringPrintf(
968 "%d+%d-600x%d", host_bounds.x(), 968 "%d+%d-600x%d", host_bounds.x(),
969 host_bounds.bottom() + kVerticalOffsetPx, host_bounds.height()))); 969 host_bounds.bottom() + kVerticalOffsetPx, host_bounds.height())));
970 } 970 }
971 num_connected_displays_ = new_display_info_list.size(); 971 num_connected_displays_ = new_display_info_list.size();
972 mirroring_display_id_ = gfx::Display::kInvalidDisplayID; 972 mirroring_display_id_ = gfx::Display::kInvalidDisplayID;
973 software_mirroring_display_list_.clear(); 973 software_mirroring_display_list_.clear();
974 UpdateDisplays(new_display_info_list); 974 UpdateDisplaysWith(new_display_info_list);
975 } 975 }
976 976
977 void DisplayManager::ToggleDisplayScaleFactor() { 977 void DisplayManager::ToggleDisplayScaleFactor() {
978 DCHECK(!active_display_list_.empty()); 978 DCHECK(!active_display_list_.empty());
979 std::vector<DisplayInfo> new_display_info_list; 979 std::vector<DisplayInfo> new_display_info_list;
980 for (DisplayList::const_iterator iter = active_display_list_.begin(); 980 for (DisplayList::const_iterator iter = active_display_list_.begin();
981 iter != active_display_list_.end(); ++iter) { 981 iter != active_display_list_.end(); ++iter) {
982 DisplayInfo display_info = GetDisplayInfo(iter->id()); 982 DisplayInfo display_info = GetDisplayInfo(iter->id());
983 display_info.set_device_scale_factor( 983 display_info.set_device_scale_factor(
984 display_info.device_scale_factor() == 1.0f ? 2.0f : 1.0f); 984 display_info.device_scale_factor() == 1.0f ? 2.0f : 1.0f);
985 new_display_info_list.push_back(display_info); 985 new_display_info_list.push_back(display_info);
986 } 986 }
987 AddMirrorDisplayInfoIfAny(&new_display_info_list); 987 AddMirrorDisplayInfoIfAny(&new_display_info_list);
988 UpdateDisplays(new_display_info_list); 988 UpdateDisplaysWith(new_display_info_list);
989 } 989 }
990 990
991 #if defined(OS_CHROMEOS) 991 #if defined(OS_CHROMEOS)
992 void DisplayManager::SetSoftwareMirroring(bool enabled) { 992 void DisplayManager::SetSoftwareMirroring(bool enabled) {
993 SetMultiDisplayMode(enabled ? MIRRORING 993 SetMultiDisplayMode(enabled ? MIRRORING
994 : current_default_multi_display_mode_); 994 : current_default_multi_display_mode_);
995 } 995 }
996 996
997 bool DisplayManager::SoftwareMirroringEnabled() const { 997 bool DisplayManager::SoftwareMirroringEnabled() const {
998 return software_mirroring_enabled(); 998 return software_mirroring_enabled();
(...skipping 19 matching lines...) Expand all
1018 DisplayInfoList display_info_list; 1018 DisplayInfoList display_info_list;
1019 for (const gfx::Display& display : active_display_list_) { 1019 for (const gfx::Display& display : active_display_list_) {
1020 if (display.id() == kUnifiedDisplayId) 1020 if (display.id() == kUnifiedDisplayId)
1021 continue; 1021 continue;
1022 display_info_list.push_back(GetDisplayInfo(display.id())); 1022 display_info_list.push_back(GetDisplayInfo(display.id()));
1023 } 1023 }
1024 for (const gfx::Display& display : software_mirroring_display_list_) 1024 for (const gfx::Display& display : software_mirroring_display_list_)
1025 display_info_list.push_back(GetDisplayInfo(display.id())); 1025 display_info_list.push_back(GetDisplayInfo(display.id()));
1026 mirroring_display_id_ = gfx::Display::kInvalidDisplayID; 1026 mirroring_display_id_ = gfx::Display::kInvalidDisplayID;
1027 software_mirroring_display_list_.clear(); 1027 software_mirroring_display_list_.clear();
1028 UpdateDisplays(display_info_list); 1028 UpdateDisplaysWith(display_info_list);
1029 } 1029 }
1030 1030
1031 bool DisplayManager::UpdateDisplayBounds(int64_t display_id, 1031 bool DisplayManager::UpdateDisplayBounds(int64_t display_id,
1032 const gfx::Rect& new_bounds) { 1032 const gfx::Rect& new_bounds) {
1033 if (change_display_upon_host_resize_) { 1033 if (change_display_upon_host_resize_) {
1034 display_info_[display_id].SetBounds(new_bounds); 1034 display_info_[display_id].SetBounds(new_bounds);
1035 // Don't notify observers if the mirrored window has changed. 1035 // Don't notify observers if the mirrored window has changed.
1036 if (software_mirroring_enabled() && mirroring_display_id_ == display_id) 1036 if (software_mirroring_enabled() && mirroring_display_id_ == display_id)
1037 return false; 1037 return false;
1038 gfx::Display* display = FindDisplayForId(display_id); 1038 gfx::Display* display = FindDisplayForId(display_id);
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1400 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1401 secondary_display->UpdateWorkAreaFromInsets(insets); 1401 secondary_display->UpdateWorkAreaFromInsets(insets);
1402 } 1402 }
1403 1403
1404 void DisplayManager::RunPendingTasksForTest() { 1404 void DisplayManager::RunPendingTasksForTest() {
1405 if (!software_mirroring_display_list_.empty()) 1405 if (!software_mirroring_display_list_.empty())
1406 base::RunLoop().RunUntilIdle(); 1406 base::RunLoop().RunUntilIdle();
1407 } 1407 }
1408 1408
1409 } // namespace ash 1409 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager.h ('k') | ash/display/extended_mouse_warp_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698