| 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_util.h" | 9 #include "ash/display/display_util.h" |
| 10 #include "ash/display/shared_display_edge_indicator.h" | 10 #include "ash/display/shared_display_edge_indicator.h" |
| 11 #include "ash/display/window_tree_host_manager.h" | 11 #include "ash/display/window_tree_host_manager.h" |
| 12 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/display/manager/display_layout.h" | 16 #include "ui/display/manager/display_layout.h" |
| 17 #include "ui/display/manager/display_manager.h" | 17 #include "ui/display/manager/display_manager.h" |
| 18 #include "ui/display/manager/display_manager_utilities.h" | 18 #include "ui/display/manager/display_manager_utilities.h" |
| 19 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
| 20 #include "ui/display/types/display_constants.h" |
| 20 #include "ui/events/event_utils.h" | 21 #include "ui/events/event_utils.h" |
| 21 #include "ui/wm/core/coordinate_conversion.h" | 22 #include "ui/wm/core/coordinate_conversion.h" |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 // Maximum size on the display edge that initiate snapping phantom window, | 28 // Maximum size on the display edge that initiate snapping phantom window, |
| 28 // from the corner of the display. | 29 // from the corner of the display. |
| 29 const int kMaximumSnapHeight = 16; | 30 const int kMaximumSnapHeight = 16; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 CHECK_EQ(b_display_id_, id); | 97 CHECK_EQ(b_display_id_, id); |
| 97 return b_indicator_bounds_; | 98 return b_indicator_bounds_; |
| 98 } | 99 } |
| 99 | 100 |
| 100 ExtendedMouseWarpController::ExtendedMouseWarpController( | 101 ExtendedMouseWarpController::ExtendedMouseWarpController( |
| 101 aura::Window* drag_source) | 102 aura::Window* drag_source) |
| 102 : drag_source_root_(drag_source), allow_non_native_event_(false) { | 103 : drag_source_root_(drag_source), allow_non_native_event_(false) { |
| 103 display::DisplayManager* display_manager = | 104 display::DisplayManager* display_manager = |
| 104 Shell::GetInstance()->display_manager(); | 105 Shell::GetInstance()->display_manager(); |
| 105 int64_t drag_source_id = drag_source ? GetDisplayIdFromWindow(drag_source) | 106 int64_t drag_source_id = drag_source ? GetDisplayIdFromWindow(drag_source) |
| 106 : display::Display::kInvalidDisplayID; | 107 : display::kInvalidDisplayId; |
| 107 display::Displays display_list = display_manager->active_display_list(); | 108 display::Displays display_list = display_manager->active_display_list(); |
| 108 // Try to create a Warp region for all possible two displays combination. | 109 // Try to create a Warp region for all possible two displays combination. |
| 109 // The following code does it by poping the last element in the list | 110 // The following code does it by poping the last element in the list |
| 110 // and then pairing with remaining displays in the list, until the list | 111 // and then pairing with remaining displays in the list, until the list |
| 111 // becomes single element. | 112 // becomes single element. |
| 112 while (display_list.size() > 1) { | 113 while (display_list.size() > 1) { |
| 113 display::Display display = display_list.back(); | 114 display::Display display = display_list.back(); |
| 114 display_list.pop_back(); | 115 display_list.pop_back(); |
| 115 for (const display::Display& peer : display_list) { | 116 for (const display::Display& peer : display_list) { |
| 116 std::unique_ptr<WarpRegion> region = | 117 std::unique_ptr<WarpRegion> region = |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 199 |
| 199 return false; | 200 return false; |
| 200 } | 201 } |
| 201 | 202 |
| 202 std::unique_ptr<ExtendedMouseWarpController::WarpRegion> | 203 std::unique_ptr<ExtendedMouseWarpController::WarpRegion> |
| 203 ExtendedMouseWarpController::CreateWarpRegion(const display::Display& a, | 204 ExtendedMouseWarpController::CreateWarpRegion(const display::Display& a, |
| 204 const display::Display& b, | 205 const display::Display& b, |
| 205 int64_t drag_source_id) { | 206 int64_t drag_source_id) { |
| 206 gfx::Rect a_edge; | 207 gfx::Rect a_edge; |
| 207 gfx::Rect b_edge; | 208 gfx::Rect b_edge; |
| 208 int snap_barrier = drag_source_id == display::Display::kInvalidDisplayID | 209 int snap_barrier = |
| 209 ? 0 | 210 drag_source_id == display::kInvalidDisplayId ? 0 : kMaximumSnapHeight; |
| 210 : kMaximumSnapHeight; | |
| 211 | 211 |
| 212 if (!display::ComputeBoundary(a, b, &a_edge, &b_edge)) | 212 if (!display::ComputeBoundary(a, b, &a_edge, &b_edge)) |
| 213 return nullptr; | 213 return nullptr; |
| 214 | 214 |
| 215 // Creates the snap window barrirer only when horizontally connected. | 215 // Creates the snap window barrirer only when horizontally connected. |
| 216 if (a_edge.height() > a_edge.width()) { | 216 if (a_edge.height() > a_edge.width()) { |
| 217 if (drag_source_id == a.id()) | 217 if (drag_source_id == a.id()) |
| 218 AdjustSourceEdgeBounds(a.bounds(), snap_barrier, &a_edge); | 218 AdjustSourceEdgeBounds(a.bounds(), snap_barrier, &a_edge); |
| 219 else if (drag_source_id == b.id()) | 219 else if (drag_source_id == b.id()) |
| 220 AdjustSourceEdgeBounds(b.bounds(), snap_barrier, &b_edge); | 220 AdjustSourceEdgeBounds(b.bounds(), snap_barrier, &b_edge); |
| 221 } | 221 } |
| 222 | 222 |
| 223 return base::MakeUnique<WarpRegion>(a.id(), b.id(), a_edge, b_edge); | 223 return base::MakeUnique<WarpRegion>(a.id(), b.id(), a_edge, b_edge); |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace ash | 226 } // namespace ash |
| OLD | NEW |