| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/unified_mouse_warp_controller.h" | 5 #include "ash/display/unified_mouse_warp_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_util.h" | 7 #include "ash/display/display_util.h" |
| 8 #include "ash/display/mirror_window_controller.h" | 8 #include "ash/display/mirror_window_controller.h" |
| 9 #include "ash/display/mouse_cursor_event_filter.h" | 9 #include "ash/display/mouse_cursor_event_filter.h" |
| 10 #include "ash/host/ash_window_tree_host.h" | 10 #include "ash/host/ash_window_tree_host.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 const gfx::Point& origin = info.bounds_in_native().origin(); | 46 const gfx::Point& origin = info.bounds_in_native().origin(); |
| 47 // Convert to mirroring host. | 47 // Convert to mirroring host. |
| 48 point_in_unified_host->Offset(-origin.x(), -origin.y()); | 48 point_in_unified_host->Offset(-origin.x(), -origin.y()); |
| 49 *point_in_mirroring_host = *point_in_unified_host; | 49 *point_in_mirroring_host = *point_in_unified_host; |
| 50 // Convert from mirroring host to unified host. | 50 // Convert from mirroring host to unified host. |
| 51 AshWindowTreeHost* ash_host = | 51 AshWindowTreeHost* ash_host = |
| 52 Shell::GetInstance() | 52 Shell::GetInstance() |
| 53 ->window_tree_host_manager() | 53 ->window_tree_host_manager() |
| 54 ->mirror_window_controller() | 54 ->mirror_window_controller() |
| 55 ->GetAshWindowTreeHostForDisplayId(info.id()); | 55 ->GetAshWindowTreeHostForDisplayId(info.id()); |
| 56 ash_host->AsWindowTreeHost()->ConvertPointFromHost( | 56 ash_host->AsWindowTreeHost()->ConvertPointFromHostToDIP( |
| 57 point_in_unified_host); | 57 point_in_unified_host); |
| 58 return true; | 58 return true; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool TestIfMouseWarpsAt(const gfx::Point& point_in_native) { | 64 bool TestIfMouseWarpsAt(const gfx::Point& point_in_native) { |
| 65 static_cast<UnifiedMouseWarpController*>( | 65 static_cast<UnifiedMouseWarpController*>( |
| 66 Shell::GetInstance() | 66 Shell::GetInstance() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 80 GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, | 80 GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, |
| 81 point_in_mirroring_host); | 81 point_in_mirroring_host); |
| 82 #else | 82 #else |
| 83 GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, | 83 GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, |
| 84 point_in_native); | 84 point_in_native); |
| 85 #endif | 85 #endif |
| 86 aura::Window* root = Shell::GetPrimaryRootWindow(); | 86 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 87 gfx::Point new_location_in_unified_host = | 87 gfx::Point new_location_in_unified_host = |
| 88 aura::Env::GetInstance()->last_mouse_location(); | 88 aura::Env::GetInstance()->last_mouse_location(); |
| 89 // Convert screen to the host. | 89 // Convert screen to the host. |
| 90 root->GetHost()->ConvertPointToHost(&new_location_in_unified_host); | 90 root->GetHost()->ConvertPointFromDIPToHost(&new_location_in_unified_host); |
| 91 | 91 |
| 92 int new_index = display::FindDisplayIndexContainingPoint( | 92 int new_index = display::FindDisplayIndexContainingPoint( |
| 93 display_manager()->software_mirroring_display_list(), | 93 display_manager()->software_mirroring_display_list(), |
| 94 new_location_in_unified_host); | 94 new_location_in_unified_host); |
| 95 if (new_index < 0) | 95 if (new_index < 0) |
| 96 return false; | 96 return false; |
| 97 return orig_mirroring_display_id != | 97 return orig_mirroring_display_id != |
| 98 display_manager()->software_mirroring_display_list()[new_index].id(); | 98 display_manager()->software_mirroring_display_list()[new_index].id(); |
| 99 } | 99 } |
| 100 | 100 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(600, 10))); | 253 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(600, 10))); |
| 254 EXPECT_EQ("249,5", // moved to 498 by 2px, divided by 2 (dsf). | 254 EXPECT_EQ("249,5", // moved to 498 by 2px, divided by 2 (dsf). |
| 255 aura::Env::GetInstance()->last_mouse_location().ToString()); | 255 aura::Env::GetInstance()->last_mouse_location().ToString()); |
| 256 { | 256 { |
| 257 SCOPED_TRACE("1x2 NO WARP"); | 257 SCOPED_TRACE("1x2 NO WARP"); |
| 258 NoWarpTestBody(); | 258 NoWarpTestBody(); |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace aura | 262 } // namespace aura |
| OLD | NEW |