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

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

Issue 12438016: Save display preference when all display configuration changes has been completed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: replace dcheck Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/display_controller.h ('k') | ash/display/display_controller_unittest.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 (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_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 450 }
451 451
452 void DisplayController::SetDefaultDisplayLayout(const DisplayLayout& layout) { 452 void DisplayController::SetDefaultDisplayLayout(const DisplayLayout& layout) {
453 CommandLine* command_line = CommandLine::ForCurrentProcess(); 453 CommandLine* command_line = CommandLine::ForCurrentProcess();
454 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout) && 454 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout) &&
455 (default_display_layout_.position != layout.position || 455 (default_display_layout_.position != layout.position ||
456 default_display_layout_.offset != layout.offset)) { 456 default_display_layout_.offset != layout.offset)) {
457 default_display_layout_ = layout; 457 default_display_layout_ = layout;
458 NotifyDisplayConfigurationChanging(); 458 NotifyDisplayConfigurationChanging();
459 UpdateDisplayBoundsForLayout(); 459 UpdateDisplayBoundsForLayout();
460 NotifyDisplayConfigurationChanged();
460 } 461 }
461 } 462 }
462 463
463 void DisplayController::RegisterLayoutForDisplayIdPair( 464 void DisplayController::RegisterLayoutForDisplayIdPair(
464 int64 id1, 465 int64 id1,
465 int64 id2, 466 int64 id2,
466 const DisplayLayout& layout) { 467 const DisplayLayout& layout) {
467 RegisterLayoutForDisplayIdPairInternal(id1, id2, layout, true); 468 RegisterLayoutForDisplayIdPairInternal(id1, id2, layout, true);
468 } 469 }
469 470
(...skipping 21 matching lines...) Expand all
491 // Invert if the primary was swapped. 492 // Invert if the primary was swapped.
492 DisplayLayout to_set = pair.first == primary.id() ? 493 DisplayLayout to_set = pair.first == primary.id() ?
493 layout_relative_to_primary : layout_relative_to_primary.Invert(); 494 layout_relative_to_primary : layout_relative_to_primary.Invert();
494 495
495 const DisplayLayout& current_layout = paired_layouts_[pair]; 496 const DisplayLayout& current_layout = paired_layouts_[pair];
496 if (to_set.position != current_layout.position || 497 if (to_set.position != current_layout.position ||
497 to_set.offset != current_layout.offset) { 498 to_set.offset != current_layout.offset) {
498 paired_layouts_[pair] = to_set; 499 paired_layouts_[pair] = to_set;
499 NotifyDisplayConfigurationChanging(); 500 NotifyDisplayConfigurationChanging();
500 UpdateDisplayBoundsForLayout(); 501 UpdateDisplayBoundsForLayout();
502 NotifyDisplayConfigurationChanged();
501 } 503 }
502 } 504 }
503 505
504 DisplayLayout DisplayController::GetCurrentDisplayLayout() const { 506 DisplayLayout DisplayController::GetCurrentDisplayLayout() const {
505 DCHECK_EQ(2U, GetDisplayManager()->GetNumDisplays()); 507 DCHECK_EQ(2U, GetDisplayManager()->GetNumDisplays());
506 // Invert if the primary was swapped. 508 // Invert if the primary was swapped.
507 if (GetDisplayManager()->GetNumDisplays() > 1) { 509 if (GetDisplayManager()->GetNumDisplays() > 1) {
508 DisplayIdPair pair = GetCurrentDisplayIdPair(); 510 DisplayIdPair pair = GetCurrentDisplayIdPair();
509 DisplayLayout layout = GetRegisteredDisplayLayout(pair); 511 DisplayLayout layout = GetRegisteredDisplayLayout(pair);
510 const gfx::Display& primary = GetPrimaryDisplay(); 512 const gfx::Display& primary = GetPrimaryDisplay();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); 665 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0);
664 } 666 }
665 667
666 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { 668 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
667 if (limiter_.get()) 669 if (limiter_.get())
668 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); 670 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs);
669 const internal::DisplayInfo& display_info = 671 const internal::DisplayInfo& display_info =
670 GetDisplayManager()->GetDisplayInfo(display); 672 GetDisplayManager()->GetDisplayInfo(display);
671 DCHECK(!display_info.bounds_in_pixel().IsEmpty()); 673 DCHECK(!display_info.bounds_in_pixel().IsEmpty());
672 674
673 NotifyDisplayConfigurationChanging();
674 UpdateDisplayBoundsForLayout(); 675 UpdateDisplayBoundsForLayout();
675 aura::RootWindow* root = root_windows_[display.id()]; 676 aura::RootWindow* root = root_windows_[display.id()];
676 root->SetHostBoundsAndInsetsAndRootWindowScale( 677 root->SetHostBoundsAndInsetsAndRootWindowScale(
677 display_info.bounds_in_pixel(), 678 display_info.bounds_in_pixel(),
678 display_info.GetOverscanInsetsInPixel(), 679 display_info.GetOverscanInsetsInPixel(),
679 display_info.ui_scale()); 680 display_info.ui_scale());
680 SetDisplayPropertiesOnHostWindow(root, display); 681 SetDisplayPropertiesOnHostWindow(root, display);
681 } 682 }
682 683
683 void DisplayController::OnDisplayAdded(const gfx::Display& display) { 684 void DisplayController::OnDisplayAdded(const gfx::Display& display) {
684 if (limiter_.get()) 685 if (limiter_.get())
685 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); 686 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs);
686 687
687 NotifyDisplayConfigurationChanging();
688 if (primary_root_window_for_replace_) { 688 if (primary_root_window_for_replace_) {
689 DCHECK(root_windows_.empty()); 689 DCHECK(root_windows_.empty());
690 primary_display_id = display.id(); 690 primary_display_id = display.id();
691 root_windows_[display.id()] = primary_root_window_for_replace_; 691 root_windows_[display.id()] = primary_root_window_for_replace_;
692 primary_root_window_for_replace_->SetProperty( 692 primary_root_window_for_replace_->SetProperty(
693 internal::kDisplayIdKey, display.id()); 693 internal::kDisplayIdKey, display.id());
694 primary_root_window_for_replace_ = NULL; 694 primary_root_window_for_replace_ = NULL;
695 UpdateDisplayBoundsForLayout(); 695 UpdateDisplayBoundsForLayout();
696 const internal::DisplayInfo& display_info = 696 const internal::DisplayInfo& display_info =
697 GetDisplayManager()->GetDisplayInfo(display); 697 GetDisplayManager()->GetDisplayInfo(display);
(...skipping 10 matching lines...) Expand all
708 Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root); 708 Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root);
709 } 709 }
710 } 710 }
711 711
712 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { 712 void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
713 if (limiter_.get()) 713 if (limiter_.get())
714 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); 714 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs);
715 715
716 aura::RootWindow* root_to_delete = root_windows_[display.id()]; 716 aura::RootWindow* root_to_delete = root_windows_[display.id()];
717 DCHECK(root_to_delete) << display.ToString(); 717 DCHECK(root_to_delete) << display.ToString();
718 NotifyDisplayConfigurationChanging();
719 718
720 // Display for root window will be deleted when the Primary RootWindow 719 // Display for root window will be deleted when the Primary RootWindow
721 // is deleted by the Shell. 720 // is deleted by the Shell.
722 root_windows_.erase(display.id()); 721 root_windows_.erase(display.id());
723 722
724 // When the primary root window's display is removed, move the primary 723 // When the primary root window's display is removed, move the primary
725 // root to the other display. 724 // root to the other display.
726 if (primary_display_id == display.id()) { 725 if (primary_display_id == display.id()) {
727 // Temporarily store the primary root window in 726 // Temporarily store the primary root window in
728 // |primary_root_window_for_replace_| when replacing the display. 727 // |primary_root_window_for_replace_| when replacing the display.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 838 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
840 secondary_display->set_bounds( 839 secondary_display->set_bounds(
841 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 840 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
842 secondary_display->UpdateWorkAreaFromInsets(insets); 841 secondary_display->UpdateWorkAreaFromInsets(insets);
843 } 842 }
844 843
845 void DisplayController::NotifyDisplayConfigurationChanging() { 844 void DisplayController::NotifyDisplayConfigurationChanging() {
846 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); 845 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging());
847 } 846 }
848 847
848 void DisplayController::NotifyDisplayConfigurationChanged() {
849 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged());
850 }
851
849 void DisplayController::RegisterLayoutForDisplayIdPairInternal( 852 void DisplayController::RegisterLayoutForDisplayIdPairInternal(
850 int64 id1, 853 int64 id1,
851 int64 id2, 854 int64 id2,
852 const DisplayLayout& layout, 855 const DisplayLayout& layout,
853 bool override) { 856 bool override) {
854 DisplayIdPair pair; 857 DisplayIdPair pair;
855 pair.first = id1; 858 pair.first = id1;
856 pair.second = id2; 859 pair.second = id2;
857 if (override || paired_layouts_.find(pair) == paired_layouts_.end()) 860 if (override || paired_layouts_.find(pair) == paired_layouts_.end())
858 paired_layouts_[pair] = layout; 861 paired_layouts_[pair] = layout;
859 } 862 }
860 863
861 void DisplayController::OnFadeOutForSwapDisplayFinished() { 864 void DisplayController::OnFadeOutForSwapDisplayFinished() {
862 #if defined(OS_CHROMEOS) 865 #if defined(OS_CHROMEOS)
863 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); 866 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay());
864 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); 867 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation();
865 #endif 868 #endif
866 } 869 }
867 870
868 } // namespace ash 871 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller.h ('k') | ash/display/display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698