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_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/display/display_util.h" | 8 #include "ash/display/display_util.h" |
9 #include "ash/display/mirror_window_controller.h" | 9 #include "ash/display/mirror_window_controller.h" |
10 #include "ash/display/mouse_cursor_event_filter.h" | 10 #include "ash/display/mouse_cursor_event_filter.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 ~UnifiedMouseWarpControllerTest() override {} | 27 ~UnifiedMouseWarpControllerTest() override {} |
28 | 28 |
29 void SetUp() override { | 29 void SetUp() override { |
30 test::AshTestBase::SetUp(); | 30 test::AshTestBase::SetUp(); |
31 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); | 31 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); |
32 } | 32 } |
33 | 33 |
34 protected: | 34 protected: |
35 bool FindMirrroingDisplayIdContainingNativePoint( | 35 bool FindMirrroingDisplayIdContainingNativePoint( |
36 const gfx::Point& point_in_native, | 36 const gfx::Point& point_in_native, |
37 int64* display_id, | 37 int64_t* display_id, |
38 gfx::Point* point_in_mirroring_host, | 38 gfx::Point* point_in_mirroring_host, |
39 gfx::Point* point_in_unified_host) { | 39 gfx::Point* point_in_unified_host) { |
40 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 40 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
41 for (auto display : display_manager->software_mirroring_display_list()) { | 41 for (auto display : display_manager->software_mirroring_display_list()) { |
42 DisplayInfo info = display_manager->GetDisplayInfo(display.id()); | 42 DisplayInfo info = display_manager->GetDisplayInfo(display.id()); |
43 if (info.bounds_in_native().Contains(point_in_native)) { | 43 if (info.bounds_in_native().Contains(point_in_native)) { |
44 *display_id = info.id(); | 44 *display_id = info.id(); |
45 *point_in_unified_host = point_in_native; | 45 *point_in_unified_host = point_in_native; |
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. |
(...skipping 13 matching lines...) Expand all Loading... |
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() |
67 ->mouse_cursor_filter() | 67 ->mouse_cursor_filter() |
68 ->mouse_warp_controller_for_test()) | 68 ->mouse_warp_controller_for_test()) |
69 ->update_location_for_test(); | 69 ->update_location_for_test(); |
70 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 70 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
71 int64 orig_mirroring_display_id; | 71 int64_t orig_mirroring_display_id; |
72 gfx::Point point_in_unified_host; | 72 gfx::Point point_in_unified_host; |
73 gfx::Point point_in_mirroring_host; | 73 gfx::Point point_in_mirroring_host; |
74 if (!FindMirrroingDisplayIdContainingNativePoint( | 74 if (!FindMirrroingDisplayIdContainingNativePoint( |
75 point_in_native, &orig_mirroring_display_id, | 75 point_in_native, &orig_mirroring_display_id, |
76 &point_in_mirroring_host, &point_in_unified_host)) { | 76 &point_in_mirroring_host, &point_in_unified_host)) { |
77 return false; | 77 return false; |
78 } | 78 } |
79 #if defined(USE_OZONE) | 79 #if defined(USE_OZONE) |
80 // The location of the ozone's native event is relative to the host. | 80 // The location of the ozone's native event is relative to the host. |
81 GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, | 81 GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(600, 10))); | 258 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(600, 10))); |
259 EXPECT_EQ("249,5", // moved to 498 by 2px, divided by 2 (dsf). | 259 EXPECT_EQ("249,5", // moved to 498 by 2px, divided by 2 (dsf). |
260 aura::Env::GetInstance()->last_mouse_location().ToString()); | 260 aura::Env::GetInstance()->last_mouse_location().ToString()); |
261 { | 261 { |
262 SCOPED_TRACE("1x2 NO WARP"); | 262 SCOPED_TRACE("1x2 NO WARP"); |
263 NoWarpTestBody(); | 263 NoWarpTestBody(); |
264 } | 264 } |
265 } | 265 } |
266 | 266 |
267 } // namespace aura | 267 } // namespace aura |
OLD | NEW |