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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( | 540 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( |
541 const aura::Window* window, | 541 const aura::Window* window, |
542 const gfx::Insets& insets) { | 542 const gfx::Insets& insets) { |
543 const aura::Window* root_window = window->GetRootWindow(); | 543 const aura::Window* root_window = window->GetRootWindow(); |
544 int64 id = GetRootWindowSettings(root_window)->display_id; | 544 int64 id = GetRootWindowSettings(root_window)->display_id; |
545 // if id is |kInvaildDisplayID|, it's being deleted. | 545 // if id is |kInvaildDisplayID|, it's being deleted. |
546 DCHECK(id != gfx::Display::kInvalidDisplayID); | 546 DCHECK(id != gfx::Display::kInvalidDisplayID); |
547 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); | 547 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); |
548 } | 548 } |
549 | 549 |
550 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { | |
551 const DisplayInfo& display_info = | |
552 GetDisplayManager()->GetDisplayInfo(display.id()); | |
553 DCHECK(!display_info.bounds_in_native().IsEmpty()); | |
554 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()]; | |
555 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native()); | |
556 SetDisplayPropertiesOnHost(ash_host, display); | |
557 } | |
558 | |
559 void DisplayController::OnDisplayAdded(const gfx::Display& display) { | 550 void DisplayController::OnDisplayAdded(const gfx::Display& display) { |
560 if (primary_tree_host_for_replace_) { | 551 if (primary_tree_host_for_replace_) { |
561 DCHECK(window_tree_hosts_.empty()); | 552 DCHECK(window_tree_hosts_.empty()); |
562 primary_display_id = display.id(); | 553 primary_display_id = display.id(); |
563 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_; | 554 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_; |
564 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) | 555 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) |
565 ->display_id = display.id(); | 556 ->display_id = display.id(); |
566 primary_tree_host_for_replace_ = NULL; | 557 primary_tree_host_for_replace_ = NULL; |
567 const DisplayInfo& display_info = | 558 const DisplayInfo& display_info = |
568 GetDisplayManager()->GetDisplayInfo(display.id()); | 559 GetDisplayManager()->GetDisplayInfo(display.id()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 | 594 |
604 // Delete the other host instead. | 595 // Delete the other host instead. |
605 host_to_delete = window_tree_hosts_[primary_display_id]; | 596 host_to_delete = window_tree_hosts_[primary_display_id]; |
606 GetRootWindowSettings(GetWindow(host_to_delete))->display_id = display.id(); | 597 GetRootWindowSettings(GetWindow(host_to_delete))->display_id = display.id(); |
607 | 598 |
608 // Setup primary root. | 599 // Setup primary root. |
609 window_tree_hosts_[primary_display_id] = primary_host; | 600 window_tree_hosts_[primary_display_id] = primary_host; |
610 GetRootWindowSettings(GetWindow(primary_host))->display_id = | 601 GetRootWindowSettings(GetWindow(primary_host))->display_id = |
611 primary_display_id; | 602 primary_display_id; |
612 | 603 |
613 OnDisplayBoundsChanged( | 604 OnDisplayMetricsChanged( |
614 GetDisplayManager()->GetDisplayForId(primary_display_id)); | 605 GetDisplayManager()->GetDisplayForId(primary_display_id), |
| 606 DISPLAY_METRIC_BOUNDS); |
615 } | 607 } |
616 RootWindowController* controller = | 608 RootWindowController* controller = |
617 GetRootWindowController(GetWindow(host_to_delete)); | 609 GetRootWindowController(GetWindow(host_to_delete)); |
618 DCHECK(controller); | 610 DCHECK(controller); |
619 controller->MoveWindowsTo(GetPrimaryRootWindow()); | 611 controller->MoveWindowsTo(GetPrimaryRootWindow()); |
620 // Delete most of root window related objects, but don't delete | 612 // Delete most of root window related objects, but don't delete |
621 // root window itself yet because the stack may be using it. | 613 // root window itself yet because the stack may be using it. |
622 controller->Shutdown(); | 614 controller->Shutdown(); |
623 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); | 615 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); |
624 } | 616 } |
625 | 617 |
| 618 void DisplayController::OnDisplayMetricsChanged( |
| 619 const gfx::Display& display, |
| 620 DisplayObserver::DisplayMetrics metrics) { |
| 621 if (!(metrics & (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_ROTATION | |
| 622 DISPLAY_METRIC_DEVICE_SCALE_FACTOR))) |
| 623 return; |
| 624 |
| 625 const DisplayInfo& display_info = |
| 626 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 627 DCHECK(!display_info.bounds_in_native().IsEmpty()); |
| 628 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()]; |
| 629 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native()); |
| 630 SetDisplayPropertiesOnHost(ash_host, display); |
| 631 } |
| 632 |
626 void DisplayController::OnHostResized(const aura::WindowTreeHost* host) { | 633 void DisplayController::OnHostResized(const aura::WindowTreeHost* host) { |
627 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( | 634 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( |
628 const_cast<aura::Window*>(host->window())); | 635 const_cast<aura::Window*>(host->window())); |
629 | 636 |
630 DisplayManager* display_manager = GetDisplayManager(); | 637 DisplayManager* display_manager = GetDisplayManager(); |
631 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { | 638 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { |
632 mirror_window_controller_->UpdateWindow(); | 639 mirror_window_controller_->UpdateWindow(); |
633 cursor_window_controller_->UpdateContainer(); | 640 cursor_window_controller_->UpdateContainer(); |
634 } | 641 } |
635 } | 642 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 std::string name = | 762 std::string name = |
756 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 763 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
757 gfx::AcceleratedWidget xwindow = | 764 gfx::AcceleratedWidget xwindow = |
758 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 765 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
759 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 766 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
760 } | 767 } |
761 #endif | 768 #endif |
762 } | 769 } |
763 | 770 |
764 } // namespace ash | 771 } // namespace ash |
OLD | NEW |