Chromium Code Reviews| 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 "ash/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 host->compositor()->vsync_manager()->SetAuthoritativeVSyncInterval( | 153 host->compositor()->vsync_manager()->SetAuthoritativeVSyncInterval( |
| 154 base::TimeDelta::FromMicroseconds( | 154 base::TimeDelta::FromMicroseconds( |
| 155 base::Time::kMicrosecondsPerSecond / mode.refresh_rate)); | 155 base::Time::kMicrosecondsPerSecond / mode.refresh_rate)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // Just movnig the display requires the full redraw. | 158 // Just movnig the display requires the full redraw. |
| 159 // chrome-os-partner:33558. | 159 // chrome-os-partner:33558. |
| 160 host->compositor()->ScheduleFullRedraw(); | 160 host->compositor()->ScheduleFullRedraw(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ClearDisplayPropertiesOnHost(AshWindowTreeHost* ash_host, | 163 void ClearDisplayPropertiesOnHost(AshWindowTreeHost* ash_host) { |
| 164 const gfx::Display& display) { | |
| 165 #if defined(OS_CHROMEOS) && defined(USE_OZONE) | 164 #if defined(OS_CHROMEOS) && defined(USE_OZONE) |
| 166 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 165 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
| 167 ui::CursorController::GetInstance()->ClearCursorConfigForWindow( | 166 ui::CursorController::GetInstance()->ClearCursorConfigForWindow( |
| 168 host->GetAcceleratedWidget()); | 167 host->GetAcceleratedWidget()); |
| 169 #endif | 168 #endif |
| 170 } | 169 } |
| 171 | 170 |
| 172 aura::Window* GetWindow(AshWindowTreeHost* ash_host) { | 171 aura::Window* GetWindow(AshWindowTreeHost* ash_host) { |
| 173 CHECK(ash_host->AsWindowTreeHost()); | 172 CHECK(ash_host->AsWindowTreeHost()); |
| 174 return ash_host->AsWindowTreeHost()->window(); | 173 return ash_host->AsWindowTreeHost()->window(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 const gfx::Display& primary_candidate = | 322 const gfx::Display& primary_candidate = |
| 324 GetDisplayManager()->GetPrimaryDisplayCandidate(); | 323 GetDisplayManager()->GetPrimaryDisplayCandidate(); |
| 325 primary_display_id = primary_candidate.id(); | 324 primary_display_id = primary_candidate.id(); |
| 326 CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); | 325 CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); |
| 327 AddWindowTreeHostForDisplay(primary_candidate, init_params); | 326 AddWindowTreeHostForDisplay(primary_candidate, init_params); |
| 328 } | 327 } |
| 329 | 328 |
| 330 void DisplayController::InitDisplays() { | 329 void DisplayController::InitDisplays() { |
| 331 RootWindowController::CreateForPrimaryDisplay( | 330 RootWindowController::CreateForPrimaryDisplay( |
| 332 window_tree_hosts_[primary_display_id]); | 331 window_tree_hosts_[primary_display_id]); |
| 333 | |
| 334 DisplayManager* display_manager = GetDisplayManager(); | 332 DisplayManager* display_manager = GetDisplayManager(); |
| 335 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 333 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 336 const gfx::Display& display = display_manager->GetDisplayAt(i); | 334 const gfx::Display& display = display_manager->GetDisplayAt(i); |
| 337 if (primary_display_id != display.id()) { | 335 if (primary_display_id != display.id()) { |
| 338 AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay( | 336 AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay( |
| 339 display, AshWindowTreeHostInitParams()); | 337 display, AshWindowTreeHostInitParams()); |
| 340 RootWindowController::CreateForSecondaryDisplay(ash_host); | 338 RootWindowController::CreateForSecondaryDisplay(ash_host); |
| 341 } | 339 } |
| 342 } | 340 } |
| 343 | 341 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 356 int64 DisplayController::GetPrimaryDisplayId() { | 354 int64 DisplayController::GetPrimaryDisplayId() { |
| 357 CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); | 355 CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); |
| 358 return primary_display_id; | 356 return primary_display_id; |
| 359 } | 357 } |
| 360 | 358 |
| 361 aura::Window* DisplayController::GetPrimaryRootWindow() { | 359 aura::Window* DisplayController::GetPrimaryRootWindow() { |
| 362 return GetRootWindowForDisplayId(primary_display_id); | 360 return GetRootWindowForDisplayId(primary_display_id); |
| 363 } | 361 } |
| 364 | 362 |
| 365 aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { | 363 aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { |
| 366 CHECK_EQ(1u, window_tree_hosts_.count(id)); | 364 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); |
| 367 AshWindowTreeHost* host = window_tree_hosts_[id]; | |
| 368 CHECK(host); | 365 CHECK(host); |
| 369 return GetWindow(host); | 366 return GetWindow(host); |
| 370 } | 367 } |
| 371 | 368 |
| 369 AshWindowTreeHost* DisplayController::GetAshWindowTreeHostForDisplayId( | |
| 370 int64 id) { | |
| 371 CHECK_EQ(1u, window_tree_hosts_.count(id)); | |
| 372 return window_tree_hosts_[id]; | |
| 373 } | |
| 374 | |
| 372 void DisplayController::CloseChildWindows() { | 375 void DisplayController::CloseChildWindows() { |
| 373 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); | 376 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); |
| 374 it != window_tree_hosts_.end(); | 377 it != window_tree_hosts_.end(); |
| 375 ++it) { | 378 ++it) { |
| 376 aura::Window* root_window = GetWindow(it->second); | 379 aura::Window* root_window = GetWindow(it->second); |
| 377 RootWindowController* controller = GetRootWindowController(root_window); | 380 RootWindowController* controller = GetRootWindowController(root_window); |
| 378 if (controller) { | 381 if (controller) { |
| 379 controller->CloseChildWindows(); | 382 controller->CloseChildWindows(); |
| 380 } else { | 383 } else { |
| 381 while (!root_window->children().empty()) { | 384 while (!root_window->children().empty()) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 const aura::Window* window, | 625 const aura::Window* window, |
| 623 const gfx::Insets& insets) { | 626 const gfx::Insets& insets) { |
| 624 const aura::Window* root_window = window->GetRootWindow(); | 627 const aura::Window* root_window = window->GetRootWindow(); |
| 625 int64 id = GetRootWindowSettings(root_window)->display_id; | 628 int64 id = GetRootWindowSettings(root_window)->display_id; |
| 626 // if id is |kInvaildDisplayID|, it's being deleted. | 629 // if id is |kInvaildDisplayID|, it's being deleted. |
| 627 DCHECK(id != gfx::Display::kInvalidDisplayID); | 630 DCHECK(id != gfx::Display::kInvalidDisplayID); |
| 628 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); | 631 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); |
| 629 } | 632 } |
| 630 | 633 |
| 631 void DisplayController::OnDisplayAdded(const gfx::Display& display) { | 634 void DisplayController::OnDisplayAdded(const gfx::Display& display) { |
| 632 if (primary_tree_host_for_replace_) { | 635 // TODO(oshima): Consolidate these logic. |
| 633 DCHECK(window_tree_hosts_.empty()); | 636 if (GetDisplayManager()->IsInUnifiedMode()) { |
| 634 primary_display_id = display.id(); | |
| 635 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_; | |
| 636 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) | |
| 637 ->display_id = display.id(); | |
| 638 primary_tree_host_for_replace_ = NULL; | |
| 639 const DisplayInfo& display_info = | |
| 640 GetDisplayManager()->GetDisplayInfo(display.id()); | |
| 641 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()]; | |
| 642 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native()); | |
| 643 SetDisplayPropertiesOnHost(ash_host, display); | |
| 644 } else { | |
| 645 if (primary_display_id == gfx::Display::kInvalidDisplayID) | 637 if (primary_display_id == gfx::Display::kInvalidDisplayID) |
| 646 primary_display_id = display.id(); | 638 primary_display_id = display.id(); |
| 647 DCHECK(!window_tree_hosts_.empty()); | |
| 648 AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay( | 639 AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay( |
| 649 display, AshWindowTreeHostInitParams()); | 640 display, AshWindowTreeHostInitParams()); |
| 650 RootWindowController::CreateForSecondaryDisplay(ash_host); | 641 RootWindowController::CreateForSecondaryDisplay(ash_host); |
| 642 | |
| 643 if (primary_tree_host_for_replace_) { | |
| 644 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_; | |
| 645 primary_tree_host_for_replace_ = NULL; | |
|
Jun Mukai
2015/04/26 23:45:07
nullptr
oshima
2015/04/27 17:48:38
Done.
| |
| 646 DeleteHost(to_delete); | |
| 647 // the host has already been removed from the window_tree_host_. | |
| 648 } | |
| 649 } else { | |
| 650 if (primary_tree_host_for_replace_) { | |
|
Jun Mukai
2015/04/26 23:45:07
why not else if?
oshima
2015/04/27 17:48:38
Done.
| |
| 651 DCHECK(window_tree_hosts_.empty()); | |
| 652 primary_display_id = display.id(); | |
| 653 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_; | |
| 654 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) | |
| 655 ->display_id = display.id(); | |
| 656 primary_tree_host_for_replace_ = NULL; | |
|
Jun Mukai
2015/04/26 23:45:07
nullptr
oshima
2015/04/27 17:48:38
Done.
| |
| 657 const DisplayInfo& display_info = | |
| 658 GetDisplayManager()->GetDisplayInfo(display.id()); | |
| 659 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()]; | |
| 660 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native()); | |
| 661 SetDisplayPropertiesOnHost(ash_host, display); | |
| 662 } else { | |
| 663 if (primary_display_id == gfx::Display::kInvalidDisplayID) | |
| 664 primary_display_id = display.id(); | |
| 665 DCHECK(!window_tree_hosts_.empty()); | |
| 666 AshWindowTreeHost* ash_host = | |
| 667 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); | |
| 668 RootWindowController::CreateForSecondaryDisplay(ash_host); | |
| 669 } | |
| 651 } | 670 } |
| 652 } | 671 } |
| 653 | 672 |
| 673 void DisplayController::DeleteHost(AshWindowTreeHost* host_to_delete) { | |
| 674 ClearDisplayPropertiesOnHost(host_to_delete); | |
| 675 RootWindowController* controller = | |
| 676 GetRootWindowController(GetWindow(host_to_delete)); | |
| 677 DCHECK(controller); | |
| 678 controller->MoveWindowsTo(GetPrimaryRootWindow()); | |
| 679 // Delete most of root window related objects, but don't delete | |
| 680 // root window itself yet because the stack may be using it. | |
| 681 controller->Shutdown(); | |
| 682 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); | |
| 683 } | |
| 684 | |
| 654 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { | 685 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { |
| 655 AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()]; | 686 AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()]; |
| 656 CHECK(host_to_delete) << display.ToString(); | 687 CHECK(host_to_delete) << display.ToString(); |
| 657 | 688 |
| 658 // When the primary root window's display is removed, move the primary | 689 // When the primary root window's display is removed, move the primary |
| 659 // root to the other display. | 690 // root to the other display. |
| 660 if (primary_display_id == display.id()) { | 691 if (primary_display_id == display.id()) { |
| 661 // Temporarily store the primary root window in | 692 // Temporarily store the primary root window in |
| 662 // |primary_root_window_for_replace_| when replacing the display. | 693 // |primary_root_window_for_replace_| when replacing the display. |
| 663 if (window_tree_hosts_.size() == 1) { | 694 if (window_tree_hosts_.size() == 1) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 683 | 714 |
| 684 // Setup primary root. | 715 // Setup primary root. |
| 685 window_tree_hosts_[primary_display_id] = primary_host; | 716 window_tree_hosts_[primary_display_id] = primary_host; |
| 686 GetRootWindowSettings(GetWindow(primary_host))->display_id = | 717 GetRootWindowSettings(GetWindow(primary_host))->display_id = |
| 687 primary_display_id; | 718 primary_display_id; |
| 688 | 719 |
| 689 OnDisplayMetricsChanged( | 720 OnDisplayMetricsChanged( |
| 690 GetDisplayManager()->GetDisplayForId(primary_display_id), | 721 GetDisplayManager()->GetDisplayForId(primary_display_id), |
| 691 DISPLAY_METRIC_BOUNDS); | 722 DISPLAY_METRIC_BOUNDS); |
| 692 } | 723 } |
| 693 ClearDisplayPropertiesOnHost(host_to_delete, display); | 724 |
| 694 RootWindowController* controller = | 725 DeleteHost(host_to_delete); |
| 695 GetRootWindowController(GetWindow(host_to_delete)); | |
| 696 DCHECK(controller); | |
| 697 controller->MoveWindowsTo(GetPrimaryRootWindow()); | |
| 698 // Delete most of root window related objects, but don't delete | |
| 699 // root window itself yet because the stack may be using it. | |
| 700 controller->Shutdown(); | |
| 701 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); | |
| 702 | 726 |
| 703 // The window tree host should be erased at last because some handlers can | 727 // The window tree host should be erased at last because some handlers can |
| 704 // access to the host through GetRootWindowForDisplayId() during | 728 // access to the host through GetRootWindowForDisplayId() during |
| 705 // MoveWindowsTo(). See http://crbug.com/415222 | 729 // MoveWindowsTo(). See http://crbug.com/415222 |
| 706 window_tree_hosts_.erase(display.id()); | 730 window_tree_hosts_.erase(display.id()); |
| 707 } | 731 } |
| 708 | 732 |
| 709 void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display, | 733 void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display, |
| 710 uint32_t metrics) { | 734 uint32_t metrics) { |
| 711 if (!(metrics & (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_ROTATION | | 735 if (!(metrics & (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_ROTATION | |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 724 const_cast<aura::Window*>(host->window())); | 748 const_cast<aura::Window*>(host->window())); |
| 725 | 749 |
| 726 DisplayManager* display_manager = GetDisplayManager(); | 750 DisplayManager* display_manager = GetDisplayManager(); |
| 727 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { | 751 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { |
| 728 mirror_window_controller_->UpdateWindow(); | 752 mirror_window_controller_->UpdateWindow(); |
| 729 cursor_window_controller_->UpdateContainer(); | 753 cursor_window_controller_->UpdateContainer(); |
| 730 } | 754 } |
| 731 } | 755 } |
| 732 | 756 |
| 733 void DisplayController::CreateOrUpdateMirroringDisplay( | 757 void DisplayController::CreateOrUpdateMirroringDisplay( |
| 734 const DisplayInfo& info) { | 758 const DisplayInfoList& info_list) { |
| 735 switch (GetDisplayManager()->second_display_mode()) { | 759 switch (GetDisplayManager()->multi_display_mode()) { |
| 736 case DisplayManager::MIRRORING: | 760 case DisplayManager::MIRRORING: |
| 737 mirror_window_controller_->UpdateWindow(info); | 761 case DisplayManager::UNIFIED: |
| 762 mirror_window_controller_->UpdateWindow(info_list); | |
| 738 cursor_window_controller_->UpdateContainer(); | 763 cursor_window_controller_->UpdateContainer(); |
| 739 break; | 764 break; |
| 740 case DisplayManager::EXTENDED: | 765 case DisplayManager::EXTENDED: |
| 741 NOTREACHED(); | 766 NOTREACHED(); |
| 742 } | 767 } |
| 743 } | 768 } |
| 744 | 769 |
| 745 void DisplayController::CloseMirroringDisplay() { | 770 void DisplayController::CloseMirroringDisplay() { |
| 746 mirror_window_controller_->Close(); | 771 mirror_window_controller_->Close(); |
| 747 // If cursor_compositing is enabled for large cursor, the cursor window is | 772 // If cursor_compositing is enabled for large cursor, the cursor window is |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 773 if (limiter_) | 798 if (limiter_) |
| 774 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); | 799 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); |
| 775 | 800 |
| 776 focus_activation_store_->Restore(); | 801 focus_activation_store_->Restore(); |
| 777 | 802 |
| 778 DisplayManager* display_manager = GetDisplayManager(); | 803 DisplayManager* display_manager = GetDisplayManager(); |
| 779 DisplayLayoutStore* layout_store = display_manager->layout_store(); | 804 DisplayLayoutStore* layout_store = display_manager->layout_store(); |
| 780 if (display_manager->num_connected_displays() > 1) { | 805 if (display_manager->num_connected_displays() > 1) { |
| 781 DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); | 806 DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); |
| 782 layout_store->UpdateMirrorStatus(pair, display_manager->IsInMirrorMode()); | 807 layout_store->UpdateMirrorStatus(pair, display_manager->IsInMirrorMode()); |
| 783 DisplayLayout layout = layout_store->GetRegisteredDisplayLayout(pair); | |
| 784 | 808 |
| 785 if (Shell::GetScreen()->GetNumDisplays() > 1 ) { | 809 if (Shell::GetScreen()->GetNumDisplays() > 1 ) { |
| 810 DisplayLayout layout = layout_store->GetRegisteredDisplayLayout(pair); | |
| 786 int64 primary_id = layout.primary_id; | 811 int64 primary_id = layout.primary_id; |
| 787 SetPrimaryDisplayId( | 812 SetPrimaryDisplayId( |
| 788 primary_id == gfx::Display::kInvalidDisplayID ? | 813 primary_id == gfx::Display::kInvalidDisplayID ? |
| 789 pair.first : primary_id); | 814 pair.first : primary_id); |
| 790 // Update the primary_id in case the above call is | 815 // Update the primary_id in case the above call is |
| 791 // ignored. Happens when a) default layout's primary id | 816 // ignored. Happens when a) default layout's primary id |
| 792 // doesn't exist, or b) the primary_id has already been | 817 // doesn't exist, or b) the primary_id has already been |
| 793 // set to the same and didn't update it. | 818 // set to the same and didn't update it. |
| 794 layout_store->UpdatePrimaryDisplayId( | 819 layout_store->UpdatePrimaryDisplayId( |
| 795 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); | 820 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); |
| 796 } | 821 } |
| 797 } | 822 } |
| 798 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); | 823 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); |
| 799 UpdateMouseLocationAfterDisplayChange(); | 824 UpdateMouseLocationAfterDisplayChange(); |
| 800 } | 825 } |
| 801 | 826 |
| 802 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( | 827 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( |
| 803 const gfx::Display& display, | 828 const gfx::Display& display, |
| 804 const AshWindowTreeHostInitParams& init_params) { | 829 const AshWindowTreeHostInitParams& init_params) { |
| 805 static int host_count = 0; | 830 static int host_count = 0; |
| 806 const DisplayInfo& display_info = | 831 const DisplayInfo& display_info = |
| 807 GetDisplayManager()->GetDisplayInfo(display.id()); | 832 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 808 AshWindowTreeHostInitParams params_with_bounds(init_params); | 833 AshWindowTreeHostInitParams params_with_bounds(init_params); |
| 809 params_with_bounds.initial_bounds = display_info.bounds_in_native(); | 834 params_with_bounds.initial_bounds = display_info.bounds_in_native(); |
| 835 params_with_bounds.offscreen = | |
| 836 display.id() == DisplayManager::kUnifiedDisplayId; | |
| 810 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); | 837 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); |
| 811 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 838 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
| 812 | 839 |
| 813 host->window()->SetName(base::StringPrintf("RootWindow-%d", host_count++)); | 840 host->window()->SetName(base::StringPrintf( |
| 841 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", | |
| 842 host_count++)); | |
| 814 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); | 843 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); |
| 815 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 844 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
| 816 // No need to remove our observer observer because the DisplayController | 845 // No need to remove our observer observer because the DisplayController |
| 817 // outlives the host. | 846 // outlives the host. |
| 818 host->AddObserver(this); | 847 host->AddObserver(this); |
| 819 InitRootWindowSettings(host->window())->display_id = display.id(); | 848 InitRootWindowSettings(host->window())->display_id = display.id(); |
| 820 host->InitHost(); | 849 host->InitHost(); |
| 821 | 850 |
| 822 window_tree_hosts_[display.id()] = ash_host; | 851 window_tree_hosts_[display.id()] = ash_host; |
| 823 SetDisplayPropertiesOnHost(ash_host, display); | 852 SetDisplayPropertiesOnHost(ash_host, display); |
| 824 | 853 |
| 825 #if defined(OS_CHROMEOS) | 854 #if defined(OS_CHROMEOS) |
| 826 static bool force_constrain_pointer_to_root = | 855 if (switches::ConstrainPointerToRoot()) |
| 827 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 828 switches::kAshConstrainPointerToRoot); | |
| 829 if (base::SysInfo::IsRunningOnChromeOS() || force_constrain_pointer_to_root) | |
| 830 ash_host->ConfineCursorToRootWindow(); | 856 ash_host->ConfineCursorToRootWindow(); |
| 831 #endif | 857 #endif |
| 832 return ash_host; | 858 return ash_host; |
| 833 } | 859 } |
| 834 | 860 |
| 835 void DisplayController::OnFadeOutForSwapDisplayFinished() { | 861 void DisplayController::OnFadeOutForSwapDisplayFinished() { |
| 836 #if defined(OS_CHROMEOS) | 862 #if defined(OS_CHROMEOS) |
| 837 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); | 863 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); |
| 838 Shell::GetInstance()->display_configurator_animation() | 864 Shell::GetInstance()->display_configurator_animation() |
| 839 ->StartFadeInAnimation(); | 865 ->StartFadeInAnimation(); |
| 840 #endif | 866 #endif |
| 841 } | 867 } |
| 842 | 868 |
| 843 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { | 869 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { |
| 844 GetDisplayManager()->SetMirrorMode(mirror); | 870 GetDisplayManager()->SetMirrorMode(mirror); |
| 845 } | 871 } |
| 846 | 872 |
| 847 } // namespace ash | 873 } // namespace ash |
| OLD | NEW |