| Index: ash/display/display_controller.cc
|
| diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
|
| index 102f0d7068605013ea757d92358cf2a02d0e0c4c..d87252dd2ae674a5e21e7e53f0ad99b986f4c472 100644
|
| --- a/ash/display/display_controller.cc
|
| +++ b/ash/display/display_controller.cc
|
| @@ -35,7 +35,7 @@ namespace {
|
|
|
| // Primary display stored in global object as it can be
|
| // accessed after Shell is deleted.
|
| -gfx::Display* primary_display = NULL;
|
| +int64 primary_display_id = gfx::Display::kInvalidDisplayID;
|
|
|
| // The maximum value for 'offset' in DisplayLayout in case of outliers. Need
|
| // to change this value in case to support even larger displays.
|
| @@ -156,10 +156,9 @@ void DisplayLayout::RegisterJSONConverter(
|
| }
|
|
|
| DisplayController::DisplayController() {
|
| - // Reinstantiate display to make sure that tests don't use
|
| + // Reset primary display to make sure that tests don't use
|
| // stale display info from previous tests.
|
| - delete primary_display;
|
| - primary_display = new gfx::Display();
|
| + primary_display_id = gfx::Display::kInvalidDisplayID;
|
|
|
| GetDisplayManager()->AddObserver(this);
|
| }
|
| @@ -177,9 +176,9 @@ DisplayController::~DisplayController() {
|
| }
|
| }
|
| // static
|
| -gfx::Display DisplayController::GetPrimaryDisplay() {
|
| - DCHECK(primary_display);
|
| - return *primary_display;
|
| +const gfx::Display& DisplayController::GetPrimaryDisplay() {
|
| + DCHECK_NE(primary_display_id, gfx::Display::kInvalidDisplayID);
|
| + return GetDisplayManager()->GetDisplayForId(primary_display_id);
|
| }
|
|
|
| void DisplayController::InitPrimaryDisplay() {
|
| @@ -203,9 +202,9 @@ void DisplayController::InitPrimaryDisplay() {
|
| }
|
| }
|
| #endif
|
| - *primary_display = *primary_candidate;
|
| - aura::RootWindow* root = AddRootWindowForDisplay(*primary_display);
|
| - root->SetHostBounds(primary_display->bounds_in_pixel());
|
| + primary_display_id = primary_candidate->id();
|
| + aura::RootWindow* root = AddRootWindowForDisplay(*primary_candidate);
|
| + root->SetHostBounds(primary_candidate->bounds_in_pixel());
|
| UpdateDisplayBoundsForLayout();
|
| }
|
|
|
| @@ -213,7 +212,7 @@ void DisplayController::InitSecondaryDisplays() {
|
| internal::MultiDisplayManager* display_manager = GetDisplayManager();
|
| for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
|
| const gfx::Display* display = display_manager->GetDisplayAt(i);
|
| - if (primary_display->id() != display->id()) {
|
| + if (primary_display_id != display->id()) {
|
| aura::RootWindow* root = AddRootWindowForDisplay(*display);
|
| Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root);
|
| }
|
| @@ -249,7 +248,7 @@ void DisplayController::RemoveObserver(Observer* observer) {
|
|
|
| aura::RootWindow* DisplayController::GetPrimaryRootWindow() {
|
| DCHECK(!root_windows_.empty());
|
| - return root_windows_[primary_display->id()];
|
| + return root_windows_[primary_display_id];
|
| }
|
|
|
| aura::RootWindow* DisplayController::GetRootWindowForDisplayId(int64 id) {
|
| @@ -351,7 +350,7 @@ void DisplayController::SetPrimaryDisplay(
|
| return;
|
| }
|
|
|
| - if (primary_display->id() == new_primary_display.id() ||
|
| + if (primary_display_id == new_primary_display.id() ||
|
| root_windows_.size() < 2) {
|
| return;
|
| }
|
| @@ -363,10 +362,10 @@ void DisplayController::SetPrimaryDisplay(
|
| if (!non_primary_root)
|
| return;
|
|
|
| - gfx::Display old_primary_display = *primary_display;
|
| + gfx::Display old_primary_display = GetPrimaryDisplay();
|
|
|
| // Swap root windows between current and new primary display.
|
| - aura::RootWindow* primary_root = root_windows_[primary_display->id()];
|
| + aura::RootWindow* primary_root = root_windows_[primary_display_id];
|
| DCHECK(primary_root);
|
| DCHECK_NE(primary_root, non_primary_root);
|
|
|
| @@ -377,7 +376,7 @@ void DisplayController::SetPrimaryDisplay(
|
| non_primary_root->SetProperty(internal::kDisplayIdKey,
|
| old_primary_display.id());
|
|
|
| - *primary_display = new_primary_display;
|
| + primary_display_id = new_primary_display.id();
|
|
|
| // Update the layout.
|
| SetLayoutForDisplayName(
|
| @@ -386,7 +385,7 @@ void DisplayController::SetPrimaryDisplay(
|
|
|
| // Update the dispay manager with new display info.
|
| std::vector<gfx::Display> displays;
|
| - displays.push_back(*primary_display);
|
| + displays.push_back(GetDisplayManager()->GetDisplayForId(primary_display_id));
|
| displays.push_back(*GetSecondaryDisplay());
|
| GetDisplayManager()->set_force_bounds_changed(true);
|
| GetDisplayManager()->OnNativeDisplaysChanged(displays);
|
| @@ -396,13 +395,11 @@ void DisplayController::SetPrimaryDisplay(
|
| gfx::Display* DisplayController::GetSecondaryDisplay() {
|
| internal::MultiDisplayManager* display_manager = GetDisplayManager();
|
| CHECK_EQ(2U, display_manager->GetNumDisplays());
|
| - return display_manager->GetDisplayAt(0)->id() == primary_display->id() ?
|
| + return display_manager->GetDisplayAt(0)->id() == primary_display_id ?
|
| display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0);
|
| }
|
|
|
| void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
|
| - if (display.id() == primary_display->id())
|
| - *primary_display = display;
|
| NotifyDisplayConfigurationChanging();
|
| UpdateDisplayBoundsForLayout();
|
| root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel());
|
| @@ -427,20 +424,21 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
|
|
|
| // When the primary root window's display is removed, move the primary
|
| // root to the other display.
|
| - if (primary_display->id() == display.id()) {
|
| + if (primary_display_id == display.id()) {
|
| DCHECK_EQ(1U, root_windows_.size());
|
| - *primary_display = *GetSecondaryDisplay();
|
| + primary_display_id = GetSecondaryDisplay()->id();
|
| aura::RootWindow* primary_root = root_to_delete;
|
|
|
| // Delete the other root instead.
|
| - root_to_delete = root_windows_[primary_display->id()];
|
| + root_to_delete = root_windows_[primary_display_id];
|
| root_to_delete->SetProperty(internal::kDisplayIdKey, display.id());
|
|
|
| // Setup primary root.
|
| - root_windows_[primary_display->id()] = primary_root;
|
| - primary_root->SetProperty(internal::kDisplayIdKey, primary_display->id());
|
| + root_windows_[primary_display_id] = primary_root;
|
| + primary_root->SetProperty(internal::kDisplayIdKey, primary_display_id);
|
|
|
| - OnDisplayBoundsChanged(*primary_display);
|
| + OnDisplayBoundsChanged(
|
| + GetDisplayManager()->GetDisplayForId(primary_display_id));
|
| }
|
| internal::RootWindowController* controller =
|
| GetRootWindowController(root_to_delete);
|
| @@ -473,7 +471,7 @@ void DisplayController::UpdateDisplayBoundsForLayout() {
|
| return;
|
|
|
| DCHECK_EQ(2, gfx::Screen::GetNumDisplays());
|
| - const gfx::Rect& primary_bounds = primary_display->bounds();
|
| + const gfx::Rect& primary_bounds = GetPrimaryDisplay().bounds();
|
|
|
| gfx::Display* secondary_display = GetSecondaryDisplay();
|
| const gfx::Rect& secondary_bounds = secondary_display->bounds();
|
|
|