| 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/extended_mouse_warp_controller.h" | 5 #include "ash/display/extended_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" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if (drag_source) { | 51 if (drag_source) { |
| 52 shared_display_edge_indicator_->Show(src_indicator_bounds_, | 52 shared_display_edge_indicator_->Show(src_indicator_bounds_, |
| 53 dst_indicator_bounds_); | 53 dst_indicator_bounds_); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 ExtendedMouseWarpController::~ExtendedMouseWarpController() { | 57 ExtendedMouseWarpController::~ExtendedMouseWarpController() { |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool ExtendedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) { | 60 bool ExtendedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) { |
| 61 if (Shell::GetScreen()->GetNumDisplays() <= 1 || !enabled_) | 61 if (gfx::Screen::GetScreen()->GetNumDisplays() <= 1 || !enabled_) |
| 62 return false; | 62 return false; |
| 63 | 63 |
| 64 aura::Window* target = static_cast<aura::Window*>(event->target()); | 64 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 65 gfx::Point point_in_screen = event->location(); | 65 gfx::Point point_in_screen = event->location(); |
| 66 ::wm::ConvertPointToScreen(target, &point_in_screen); | 66 ::wm::ConvertPointToScreen(target, &point_in_screen); |
| 67 | 67 |
| 68 // A native event may not exist in unit test. Generate the native point | 68 // A native event may not exist in unit test. Generate the native point |
| 69 // from the screen point instead. | 69 // from the screen point instead. |
| 70 if (!event->HasNativeEvent()) { | 70 if (!event->HasNativeEvent()) { |
| 71 if (!allow_non_native_event_) | 71 if (!allow_non_native_event_) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 MoveCursorTo(target_ash_host, point_in_screen, update_mouse_location_now); | 116 MoveCursorTo(target_ash_host, point_in_screen, update_mouse_location_now); |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ExtendedMouseWarpController::UpdateHorizontalEdgeBounds() { | 120 void ExtendedMouseWarpController::UpdateHorizontalEdgeBounds() { |
| 121 bool from_primary = Shell::GetPrimaryRootWindow() == drag_source_root_; | 121 bool from_primary = Shell::GetPrimaryRootWindow() == drag_source_root_; |
| 122 // GetPrimaryDisplay returns an object on stack, so copy the bounds | 122 // GetPrimaryDisplay returns an object on stack, so copy the bounds |
| 123 // instead of using reference. | 123 // instead of using reference. |
| 124 const gfx::Rect primary_bounds = | 124 const gfx::Rect primary_bounds = |
| 125 Shell::GetScreen()->GetPrimaryDisplay().bounds(); | 125 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 126 const gfx::Rect secondary_bounds = ScreenUtil::GetSecondaryDisplay().bounds(); | 126 const gfx::Rect secondary_bounds = ScreenUtil::GetSecondaryDisplay().bounds(); |
| 127 DisplayLayout::Position position = Shell::GetInstance() | 127 DisplayLayout::Position position = Shell::GetInstance() |
| 128 ->display_manager() | 128 ->display_manager() |
| 129 ->GetCurrentDisplayLayout() | 129 ->GetCurrentDisplayLayout() |
| 130 .position; | 130 .position; |
| 131 | 131 |
| 132 src_indicator_bounds_.set_x( | 132 src_indicator_bounds_.set_x( |
| 133 std::max(primary_bounds.x(), secondary_bounds.x())); | 133 std::max(primary_bounds.x(), secondary_bounds.x())); |
| 134 src_indicator_bounds_.set_width( | 134 src_indicator_bounds_.set_width( |
| 135 std::min(primary_bounds.right(), secondary_bounds.right()) - | 135 std::min(primary_bounds.right(), secondary_bounds.right()) - |
| (...skipping 20 matching lines...) Expand all Loading... |
| 156 dst_edge_bounds_in_native_ = GetNativeEdgeBounds( | 156 dst_edge_bounds_in_native_ = GetNativeEdgeBounds( |
| 157 GetRootWindowController(dst_root)->ash_host(), dst_indicator_bounds_); | 157 GetRootWindowController(dst_root)->ash_host(), dst_indicator_bounds_); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void ExtendedMouseWarpController::UpdateVerticalEdgeBounds() { | 160 void ExtendedMouseWarpController::UpdateVerticalEdgeBounds() { |
| 161 int snap_height = drag_source_root_ ? kMaximumSnapHeight : 0; | 161 int snap_height = drag_source_root_ ? kMaximumSnapHeight : 0; |
| 162 bool in_primary = Shell::GetPrimaryRootWindow() == drag_source_root_; | 162 bool in_primary = Shell::GetPrimaryRootWindow() == drag_source_root_; |
| 163 // GetPrimaryDisplay returns an object on stack, so copy the bounds | 163 // GetPrimaryDisplay returns an object on stack, so copy the bounds |
| 164 // instead of using reference. | 164 // instead of using reference. |
| 165 const gfx::Rect primary_bounds = | 165 const gfx::Rect primary_bounds = |
| 166 Shell::GetScreen()->GetPrimaryDisplay().bounds(); | 166 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 167 const gfx::Rect secondary_bounds = ScreenUtil::GetSecondaryDisplay().bounds(); | 167 const gfx::Rect secondary_bounds = ScreenUtil::GetSecondaryDisplay().bounds(); |
| 168 DisplayLayout::Position position = Shell::GetInstance() | 168 DisplayLayout::Position position = Shell::GetInstance() |
| 169 ->display_manager() | 169 ->display_manager() |
| 170 ->GetCurrentDisplayLayout() | 170 ->GetCurrentDisplayLayout() |
| 171 .position; | 171 .position; |
| 172 | 172 |
| 173 int upper_shared_y = std::max(primary_bounds.y(), secondary_bounds.y()); | 173 int upper_shared_y = std::max(primary_bounds.y(), secondary_bounds.y()); |
| 174 int lower_shared_y = | 174 int lower_shared_y = |
| 175 std::min(primary_bounds.bottom(), secondary_bounds.bottom()); | 175 std::min(primary_bounds.bottom(), secondary_bounds.bottom()); |
| 176 int shared_height = lower_shared_y - upper_shared_y; | 176 int shared_height = lower_shared_y - upper_shared_y; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 void ExtendedMouseWarpController::GetSrcAndDstRootWindows( | 226 void ExtendedMouseWarpController::GetSrcAndDstRootWindows( |
| 227 aura::Window** src_root, | 227 aura::Window** src_root, |
| 228 aura::Window** dst_root) { | 228 aura::Window** dst_root) { |
| 229 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 229 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 230 *src_root = drag_source_root_ ? drag_source_root_ | 230 *src_root = drag_source_root_ ? drag_source_root_ |
| 231 : Shell::GetInstance()->GetPrimaryRootWindow(); | 231 : Shell::GetInstance()->GetPrimaryRootWindow(); |
| 232 *dst_root = root_windows[0] == *src_root ? root_windows[1] : root_windows[0]; | 232 *dst_root = root_windows[0] == *src_root ? root_windows[1] : root_windows[0]; |
| 233 } | 233 } |
| 234 | 234 |
| 235 } // namespace ash | 235 } // namespace ash |
| OLD | NEW |