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/system/tray/system_tray.h" | 27 #include "ash/system/tray/system_tray.h" |
26 #include "ash/wm/coordinate_conversion.h" | 28 #include "ash/wm/coordinate_conversion.h" |
27 #include "base/command_line.h" | 29 #include "base/command_line.h" |
28 #include "base/stl_util.h" | 30 #include "base/stl_util.h" |
29 #include "base/strings/stringprintf.h" | 31 #include "base/strings/stringprintf.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 return GetRootWindowForDisplayId(primary_display_id); | 362 return GetRootWindowForDisplayId(primary_display_id); |
361 } | 363 } |
362 | 364 |
363 aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { | 365 aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { |
364 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); | 366 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); |
365 CHECK(host); | 367 CHECK(host); |
366 return GetWindow(host); | 368 return GetWindow(host); |
367 } | 369 } |
368 | 370 |
369 AshWindowTreeHost* DisplayController::GetAshWindowTreeHostForDisplayId( | 371 AshWindowTreeHost* DisplayController::GetAshWindowTreeHostForDisplayId( |
370 int64 id) { | 372 int64 display_id) { |
371 CHECK_EQ(1u, window_tree_hosts_.count(id)); | 373 CHECK_EQ(1u, window_tree_hosts_.count(display_id)) |
372 return window_tree_hosts_[id]; | 374 << "display id = " << display_id; |
375 return window_tree_hosts_[display_id]; | |
373 } | 376 } |
374 | 377 |
375 void DisplayController::CloseChildWindows() { | 378 void DisplayController::CloseChildWindows() { |
376 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); | 379 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); |
377 it != window_tree_hosts_.end(); | 380 it != window_tree_hosts_.end(); |
378 ++it) { | 381 ++it) { |
379 aura::Window* root_window = GetWindow(it->second); | 382 aura::Window* root_window = GetWindow(it->second); |
380 RootWindowController* controller = GetRootWindowController(root_window); | 383 RootWindowController* controller = GetRootWindowController(root_window); |
381 if (controller) { | 384 if (controller) { |
382 controller->CloseChildWindows(); | 385 controller->CloseChildWindows(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 | 585 |
583 gfx::Point target_location_in_root = target_location_in_native; | 586 gfx::Point target_location_in_root = target_location_in_native; |
584 dst_root_window->GetHost()->ConvertPointFromNativeScreen( | 587 dst_root_window->GetHost()->ConvertPointFromNativeScreen( |
585 &target_location_in_root); | 588 &target_location_in_root); |
586 | 589 |
587 #if defined(USE_OZONE) | 590 #if defined(USE_OZONE) |
588 gfx::Point target_location_in_screen = target_location_in_root; | 591 gfx::Point target_location_in_screen = target_location_in_root; |
589 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); | 592 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); |
590 const gfx::Display& target_display = | 593 const gfx::Display& target_display = |
591 display_manager->FindDisplayContainingPoint(target_location_in_screen); | 594 display_manager->FindDisplayContainingPoint(target_location_in_screen); |
595 // If the original location isn't on any of new display, let ozone move | |
596 // the cursor. | |
597 if (!target_display.is_valid()) | |
598 return; | |
oshima
2015/05/05 15:32:13
this was ozone issue.
| |
592 int64 target_display_id = target_display.id(); | 599 int64 target_display_id = target_display.id(); |
593 | 600 |
594 // Do not move the cursor if the cursor's location did not change. This avoids | 601 // Do not move the cursor if the cursor's location did not change. This avoids |
595 // moving (and showing) the cursor: | 602 // moving (and showing) the cursor: |
596 // - At startup. | 603 // - At startup. |
597 // - When the device is rotated in maximized mode. | 604 // - When the device is rotated in maximized mode. |
598 // |cursor_display_id_for_restore_| is checked to ensure that the cursor is | 605 // |cursor_display_id_for_restore_| is checked to ensure that the cursor is |
599 // moved when the cursor's native position does not change but the display | 606 // moved when the cursor's native position does not change but the display |
600 // that it is on has changed. This occurs when swapping the primary display. | 607 // that it is on has changed. This occurs when swapping the primary display. |
601 if (target_location_in_native != | 608 if (target_location_in_native != |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 void DisplayController::OnDisplayAdded(const gfx::Display& display) { | 641 void DisplayController::OnDisplayAdded(const gfx::Display& display) { |
635 #if defined(OS_CHROMEOS) | 642 #if defined(OS_CHROMEOS) |
636 if (GetDisplayManager()->default_multi_display_mode() == | 643 if (GetDisplayManager()->default_multi_display_mode() == |
637 DisplayManager::UNIFIED) { | 644 DisplayManager::UNIFIED) { |
638 if (primary_display_id == gfx::Display::kInvalidDisplayID) | 645 if (primary_display_id == gfx::Display::kInvalidDisplayID) |
639 primary_display_id = display.id(); | 646 primary_display_id = display.id(); |
640 AshWindowTreeHost* ash_host = | 647 AshWindowTreeHost* ash_host = |
641 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); | 648 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); |
642 RootWindowController::CreateForSecondaryDisplay(ash_host); | 649 RootWindowController::CreateForSecondaryDisplay(ash_host); |
643 | 650 |
651 // Magnifier controllers keep pointers to the current root window. | |
652 // Update them here to avoid accessing them later. | |
653 Shell::GetInstance()->magnification_controller()->SwitchTargetRootWindow( | |
654 ash_host->AsWindowTreeHost()->window(), false); | |
655 Shell::GetInstance() | |
656 ->partial_magnification_controller() | |
657 ->SwitchTargetRootWindow(ash_host->AsWindowTreeHost()->window()); | |
658 | |
644 if (primary_tree_host_for_replace_) { | 659 if (primary_tree_host_for_replace_) { |
645 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_; | 660 AshWindowTreeHost* to_delete = primary_tree_host_for_replace_; |
646 primary_tree_host_for_replace_ = nullptr; | 661 primary_tree_host_for_replace_ = nullptr; |
647 | 662 |
648 // Show the shelf if the original WTH had a visible system | 663 // Show the shelf if the original WTH had a visible system |
649 // tray. It may or may not be visible depending on OOBE state. | 664 // tray. It may or may not be visible depending on OOBE state. |
650 ash::SystemTray* old_tray = | 665 ash::SystemTray* old_tray = |
651 GetRootWindowController(to_delete->AsWindowTreeHost()->window()) | 666 GetRootWindowController(to_delete->AsWindowTreeHost()->window()) |
652 ->GetSystemTray(); | 667 ->GetSystemTray(); |
653 ash::SystemTray* new_tray = | 668 ash::SystemTray* new_tray = |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
887 Shell::GetInstance()->display_configurator_animation() | 902 Shell::GetInstance()->display_configurator_animation() |
888 ->StartFadeInAnimation(); | 903 ->StartFadeInAnimation(); |
889 #endif | 904 #endif |
890 } | 905 } |
891 | 906 |
892 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { | 907 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { |
893 GetDisplayManager()->SetMirrorMode(mirror); | 908 GetDisplayManager()->SetMirrorMode(mirror); |
894 } | 909 } |
895 | 910 |
896 } // namespace ash | 911 } // namespace ash |
OLD | NEW |