| 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 |
| 11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/display/cursor_window_controller.h" | 12 #include "ash/display/cursor_window_controller.h" |
| 13 #include "ash/display/display_layout_store.h" | 13 #include "ash/display/display_layout_store.h" |
| 14 #include "ash/display/display_manager.h" | 14 #include "ash/display/display_manager.h" |
| 15 #include "ash/display/mirror_window_controller.h" | 15 #include "ash/display/mirror_window_controller.h" |
| 16 #include "ash/display/root_window_transformers.h" | 16 #include "ash/display/root_window_transformers.h" |
| 17 #include "ash/host/ash_window_tree_host.h" | 17 #include "ash/host/ash_window_tree_host.h" |
| 18 #include "ash/host/ash_window_tree_host_init_params.h" | 18 #include "ash/host/ash_window_tree_host_init_params.h" |
| 19 #include "ash/host/root_window_transformer.h" | 19 #include "ash/host/root_window_transformer.h" |
| 20 #include "ash/magnifier/magnification_controller.h" |
| 21 #include "ash/magnifier/partial_magnification_controller.h" |
| 20 #include "ash/root_window_controller.h" | 22 #include "ash/root_window_controller.h" |
| 21 #include "ash/root_window_settings.h" | 23 #include "ash/root_window_settings.h" |
| 22 #include "ash/screen_util.h" | 24 #include "ash/screen_util.h" |
| 23 #include "ash/shell.h" | 25 #include "ash/shell.h" |
| 24 #include "ash/shell_delegate.h" | 26 #include "ash/shell_delegate.h" |
| 25 #include "ash/wm/coordinate_conversion.h" | 27 #include "ash/wm/coordinate_conversion.h" |
| 26 #include "base/command_line.h" | 28 #include "base/command_line.h" |
| 27 #include "base/stl_util.h" | 29 #include "base/stl_util.h" |
| 28 #include "base/strings/stringprintf.h" | 30 #include "base/strings/stringprintf.h" |
| 29 #include "base/strings/utf_string_conversions.h" | 31 #include "base/strings/utf_string_conversions.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 return GetRootWindowForDisplayId(primary_display_id); | 361 return GetRootWindowForDisplayId(primary_display_id); |
| 360 } | 362 } |
| 361 | 363 |
| 362 aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { | 364 aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { |
| 363 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); | 365 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); |
| 364 CHECK(host); | 366 CHECK(host); |
| 365 return GetWindow(host); | 367 return GetWindow(host); |
| 366 } | 368 } |
| 367 | 369 |
| 368 AshWindowTreeHost* DisplayController::GetAshWindowTreeHostForDisplayId( | 370 AshWindowTreeHost* DisplayController::GetAshWindowTreeHostForDisplayId( |
| 369 int64 id) { | 371 int64 display_id) { |
| 370 CHECK_EQ(1u, window_tree_hosts_.count(id)); | 372 CHECK_EQ(1u, window_tree_hosts_.count(display_id)) |
| 371 return window_tree_hosts_[id]; | 373 << "display id = " << display_id; |
| 374 return window_tree_hosts_[display_id]; |
| 372 } | 375 } |
| 373 | 376 |
| 374 void DisplayController::CloseChildWindows() { | 377 void DisplayController::CloseChildWindows() { |
| 375 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); | 378 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); |
| 376 it != window_tree_hosts_.end(); | 379 it != window_tree_hosts_.end(); |
| 377 ++it) { | 380 ++it) { |
| 378 aura::Window* root_window = GetWindow(it->second); | 381 aura::Window* root_window = GetWindow(it->second); |
| 379 RootWindowController* controller = GetRootWindowController(root_window); | 382 RootWindowController* controller = GetRootWindowController(root_window); |
| 380 if (controller) { | 383 if (controller) { |
| 381 controller->CloseChildWindows(); | 384 controller->CloseChildWindows(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 target_location_in_native = center; | 580 target_location_in_native = center; |
| 578 closest_distance_squared = distance_squared; | 581 closest_distance_squared = distance_squared; |
| 579 } | 582 } |
| 580 } | 583 } |
| 581 | 584 |
| 582 gfx::Point target_location_in_root = target_location_in_native; | 585 gfx::Point target_location_in_root = target_location_in_native; |
| 583 dst_root_window->GetHost()->ConvertPointFromNativeScreen( | 586 dst_root_window->GetHost()->ConvertPointFromNativeScreen( |
| 584 &target_location_in_root); | 587 &target_location_in_root); |
| 585 | 588 |
| 586 #if defined(USE_OZONE) | 589 #if defined(USE_OZONE) |
| 590 LOG(ERROR) << "Start OZONE"; |
| 587 gfx::Point target_location_in_screen = target_location_in_root; | 591 gfx::Point target_location_in_screen = target_location_in_root; |
| 588 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); | 592 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); |
| 589 const gfx::Display& target_display = | 593 const gfx::Display& target_display = |
| 590 display_manager->FindDisplayContainingPoint(target_location_in_screen); | 594 display_manager->FindDisplayContainingPoint(target_location_in_screen); |
| 591 int64 target_display_id = target_display.id(); | 595 int64 target_display_id = target_display.id(); |
| 592 | 596 |
| 593 // Do not move the cursor if the cursor's location did not change. This avoids | 597 // Do not move the cursor if the cursor's location did not change. This avoids |
| 594 // moving (and showing) the cursor: | 598 // moving (and showing) the cursor: |
| 595 // - At startup. | 599 // - At startup. |
| 596 // - When the device is rotated in maximized mode. | 600 // - When the device is rotated in maximized mode. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 608 // that the cursor is on changes. | 612 // that the cursor is on changes. |
| 609 Shell::GetInstance()->cursor_manager()->SetDisplay(target_display); | 613 Shell::GetInstance()->cursor_manager()->SetDisplay(target_display); |
| 610 | 614 |
| 611 // Update the cursor's root location. This ends up dispatching a synthetic | 615 // Update the cursor's root location. This ends up dispatching a synthetic |
| 612 // mouse move. The synthetic mouse move updates the composited cursor's | 616 // mouse move. The synthetic mouse move updates the composited cursor's |
| 613 // location and hover effects. Synthetic mouse moves do not affect the | 617 // location and hover effects. Synthetic mouse moves do not affect the |
| 614 // cursor's visibility. | 618 // cursor's visibility. |
| 615 dst_root_window->GetHost()->dispatcher()->OnCursorMovedToRootLocation( | 619 dst_root_window->GetHost()->dispatcher()->OnCursorMovedToRootLocation( |
| 616 target_location_in_root); | 620 target_location_in_root); |
| 617 } | 621 } |
| 622 LOG(ERROR) << "END OZONE"; |
| 618 #else | 623 #else |
| 619 dst_root_window->MoveCursorTo(target_location_in_root); | 624 dst_root_window->MoveCursorTo(target_location_in_root); |
| 620 #endif | 625 #endif |
| 621 } | 626 } |
| 622 | 627 |
| 623 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( | 628 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( |
| 624 const aura::Window* window, | 629 const aura::Window* window, |
| 625 const gfx::Insets& insets) { | 630 const gfx::Insets& insets) { |
| 626 const aura::Window* root_window = window->GetRootWindow(); | 631 const aura::Window* root_window = window->GetRootWindow(); |
| 627 int64 id = GetRootWindowSettings(root_window)->display_id; | 632 int64 id = GetRootWindowSettings(root_window)->display_id; |
| 628 // if id is |kInvaildDisplayID|, it's being deleted. | 633 // if id is |kInvaildDisplayID|, it's being deleted. |
| 629 DCHECK(id != gfx::Display::kInvalidDisplayID); | 634 DCHECK(id != gfx::Display::kInvalidDisplayID); |
| 630 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); | 635 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); |
| 631 } | 636 } |
| 632 | 637 |
| 633 void DisplayController::OnDisplayAdded(const gfx::Display& display) { | 638 void DisplayController::OnDisplayAdded(const gfx::Display& display) { |
| 634 #if defined(OS_CHROMEOS) | 639 #if defined(OS_CHROMEOS) |
| 635 if (GetDisplayManager()->default_multi_display_mode() == | 640 if (GetDisplayManager()->default_multi_display_mode() == |
| 636 DisplayManager::UNIFIED) { | 641 DisplayManager::UNIFIED) { |
| 637 if (primary_display_id == gfx::Display::kInvalidDisplayID) | 642 if (primary_display_id == gfx::Display::kInvalidDisplayID) |
| 638 primary_display_id = display.id(); | 643 primary_display_id = display.id(); |
| 639 AshWindowTreeHost* ash_host = | 644 AshWindowTreeHost* ash_host = |
| 640 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); | 645 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); |
| 641 RootWindowController::CreateForSecondaryDisplay(ash_host); | 646 RootWindowController::CreateForSecondaryDisplay(ash_host); |
| 642 | 647 |
| 648 // Magnifier controllers keep pointers to the current root window. |
| 649 // Update them here to avoid accessing them later. |
| 650 Shell::GetInstance()->magnification_controller()->SwitchTargetRootWindow( |
| 651 ash_host->AsWindowTreeHost()->window(), false); |
| 652 Shell::GetInstance() |
| 653 ->partial_magnification_controller() |
| 654 ->SwitchTargetRootWindow(ash_host->AsWindowTreeHost()->window()); |
| 655 |
| 643 if (primary_tree_host_for_replace_) { | 656 if (primary_tree_host_for_replace_) { |
| 644 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_; | 657 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_; |
| 645 primary_tree_host_for_replace_ = nullptr; | 658 primary_tree_host_for_replace_ = nullptr; |
| 646 DeleteHost(to_delete); | 659 DeleteHost(to_delete); |
| 647 #ifndef NDEBUG | 660 #ifndef NDEBUG |
| 648 auto iter = std::find_if( | 661 auto iter = std::find_if( |
| 649 window_tree_hosts_.begin(), window_tree_hosts_.end(), | 662 window_tree_hosts_.begin(), window_tree_hosts_.end(), |
| 650 [to_delete](const std::pair<int64, AshWindowTreeHost*>& pair) { | 663 [to_delete](const std::pair<int64, AshWindowTreeHost*>& pair) { |
| 651 return pair.second == to_delete; | 664 return pair.second == to_delete; |
| 652 }); | 665 }); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 Shell::GetInstance()->display_configurator_animation() | 886 Shell::GetInstance()->display_configurator_animation() |
| 874 ->StartFadeInAnimation(); | 887 ->StartFadeInAnimation(); |
| 875 #endif | 888 #endif |
| 876 } | 889 } |
| 877 | 890 |
| 878 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { | 891 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { |
| 879 GetDisplayManager()->SetMirrorMode(mirror); | 892 GetDisplayManager()->SetMirrorMode(mirror); |
| 880 } | 893 } |
| 881 | 894 |
| 882 } // namespace ash | 895 } // namespace ash |
| OLD | NEW |