Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: ash/display/extended_mouse_warp_controller.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/display/event_transformation_handler.cc ('k') | ash/display/mirror_window_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ExtendedMouseWarpController::WarpRegion::GetIndicatorBoundsForTest( 92 ExtendedMouseWarpController::WarpRegion::GetIndicatorBoundsForTest(
93 int64_t id) const { 93 int64_t id) const {
94 if (a_display_id_ == id) 94 if (a_display_id_ == id)
95 return a_indicator_bounds_; 95 return a_indicator_bounds_;
96 CHECK_EQ(b_display_id_, id); 96 CHECK_EQ(b_display_id_, id);
97 return b_indicator_bounds_; 97 return b_indicator_bounds_;
98 } 98 }
99 99
100 ExtendedMouseWarpController::ExtendedMouseWarpController( 100 ExtendedMouseWarpController::ExtendedMouseWarpController(
101 aura::Window* drag_source) 101 aura::Window* drag_source)
102 : drag_source_root_(drag_source), 102 : drag_source_root_(drag_source), allow_non_native_event_(false) {
103 allow_non_native_event_(false) {
104 ash::DisplayManager* display_manager = 103 ash::DisplayManager* display_manager =
105 Shell::GetInstance()->display_manager(); 104 Shell::GetInstance()->display_manager();
106 int64_t drag_source_id = drag_source ? GetDisplayIdFromWindow(drag_source) 105 int64_t drag_source_id = drag_source ? GetDisplayIdFromWindow(drag_source)
107 : display::Display::kInvalidDisplayID; 106 : display::Display::kInvalidDisplayID;
108 display::DisplayList display_list = display_manager->active_display_list(); 107 display::DisplayList display_list = display_manager->active_display_list();
109 // Try to create a Warp region for all possible two displays combination. 108 // Try to create a Warp region for all possible two displays combination.
110 // The following code does it by poping the last element in the list 109 // The following code does it by poping the last element in the list
111 // and then pairing with remaining displays in the list, until the list 110 // and then pairing with remaining displays in the list, until the list
112 // becomes single element. 111 // becomes single element.
113 while (display_list.size() > 1) { 112 while (display_list.size() > 1) {
114 display::Display display = display_list.back(); 113 display::Display display = display_list.back();
115 display_list.pop_back(); 114 display_list.pop_back();
116 for (const display::Display& peer : display_list) { 115 for (const display::Display& peer : display_list) {
117 std::unique_ptr<WarpRegion> region = 116 std::unique_ptr<WarpRegion> region =
118 CreateWarpRegion(display, peer, drag_source_id); 117 CreateWarpRegion(display, peer, drag_source_id);
119 if (region) 118 if (region)
120 AddWarpRegion(std::move(region), drag_source != nullptr); 119 AddWarpRegion(std::move(region), drag_source != nullptr);
121 } 120 }
122 } 121 }
123 } 122 }
124 123
125 ExtendedMouseWarpController::~ExtendedMouseWarpController() { 124 ExtendedMouseWarpController::~ExtendedMouseWarpController() {}
126 }
127 125
128 bool ExtendedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) { 126 bool ExtendedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) {
129 if (display::Screen::GetScreen()->GetNumDisplays() <= 1 || !enabled_) 127 if (display::Screen::GetScreen()->GetNumDisplays() <= 1 || !enabled_)
130 return false; 128 return false;
131 129
132 aura::Window* target = static_cast<aura::Window*>(event->target()); 130 aura::Window* target = static_cast<aura::Window*>(event->target());
133 gfx::Point point_in_screen = event->location(); 131 gfx::Point point_in_screen = event->location();
134 ::wm::ConvertPointToScreen(target, &point_in_screen); 132 ::wm::ConvertPointToScreen(target, &point_in_screen);
135 133
136 // A native event may not exist in unit test. Generate the native point 134 // A native event may not exist in unit test. Generate the native point
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 if (drag_source_id == a.id()) 217 if (drag_source_id == a.id())
220 AdjustSourceEdgeBounds(a.bounds(), snap_barrier, &a_edge); 218 AdjustSourceEdgeBounds(a.bounds(), snap_barrier, &a_edge);
221 else if (drag_source_id == b.id()) 219 else if (drag_source_id == b.id())
222 AdjustSourceEdgeBounds(b.bounds(), snap_barrier, &b_edge); 220 AdjustSourceEdgeBounds(b.bounds(), snap_barrier, &b_edge);
223 } 221 }
224 222
225 return base::WrapUnique(new WarpRegion(a.id(), b.id(), a_edge, b_edge)); 223 return base::WrapUnique(new WarpRegion(a.id(), b.id(), a_edge, b_edge));
226 } 224 }
227 225
228 } // namespace ash 226 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/event_transformation_handler.cc ('k') | ash/display/mirror_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698