| 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" |
| 11 #include "ash/display/window_tree_host_manager.h" | 11 #include "ash/display/window_tree_host_manager.h" |
| 12 #include "ash/host/ash_window_tree_host.h" | 12 #include "ash/host/ash_window_tree_host.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ui/aura/client/cursor_client.h" | 14 #include "ui/aura/client/cursor_client.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
| 17 #include "ui/base/layout.h" | 17 #include "ui/base/layout.h" |
| 18 #include "ui/display/display_finder.h" |
| 18 #include "ui/display/display_layout.h" | 19 #include "ui/display/display_layout.h" |
| 19 #include "ui/display/manager/display_manager.h" | 20 #include "ui/display/manager/display_manager.h" |
| 20 #include "ui/display/manager/display_manager_utilities.h" | 21 #include "ui/display/manager/display_manager_utilities.h" |
| 21 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 22 #include "ui/events/event_utils.h" | 23 #include "ui/events/event_utils.h" |
| 23 #include "ui/wm/core/coordinate_conversion.h" | 24 #include "ui/wm/core/coordinate_conversion.h" |
| 24 | 25 |
| 25 namespace ash { | 26 namespace ash { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 AshWindowTreeHost* GetMirroringAshWindowTreeHostForDisplayId( | 30 AshWindowTreeHost* GetMirroringAshWindowTreeHostForDisplayId( |
| 30 int64_t display_id) { | 31 int64_t display_id) { |
| 31 return Shell::GetInstance() | 32 return Shell::GetInstance() |
| 32 ->window_tree_host_manager() | 33 ->window_tree_host_manager() |
| 33 ->mirror_window_controller() | 34 ->mirror_window_controller() |
| 34 ->GetAshWindowTreeHostForDisplayId(display_id); | 35 ->GetAshWindowTreeHostForDisplayId(display_id); |
| 35 } | 36 } |
| 36 | 37 |
| 37 #if defined(USE_OZONE) | 38 #if defined(USE_OZONE) |
| 38 // Find a WindowTreeHost used for mirroring displays that contains | 39 // Find a WindowTreeHost used for mirroring displays that contains |
| 39 // the |point_in_screen|. Returns nullptr if such WTH does not exist. | 40 // the |point_in_screen|. Returns nullptr if such WTH does not exist. |
| 40 aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint( | 41 aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint( |
| 41 const gfx::Point& point_in_screen) { | 42 const gfx::Point& point_in_screen) { |
| 42 display::Displays mirroring_display_list = | 43 display::Displays mirroring_display_list = |
| 43 Shell::GetInstance() | 44 Shell::GetInstance() |
| 44 ->display_manager() | 45 ->display_manager() |
| 45 ->software_mirroring_display_list(); | 46 ->software_mirroring_display_list(); |
| 46 int index = display::FindDisplayIndexContainingPoint(mirroring_display_list, | 47 auto iter = display::FindDisplayContainingPoint(mirroring_display_list, |
| 47 point_in_screen); | 48 point_in_screen); |
| 48 if (index < 0) | 49 if (iter == mirroring_display_list.end()) |
| 49 return nullptr; | 50 return nullptr; |
| 50 return GetMirroringAshWindowTreeHostForDisplayId( | 51 return GetMirroringAshWindowTreeHostForDisplayId(iter->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::kInvalidDisplayId), | 59 : current_cursor_display_id_(display::kInvalidDisplayId), |
| 60 update_location_for_test_(false) {} | 60 update_location_for_test_(false) {} |
| 61 | 61 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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::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 auto iter = display::FindDisplayContainingPoint(mirroring_display_list, |
| 86 mirroring_display_list, point_in_unified_host); | 86 point_in_unified_host); |
| 87 if (index >= 0) { | 87 if (iter != mirroring_display_list.end() && |
| 88 const display::Display& new_display = mirroring_display_list[index]; | 88 current_cursor_display_id_ != iter->id()) { |
| 89 if (current_cursor_display_id_ != new_display.id()) { | 89 cursor_client->SetDisplay(*iter); |
| 90 cursor_client->SetDisplay(new_display); | 90 current_cursor_display_id_ = display::kInvalidDisplayId; |
| 91 current_cursor_display_id_ = display::kInvalidDisplayId; | |
| 92 } | |
| 93 } | 91 } |
| 94 } | 92 } |
| 95 } | 93 } |
| 96 | 94 |
| 97 // A native event may not exist in unit test. | 95 // A native event may not exist in unit test. |
| 98 if (!event->HasNativeEvent()) | 96 if (!event->HasNativeEvent()) |
| 99 return false; | 97 return false; |
| 100 | 98 |
| 101 gfx::Point point_in_native = | 99 gfx::Point point_in_native = |
| 102 ui::EventSystemLocationFromNative(event->native_event()); | 100 ui::EventSystemLocationFromNative(event->native_event()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 in_first_edge ? display_list[0].id() : display_list[1].id(); | 164 in_first_edge ? display_list[0].id() : display_list[1].id(); |
| 167 AshWindowTreeHost* target_ash_host = | 165 AshWindowTreeHost* target_ash_host = |
| 168 GetMirroringAshWindowTreeHostForDisplayId( | 166 GetMirroringAshWindowTreeHostForDisplayId( |
| 169 in_first_edge ? display_list[1].id() : display_list[0].id()); | 167 in_first_edge ? display_list[1].id() : display_list[0].id()); |
| 170 MoveCursorTo(target_ash_host, point_in_unified_host, | 168 MoveCursorTo(target_ash_host, point_in_unified_host, |
| 171 update_mouse_location_now); | 169 update_mouse_location_now); |
| 172 return true; | 170 return true; |
| 173 } | 171 } |
| 174 | 172 |
| 175 } // namespace ash | 173 } // namespace ash |
| OLD | NEW |