| 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/window_tree_host_manager.h" | 5 #include "ash/display/window_tree_host_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // exactly "closest" display, but good enough to pick one | 522 // exactly "closest" display, but good enough to pick one |
| 523 // appropriate (and there are at most two displays). | 523 // appropriate (and there are at most two displays). |
| 524 // We don't care about actual distance, only relative to other displays, so | 524 // We don't care about actual distance, only relative to other displays, so |
| 525 // using the LengthSquared() is cheaper than Length(). | 525 // using the LengthSquared() is cheaper than Length(). |
| 526 | 526 |
| 527 int64_t distance_squared = (center - point_in_screen).LengthSquared(); | 527 int64_t distance_squared = (center - point_in_screen).LengthSquared(); |
| 528 if (closest_distance_squared < 0 || | 528 if (closest_distance_squared < 0 || |
| 529 closest_distance_squared > distance_squared) { | 529 closest_distance_squared > distance_squared) { |
| 530 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); | 530 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); |
| 531 ::wm::ConvertPointFromScreen(root_window, ¢er); | 531 ::wm::ConvertPointFromScreen(root_window, ¢er); |
| 532 root_window->GetHost()->ConvertPointToNativeScreen(¢er); | 532 root_window->GetHost()->ConvertDIPToScreenInPixels(¢er); |
| 533 dst_root_window = root_window; | 533 dst_root_window = root_window; |
| 534 target_location_in_native = center; | 534 target_location_in_native = center; |
| 535 closest_distance_squared = distance_squared; | 535 closest_distance_squared = distance_squared; |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 | 538 |
| 539 gfx::Point target_location_in_root = target_location_in_native; | 539 gfx::Point target_location_in_root = target_location_in_native; |
| 540 dst_root_window->GetHost()->ConvertPointFromNativeScreen( | 540 dst_root_window->GetHost()->ConvertScreenInPixelsToDIP( |
| 541 &target_location_in_root); | 541 &target_location_in_root); |
| 542 | 542 |
| 543 #if defined(USE_OZONE) | 543 #if defined(USE_OZONE) |
| 544 gfx::Point target_location_in_screen = target_location_in_root; | 544 gfx::Point target_location_in_screen = target_location_in_root; |
| 545 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); | 545 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); |
| 546 const display::Display& target_display = | 546 const display::Display& target_display = |
| 547 display_manager->FindDisplayContainingPoint(target_location_in_screen); | 547 display_manager->FindDisplayContainingPoint(target_location_in_screen); |
| 548 // If the original location isn't on any of new display, let ozone move | 548 // If the original location isn't on any of new display, let ozone move |
| 549 // the cursor. | 549 // the cursor. |
| 550 if (!target_display.is_valid()) | 550 if (!target_display.is_valid()) |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 display::Screen* screen = display::Screen::GetScreen(); | 784 display::Screen* screen = display::Screen::GetScreen(); |
| 785 gfx::Point point_in_screen = screen->GetCursorScreenPoint(); | 785 gfx::Point point_in_screen = screen->GetCursorScreenPoint(); |
| 786 cursor_location_in_screen_coords_for_restore_ = point_in_screen; | 786 cursor_location_in_screen_coords_for_restore_ = point_in_screen; |
| 787 | 787 |
| 788 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); | 788 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); |
| 789 cursor_display_id_for_restore_ = display.id(); | 789 cursor_display_id_for_restore_ = display.id(); |
| 790 | 790 |
| 791 gfx::Point point_in_native = point_in_screen; | 791 gfx::Point point_in_native = point_in_screen; |
| 792 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); | 792 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); |
| 793 ::wm::ConvertPointFromScreen(root_window, &point_in_native); | 793 ::wm::ConvertPointFromScreen(root_window, &point_in_native); |
| 794 root_window->GetHost()->ConvertPointToNativeScreen(&point_in_native); | 794 root_window->GetHost()->ConvertDIPToScreenInPixels(&point_in_native); |
| 795 cursor_location_in_native_coords_for_restore_ = point_in_native; | 795 cursor_location_in_native_coords_for_restore_ = point_in_native; |
| 796 } | 796 } |
| 797 | 797 |
| 798 void WindowTreeHostManager::PostDisplayConfigurationChange( | 798 void WindowTreeHostManager::PostDisplayConfigurationChange( |
| 799 bool must_clear_window) { | 799 bool must_clear_window) { |
| 800 focus_activation_store_->Restore(); | 800 focus_activation_store_->Restore(); |
| 801 | 801 |
| 802 display::DisplayManager* display_manager = GetDisplayManager(); | 802 display::DisplayManager* display_manager = GetDisplayManager(); |
| 803 display::DisplayLayoutStore* layout_store = display_manager->layout_store(); | 803 display::DisplayLayoutStore* layout_store = display_manager->layout_store(); |
| 804 if (display_manager->num_connected_displays() > 1) { | 804 if (display_manager->num_connected_displays() > 1) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 SetDisplayPropertiesOnHost(ash_host, display); | 898 SetDisplayPropertiesOnHost(ash_host, display); |
| 899 | 899 |
| 900 #if defined(OS_CHROMEOS) | 900 #if defined(OS_CHROMEOS) |
| 901 if (switches::ConstrainPointerToRoot()) | 901 if (switches::ConstrainPointerToRoot()) |
| 902 ash_host->ConfineCursorToRootWindow(); | 902 ash_host->ConfineCursorToRootWindow(); |
| 903 #endif | 903 #endif |
| 904 return ash_host; | 904 return ash_host; |
| 905 } | 905 } |
| 906 | 906 |
| 907 } // namespace ash | 907 } // namespace ash |
| OLD | NEW |