| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "ash/display/display_util.h" | 9 #include "ash/display/display_util.h" |
| 10 #include "ash/display/mirror_window_controller.h" | 10 #include "ash/display/mirror_window_controller.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 return nullptr; | 49 return nullptr; |
| 50 return GetMirroringAshWindowTreeHostForDisplayId( | 50 return GetMirroringAshWindowTreeHostForDisplayId( |
| 51 mirroring_display_list[index].id()) | 51 mirroring_display_list[index].id()) |
| 52 ->AsWindowTreeHost(); | 52 ->AsWindowTreeHost(); |
| 53 } | 53 } |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 UnifiedMouseWarpController::UnifiedMouseWarpController() | 58 UnifiedMouseWarpController::UnifiedMouseWarpController() |
| 59 : current_cursor_display_id_(display::Display::kInvalidDisplayID), | 59 : current_cursor_display_id_(display::kInvalidDisplayId), |
| 60 update_location_for_test_(false) {} | 60 update_location_for_test_(false) {} |
| 61 | 61 |
| 62 UnifiedMouseWarpController::~UnifiedMouseWarpController() {} | 62 UnifiedMouseWarpController::~UnifiedMouseWarpController() {} |
| 63 | 63 |
| 64 bool UnifiedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) { | 64 bool UnifiedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) { |
| 65 // Mirroring windows are created asynchronously, so compute the edge | 65 // Mirroring windows are created asynchronously, so compute the edge |
| 66 // beounds when we received an event instead of in constructor. | 66 // beounds when we received an event instead of in constructor. |
| 67 if (first_edge_bounds_in_native_.IsEmpty()) | 67 if (first_edge_bounds_in_native_.IsEmpty()) |
| 68 ComputeBounds(); | 68 ComputeBounds(); |
| 69 | 69 |
| 70 aura::Window* target = static_cast<aura::Window*>(event->target()); | 70 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 71 gfx::Point point_in_unified_host = event->location(); | 71 gfx::Point point_in_unified_host = event->location(); |
| 72 ::wm::ConvertPointToScreen(target, &point_in_unified_host); | 72 ::wm::ConvertPointToScreen(target, &point_in_unified_host); |
| 73 // The display bounds of the mirroring windows isn't scaled, so | 73 // The display bounds of the mirroring windows isn't scaled, so |
| 74 // transform back to the host coordinates. | 74 // transform back to the host coordinates. |
| 75 target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host); | 75 target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host); |
| 76 | 76 |
| 77 if (current_cursor_display_id_ != display::Display::kInvalidDisplayID) { | 77 if (current_cursor_display_id_ != display::kInvalidDisplayId) { |
| 78 aura::client::CursorClient* cursor_client = | 78 aura::client::CursorClient* cursor_client = |
| 79 aura::client::GetCursorClient(target->GetRootWindow()); | 79 aura::client::GetCursorClient(target->GetRootWindow()); |
| 80 if (cursor_client) { | 80 if (cursor_client) { |
| 81 display::Displays mirroring_display_list = | 81 display::Displays mirroring_display_list = |
| 82 Shell::GetInstance() | 82 Shell::GetInstance() |
| 83 ->display_manager() | 83 ->display_manager() |
| 84 ->software_mirroring_display_list(); | 84 ->software_mirroring_display_list(); |
| 85 int index = display::FindDisplayIndexContainingPoint( | 85 int index = display::FindDisplayIndexContainingPoint( |
| 86 mirroring_display_list, point_in_unified_host); | 86 mirroring_display_list, point_in_unified_host); |
| 87 if (index >= 0) { | 87 if (index >= 0) { |
| 88 const display::Display& new_display = mirroring_display_list[index]; | 88 const display::Display& new_display = mirroring_display_list[index]; |
| 89 if (current_cursor_display_id_ != new_display.id()) { | 89 if (current_cursor_display_id_ != new_display.id()) { |
| 90 cursor_client->SetDisplay(new_display); | 90 cursor_client->SetDisplay(new_display); |
| 91 current_cursor_display_id_ = display::Display::kInvalidDisplayID; | 91 current_cursor_display_id_ = display::kInvalidDisplayId; |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 // A native event may not exist in unit test. | 97 // A native event may not exist in unit test. |
| 98 if (!event->HasNativeEvent()) | 98 if (!event->HasNativeEvent()) |
| 99 return false; | 99 return false; |
| 100 | 100 |
| 101 gfx::Point point_in_native = | 101 gfx::Point point_in_native = |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 in_first_edge ? display_list[0].id() : display_list[1].id(); | 165 in_first_edge ? display_list[0].id() : display_list[1].id(); |
| 166 AshWindowTreeHost* target_ash_host = | 166 AshWindowTreeHost* target_ash_host = |
| 167 GetMirroringAshWindowTreeHostForDisplayId( | 167 GetMirroringAshWindowTreeHostForDisplayId( |
| 168 in_first_edge ? display_list[1].id() : display_list[0].id()); | 168 in_first_edge ? display_list[1].id() : display_list[0].id()); |
| 169 MoveCursorTo(target_ash_host, point_in_unified_host, | 169 MoveCursorTo(target_ash_host, point_in_unified_host, |
| 170 update_mouse_location_now); | 170 update_mouse_location_now); |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace ash | 174 } // namespace ash |
| OLD | NEW |