| 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_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/display_util.h" | 10 #include "ash/display/display_util.h" |
| 11 #include "ash/display/mirror_window_controller.h" | 11 #include "ash/display/mirror_window_controller.h" |
| 12 #include "ash/display/window_tree_host_manager.h" | 12 #include "ash/display/window_tree_host_manager.h" |
| 13 #include "ash/host/ash_window_tree_host.h" | 13 #include "ash/host/ash_window_tree_host.h" |
| 14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 15 #include "ui/aura/client/cursor_client.h" | 15 #include "ui/aura/client/cursor_client.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_tree_host.h" | 17 #include "ui/aura/window_tree_host.h" |
| 18 #include "ui/base/layout.h" | 18 #include "ui/base/layout.h" |
| 19 #include "ui/display/manager/display_layout.h" | 19 #include "ui/display/manager/display_layout.h" |
| 20 #include "ui/display/manager/display_manager_utilities.h" |
| 20 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
| 21 #include "ui/events/event_utils.h" | 22 #include "ui/events/event_utils.h" |
| 22 #include "ui/wm/core/coordinate_conversion.h" | 23 #include "ui/wm/core/coordinate_conversion.h" |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 AshWindowTreeHost* GetMirroringAshWindowTreeHostForDisplayId( | 29 AshWindowTreeHost* GetMirroringAshWindowTreeHostForDisplayId( |
| 29 int64_t display_id) { | 30 int64_t display_id) { |
| 30 return Shell::GetInstance() | 31 return Shell::GetInstance() |
| 31 ->window_tree_host_manager() | 32 ->window_tree_host_manager() |
| 32 ->mirror_window_controller() | 33 ->mirror_window_controller() |
| 33 ->GetAshWindowTreeHostForDisplayId(display_id); | 34 ->GetAshWindowTreeHostForDisplayId(display_id); |
| 34 } | 35 } |
| 35 | 36 |
| 36 #if defined(USE_OZONE) | 37 #if defined(USE_OZONE) |
| 37 // Find a WindowTreeHost used for mirroring displays that contains | 38 // Find a WindowTreeHost used for mirroring displays that contains |
| 38 // the |point_in_screen|. Returns nullptr if such WTH does not exist. | 39 // the |point_in_screen|. Returns nullptr if such WTH does not exist. |
| 39 aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint( | 40 aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint( |
| 40 const gfx::Point& point_in_screen) { | 41 const gfx::Point& point_in_screen) { |
| 41 display::DisplayList mirroring_display_list = | 42 display::DisplayList mirroring_display_list = |
| 42 Shell::GetInstance() | 43 Shell::GetInstance() |
| 43 ->display_manager() | 44 ->display_manager() |
| 44 ->software_mirroring_display_list(); | 45 ->software_mirroring_display_list(); |
| 45 int index = | 46 int index = display::FindDisplayIndexContainingPoint(mirroring_display_list, |
| 46 FindDisplayIndexContainingPoint(mirroring_display_list, point_in_screen); | 47 point_in_screen); |
| 47 if (index < 0) | 48 if (index < 0) |
| 48 return nullptr; | 49 return nullptr; |
| 49 return GetMirroringAshWindowTreeHostForDisplayId( | 50 return GetMirroringAshWindowTreeHostForDisplayId( |
| 50 mirroring_display_list[index].id()) | 51 mirroring_display_list[index].id()) |
| 51 ->AsWindowTreeHost(); | 52 ->AsWindowTreeHost(); |
| 52 } | 53 } |
| 53 #endif | 54 #endif |
| 54 | 55 |
| 55 } // namespace | 56 } // namespace |
| 56 | 57 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 74 target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host); | 75 target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host); |
| 75 | 76 |
| 76 if (current_cursor_display_id_ != display::Display::kInvalidDisplayID) { | 77 if (current_cursor_display_id_ != display::Display::kInvalidDisplayID) { |
| 77 aura::client::CursorClient* cursor_client = | 78 aura::client::CursorClient* cursor_client = |
| 78 aura::client::GetCursorClient(target->GetRootWindow()); | 79 aura::client::GetCursorClient(target->GetRootWindow()); |
| 79 if (cursor_client) { | 80 if (cursor_client) { |
| 80 display::DisplayList mirroring_display_list = | 81 display::DisplayList mirroring_display_list = |
| 81 Shell::GetInstance() | 82 Shell::GetInstance() |
| 82 ->display_manager() | 83 ->display_manager() |
| 83 ->software_mirroring_display_list(); | 84 ->software_mirroring_display_list(); |
| 84 int index = FindDisplayIndexContainingPoint(mirroring_display_list, | 85 int index = display::FindDisplayIndexContainingPoint( |
| 85 point_in_unified_host); | 86 mirroring_display_list, point_in_unified_host); |
| 86 if (index >= 0) { | 87 if (index >= 0) { |
| 87 const display::Display& new_display = mirroring_display_list[index]; | 88 const display::Display& new_display = mirroring_display_list[index]; |
| 88 if (current_cursor_display_id_ != new_display.id()) { | 89 if (current_cursor_display_id_ != new_display.id()) { |
| 89 cursor_client->SetDisplay(new_display); | 90 cursor_client->SetDisplay(new_display); |
| 90 current_cursor_display_id_ = display::Display::kInvalidDisplayID; | 91 current_cursor_display_id_ = display::Display::kInvalidDisplayID; |
| 91 } | 92 } |
| 92 } | 93 } |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 | 96 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 126 ->software_mirroring_display_list(); | 127 ->software_mirroring_display_list(); |
| 127 | 128 |
| 128 if (display_list.size() < 2) { | 129 if (display_list.size() < 2) { |
| 129 LOG(ERROR) << "Mirroring Display lost during re-configuration"; | 130 LOG(ERROR) << "Mirroring Display lost during re-configuration"; |
| 130 return; | 131 return; |
| 131 } | 132 } |
| 132 LOG_IF(ERROR, display_list.size() > 2) << "Only two displays are supported"; | 133 LOG_IF(ERROR, display_list.size() > 2) << "Only two displays are supported"; |
| 133 | 134 |
| 134 const display::Display& first = display_list[0]; | 135 const display::Display& first = display_list[0]; |
| 135 const display::Display& second = display_list[1]; | 136 const display::Display& second = display_list[1]; |
| 136 bool success = ComputeBoundary(first, second, &first_edge_bounds_in_native_, | 137 bool success = |
| 137 &second_edge_bounds_in_native_); | 138 display::ComputeBoundary(first, second, &first_edge_bounds_in_native_, |
| 139 &second_edge_bounds_in_native_); |
| 138 DCHECK(success); | 140 DCHECK(success); |
| 139 | 141 |
| 140 first_edge_bounds_in_native_ = | 142 first_edge_bounds_in_native_ = |
| 141 GetNativeEdgeBounds(GetMirroringAshWindowTreeHostForDisplayId(first.id()), | 143 GetNativeEdgeBounds(GetMirroringAshWindowTreeHostForDisplayId(first.id()), |
| 142 first_edge_bounds_in_native_); | 144 first_edge_bounds_in_native_); |
| 143 | 145 |
| 144 second_edge_bounds_in_native_ = GetNativeEdgeBounds( | 146 second_edge_bounds_in_native_ = GetNativeEdgeBounds( |
| 145 GetMirroringAshWindowTreeHostForDisplayId(second.id()), | 147 GetMirroringAshWindowTreeHostForDisplayId(second.id()), |
| 146 second_edge_bounds_in_native_); | 148 second_edge_bounds_in_native_); |
| 147 } | 149 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 163 in_first_edge ? display_list[0].id() : display_list[1].id(); | 165 in_first_edge ? display_list[0].id() : display_list[1].id(); |
| 164 AshWindowTreeHost* target_ash_host = | 166 AshWindowTreeHost* target_ash_host = |
| 165 GetMirroringAshWindowTreeHostForDisplayId( | 167 GetMirroringAshWindowTreeHostForDisplayId( |
| 166 in_first_edge ? display_list[1].id() : display_list[0].id()); | 168 in_first_edge ? display_list[1].id() : display_list[0].id()); |
| 167 MoveCursorTo(target_ash_host, point_in_unified_host, | 169 MoveCursorTo(target_ash_host, point_in_unified_host, |
| 168 update_mouse_location_now); | 170 update_mouse_location_now); |
| 169 return true; | 171 return true; |
| 170 } | 172 } |
| 171 | 173 |
| 172 } // namespace ash | 174 } // namespace ash |
| OLD | NEW |