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

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

Issue 11801019: Merge 174008 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/display_controller.h ('k') | ash/display/display_manager_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 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); 459 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0);
459 } 460 }
460 461
461 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { 462 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
462 NotifyDisplayConfigurationChanging(); 463 NotifyDisplayConfigurationChanging();
463 UpdateDisplayBoundsForLayout(); 464 UpdateDisplayBoundsForLayout();
464 root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel()); 465 root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel());
465 } 466 }
466 467
467 void DisplayController::OnDisplayAdded(const gfx::Display& display) { 468 void DisplayController::OnDisplayAdded(const gfx::Display& display) {
468 DCHECK(!root_windows_.empty());
469 NotifyDisplayConfigurationChanging(); 469 NotifyDisplayConfigurationChanging();
470 aura::RootWindow* root = AddRootWindowForDisplay(display); 470 if (primary_root_window_for_replace_) {
471 UpdateDisplayBoundsForLayout(); 471 DCHECK(root_windows_.empty());
472 if (desired_primary_display_id_ == display.id()) 472 primary_display_id = display.id();
473 SetPrimaryDisplay(display); 473 root_windows_[display.id()] = primary_root_window_for_replace_;
474 474 primary_root_window_for_replace_->SetProperty(
475 Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root); 475 internal::kDisplayIdKey, display.id());
476 primary_root_window_for_replace_ = NULL;
477 UpdateDisplayBoundsForLayout();
478 } else {
479 DCHECK(!root_windows_.empty());
480 aura::RootWindow* root = AddRootWindowForDisplay(display);
481 UpdateDisplayBoundsForLayout();
482 if (desired_primary_display_id_ == display.id())
483 SetPrimaryDisplay(display);
484 Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root);
485 }
476 } 486 }
477 487
478 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { 488 void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
479 aura::RootWindow* root_to_delete = root_windows_[display.id()]; 489 aura::RootWindow* root_to_delete = root_windows_[display.id()];
480 DCHECK(root_to_delete) << display.ToString(); 490 DCHECK(root_to_delete) << display.ToString();
481 NotifyDisplayConfigurationChanging(); 491 NotifyDisplayConfigurationChanging();
482 492
483 // Display for root window will be deleted when the Primary RootWindow 493 // Display for root window will be deleted when the Primary RootWindow
484 // is deleted by the Shell. 494 // is deleted by the Shell.
485 root_windows_.erase(display.id()); 495 root_windows_.erase(display.id());
486 496
487 // When the primary root window's display is removed, move the primary 497 // When the primary root window's display is removed, move the primary
488 // root to the other display. 498 // root to the other display.
489 if (primary_display_id == display.id()) { 499 if (primary_display_id == display.id()) {
500 // Temporarily store the primary root window in
501 // |primary_root_window_for_replace_| when replacing the display.
502 if (root_windows_.size() == 0) {
503 primary_display_id = gfx::Display::kInvalidDisplayID;
504 primary_root_window_for_replace_ = root_to_delete;
505 return;
506 }
490 DCHECK_EQ(1U, root_windows_.size()); 507 DCHECK_EQ(1U, root_windows_.size());
491 primary_display_id = GetSecondaryDisplay()->id(); 508 primary_display_id = GetSecondaryDisplay()->id();
492 aura::RootWindow* primary_root = root_to_delete; 509 aura::RootWindow* primary_root = root_to_delete;
493 510
494 // Delete the other root instead. 511 // Delete the other root instead.
495 root_to_delete = root_windows_[primary_display_id]; 512 root_to_delete = root_windows_[primary_display_id];
496 root_to_delete->SetProperty(internal::kDisplayIdKey, display.id()); 513 root_to_delete->SetProperty(internal::kDisplayIdKey, display.id());
497 514
498 // Setup primary root. 515 // Setup primary root.
499 root_windows_[primary_display_id] = primary_root; 516 root_windows_[primary_display_id] = primary_root;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 secondary_display->set_bounds( 591 secondary_display->set_bounds(
575 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 592 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
576 secondary_display->UpdateWorkAreaFromInsets(insets); 593 secondary_display->UpdateWorkAreaFromInsets(insets);
577 } 594 }
578 595
579 void DisplayController::NotifyDisplayConfigurationChanging() { 596 void DisplayController::NotifyDisplayConfigurationChanging() {
580 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); 597 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging());
581 } 598 }
582 599
583 } // namespace ash 600 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller.h ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698