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