| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // Helper method that maps a gfx::Display to an aura::Window. | 36 // Helper method that maps a gfx::Display to an aura::Window. |
| 37 aura::Window* GetRootWindowForDisplayId(int64_t display_id) { | 37 aura::Window* GetRootWindowForDisplayId(int64_t display_id) { |
| 38 return Shell::GetInstance() | 38 return Shell::GetInstance() |
| 39 ->window_tree_host_manager() | 39 ->window_tree_host_manager() |
| 40 ->GetRootWindowForDisplayId(display_id); | 40 ->GetRootWindowForDisplayId(display_id); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Helper method that maps an aura::Window to a gfx::Display. | 43 // Helper method that maps an aura::Window to a gfx::Display. |
| 44 gfx::Display GetDisplayFromWindow(aura::Window* window) { | 44 gfx::Display GetDisplayFromWindow(aura::Window* window) { |
| 45 return Shell::GetScreen()->GetDisplayNearestWindow(window); | 45 return gfx::Screen::GetScreen()->GetDisplayNearestWindow(window); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 ExtendedMouseWarpController::WarpRegion::WarpRegion( | 50 ExtendedMouseWarpController::WarpRegion::WarpRegion( |
| 51 int64_t a_display_id, | 51 int64_t a_display_id, |
| 52 int64_t b_display_id, | 52 int64_t b_display_id, |
| 53 const gfx::Rect& a_indicator_bounds, | 53 const gfx::Rect& a_indicator_bounds, |
| 54 const gfx::Rect& b_indicator_bounds) | 54 const gfx::Rect& b_indicator_bounds) |
| 55 : a_display_id_(a_display_id), | 55 : a_display_id_(a_display_id), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const gfx::Display& right = display_manager->GetDisplayAt(i); | 87 const gfx::Display& right = display_manager->GetDisplayAt(i); |
| 88 | 88 |
| 89 AddWarpRegion(CreateVerticalEdgeBounds(left, right, DisplayLayout::RIGHT), | 89 AddWarpRegion(CreateVerticalEdgeBounds(left, right, DisplayLayout::RIGHT), |
| 90 drag_source != nullptr); | 90 drag_source != nullptr); |
| 91 } | 91 } |
| 92 } else { | 92 } else { |
| 93 // Make sure to set |a| as the primary display, and |b| as the secondary | 93 // Make sure to set |a| as the primary display, and |b| as the secondary |
| 94 // display. DisplayLayout::Position is defined in terms of primary. | 94 // display. DisplayLayout::Position is defined in terms of primary. |
| 95 DisplayLayout::Position position = | 95 DisplayLayout::Position position = |
| 96 display_manager->GetCurrentDisplayLayout().position; | 96 display_manager->GetCurrentDisplayLayout().position; |
| 97 const gfx::Display& a = Shell::GetScreen()->GetPrimaryDisplay(); | 97 const gfx::Display& a = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
| 98 const gfx::Display& b = ScreenUtil::GetSecondaryDisplay(); | 98 const gfx::Display& b = ScreenUtil::GetSecondaryDisplay(); |
| 99 | 99 |
| 100 // TODO(oshima): Use ComputeBondary instead. | 100 // TODO(oshima): Use ComputeBondary instead. |
| 101 if (position == DisplayLayout::TOP || position == DisplayLayout::BOTTOM) { | 101 if (position == DisplayLayout::TOP || position == DisplayLayout::BOTTOM) { |
| 102 AddWarpRegion(CreateHorizontalEdgeBounds(a, b, position), | 102 AddWarpRegion(CreateHorizontalEdgeBounds(a, b, position), |
| 103 drag_source != nullptr); | 103 drag_source != nullptr); |
| 104 } else { | 104 } else { |
| 105 AddWarpRegion(CreateVerticalEdgeBounds(a, b, position), | 105 AddWarpRegion(CreateVerticalEdgeBounds(a, b, position), |
| 106 drag_source != nullptr); | 106 drag_source != nullptr); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 ExtendedMouseWarpController::~ExtendedMouseWarpController() { | 111 ExtendedMouseWarpController::~ExtendedMouseWarpController() { |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool ExtendedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) { | 114 bool ExtendedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) { |
| 115 if (Shell::GetScreen()->GetNumDisplays() <= 1 || !enabled_) | 115 if (gfx::Screen::GetScreen()->GetNumDisplays() <= 1 || !enabled_) |
| 116 return false; | 116 return false; |
| 117 | 117 |
| 118 aura::Window* target = static_cast<aura::Window*>(event->target()); | 118 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 119 gfx::Point point_in_screen = event->location(); | 119 gfx::Point point_in_screen = event->location(); |
| 120 ::wm::ConvertPointToScreen(target, &point_in_screen); | 120 ::wm::ConvertPointToScreen(target, &point_in_screen); |
| 121 | 121 |
| 122 // A native event may not exist in unit test. Generate the native point | 122 // A native event may not exist in unit test. Generate the native point |
| 123 // from the screen point instead. | 123 // from the screen point instead. |
| 124 if (!event->HasNativeEvent()) { | 124 if (!event->HasNativeEvent()) { |
| 125 if (!allow_non_native_event_) | 125 if (!allow_non_native_event_) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 upper_indicator_y = std::max(upper_indicator_y, upper_shared_y); | 270 upper_indicator_y = std::max(upper_indicator_y, upper_shared_y); |
| 271 } | 271 } |
| 272 a_indicator_bounds.set_y(upper_indicator_y); | 272 a_indicator_bounds.set_y(upper_indicator_y); |
| 273 a_indicator_bounds.set_height(lower_indicator_y - upper_indicator_y); | 273 a_indicator_bounds.set_height(lower_indicator_y - upper_indicator_y); |
| 274 | 274 |
| 275 return make_scoped_ptr( | 275 return make_scoped_ptr( |
| 276 new WarpRegion(a.id(), b.id(), a_indicator_bounds, b_indicator_bounds)); | 276 new WarpRegion(a.id(), b.id(), a_indicator_bounds, b_indicator_bounds)); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace ash | 279 } // namespace ash |
| OLD | NEW |