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

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

Issue 11644012: Temporarily remember the primary root window while replacing the display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // static 155 // static
156 void DisplayLayout::RegisterJSONConverter( 156 void DisplayLayout::RegisterJSONConverter(
157 base::JSONValueConverter<DisplayLayout>* converter) { 157 base::JSONValueConverter<DisplayLayout>* converter) {
158 converter->RegisterCustomField<Position>( 158 converter->RegisterCustomField<Position>(
159 "position", &DisplayLayout::position, &GetPositionFromString); 159 "position", &DisplayLayout::position, &GetPositionFromString);
160 converter->RegisterIntField("offset", &DisplayLayout::offset); 160 converter->RegisterIntField("offset", &DisplayLayout::offset);
161 } 161 }
162 162
163 DisplayController::DisplayController() 163 DisplayController::DisplayController()
164 : desired_primary_display_id_(gfx::Display::kInvalidDisplayID) { 164 : desired_primary_display_id_(gfx::Display::kInvalidDisplayID),
165 primary_root_window_for_replace_(NULL) {
165 // Reset primary display to make sure that tests don't use 166 // Reset primary display to make sure that tests don't use
166 // stale display info from previous tests. 167 // stale display info from previous tests.
167 primary_display_id = gfx::Display::kInvalidDisplayID; 168 primary_display_id = gfx::Display::kInvalidDisplayID;
168 delete primary_display_for_shutdown; 169 delete primary_display_for_shutdown;
169 primary_display_for_shutdown = NULL; 170 primary_display_for_shutdown = NULL;
170 num_displays_for_shutdown = -1; 171 num_displays_for_shutdown = -1;
171 172
172 Shell::GetScreen()->AddObserver(this); 173 Shell::GetScreen()->AddObserver(this);
173 } 174 }
174 175
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); 461 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0);
461 } 462 }
462 463
463 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { 464 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
464 NotifyDisplayConfigurationChanging(); 465 NotifyDisplayConfigurationChanging();
465 UpdateDisplayBoundsForLayout(); 466 UpdateDisplayBoundsForLayout();
466 root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel()); 467 root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel());
467 } 468 }
468 469
469 void DisplayController::OnDisplayAdded(const gfx::Display& display) { 470 void DisplayController::OnDisplayAdded(const gfx::Display& display) {
470 DCHECK(!root_windows_.empty());
471 NotifyDisplayConfigurationChanging(); 471 NotifyDisplayConfigurationChanging();
472 aura::RootWindow* root = AddRootWindowForDisplay(display); 472 if (primary_root_window_for_replace_) {
473 UpdateDisplayBoundsForLayout(); 473 DCHECK(root_windows_.empty());
474 if (desired_primary_display_id_ == display.id()) 474 primary_display_id = display.id();
475 SetPrimaryDisplay(display); 475 root_windows_[display.id()] = primary_root_window_for_replace_;
476 476 primary_root_window_for_replace_->SetProperty(
477 Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root); 477 internal::kDisplayIdKey, display.id());
478 primary_root_window_for_replace_ = NULL;
479 UpdateDisplayBoundsForLayout();
480 } else {
481 DCHECK(!root_windows_.empty());
482 aura::RootWindow* root = AddRootWindowForDisplay(display);
483 UpdateDisplayBoundsForLayout();
484 if (desired_primary_display_id_ == display.id())
485 SetPrimaryDisplay(display);
486 Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root);
487 }
478 } 488 }
479 489
480 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { 490 void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
481 aura::RootWindow* root_to_delete = root_windows_[display.id()]; 491 aura::RootWindow* root_to_delete = root_windows_[display.id()];
482 DCHECK(root_to_delete) << display.ToString(); 492 DCHECK(root_to_delete) << display.ToString();
483 NotifyDisplayConfigurationChanging(); 493 NotifyDisplayConfigurationChanging();
484 494
485 // Display for root window will be deleted when the Primary RootWindow 495 // Display for root window will be deleted when the Primary RootWindow
486 // is deleted by the Shell. 496 // is deleted by the Shell.
487 root_windows_.erase(display.id()); 497 root_windows_.erase(display.id());
488 498
489 // When the primary root window's display is removed, move the primary 499 // When the primary root window's display is removed, move the primary
490 // root to the other display. 500 // root to the other display.
491 if (primary_display_id == display.id()) { 501 if (primary_display_id == display.id()) {
502 // Temporarily store the primary root window in
503 // |primary_root_window_for_replace_| when replacing the display.
504 if (root_windows_.size() == 0) {
505 primary_display_id = gfx::Display::kInvalidDisplayID;
506 primary_root_window_for_replace_ = root_to_delete;
507 return;
508 }
492 DCHECK_EQ(1U, root_windows_.size()); 509 DCHECK_EQ(1U, root_windows_.size());
493 primary_display_id = GetSecondaryDisplay()->id(); 510 primary_display_id = GetSecondaryDisplay()->id();
494 aura::RootWindow* primary_root = root_to_delete; 511 aura::RootWindow* primary_root = root_to_delete;
495 512
496 // Delete the other root instead. 513 // Delete the other root instead.
497 root_to_delete = root_windows_[primary_display_id]; 514 root_to_delete = root_windows_[primary_display_id];
498 root_to_delete->SetProperty(internal::kDisplayIdKey, display.id()); 515 root_to_delete->SetProperty(internal::kDisplayIdKey, display.id());
499 516
500 // Setup primary root. 517 // Setup primary root.
501 root_windows_[primary_display_id] = primary_root; 518 root_windows_[primary_display_id] = primary_root;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 secondary_display->set_bounds( 593 secondary_display->set_bounds(
577 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 594 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
578 secondary_display->UpdateWorkAreaFromInsets(insets); 595 secondary_display->UpdateWorkAreaFromInsets(insets);
579 } 596 }
580 597
581 void DisplayController::NotifyDisplayConfigurationChanging() { 598 void DisplayController::NotifyDisplayConfigurationChanging() {
582 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); 599 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging());
583 } 600 }
584 601
585 } // namespace ash 602 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698