OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/display_util.h" | 5 #include "ash/display/display_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
11 #include "ash/host/ash_window_tree_host.h" | 11 #include "ash/host/ash_window_tree_host.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/wm/window_util.h" | |
Jun Mukai
2015/05/12 17:08:46
Is this necessary?
oshima
2015/05/12 18:24:25
Done.
| |
13 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
14 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
15 #include "ui/gfx/geometry/point.h" | 16 #include "ui/gfx/geometry/point.h" |
16 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
17 #include "ui/wm/core/coordinate_conversion.h" | 18 #include "ui/wm/core/coordinate_conversion.h" |
18 | 19 |
19 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
20 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
21 #endif | 22 #endif |
22 | 23 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 break; | 158 break; |
158 } | 159 } |
159 } | 160 } |
160 } | 161 } |
161 | 162 |
162 gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host, | 163 gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host, |
163 const gfx::Rect& bounds_in_screen) { | 164 const gfx::Rect& bounds_in_screen) { |
164 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 165 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
165 gfx::Rect native_bounds = host->GetBounds(); | 166 gfx::Rect native_bounds = host->GetBounds(); |
166 native_bounds.Inset(ash_host->GetHostInsets()); | 167 native_bounds.Inset(ash_host->GetHostInsets()); |
167 | 168 gfx::Point start_in_native = bounds_in_screen.origin(); |
168 bool vertical = bounds_in_screen.width() < bounds_in_screen.height(); | 169 gfx::Point end_in_native(bounds_in_screen.right(), bounds_in_screen.bottom()); |
Jun Mukai
2015/05/12 17:08:46
nit: end_in_native = bounds_in_screen.bottom_right
oshima
2015/05/12 18:24:25
Done.
| |
169 gfx::Point start_in_native; | |
170 gfx::Point end_in_native; | |
171 | |
172 if (vertical) { | |
173 start_in_native = bounds_in_screen.origin(); | |
174 end_in_native = start_in_native; | |
175 end_in_native.set_y(bounds_in_screen.bottom()); | |
176 } else { | |
177 start_in_native = bounds_in_screen.origin(); | |
178 end_in_native = start_in_native; | |
179 end_in_native.set_x(bounds_in_screen.right()); | |
180 } | |
181 | 170 |
182 ConvertPointFromScreenToNative(host, &start_in_native); | 171 ConvertPointFromScreenToNative(host, &start_in_native); |
183 ConvertPointFromScreenToNative(host, &end_in_native); | 172 ConvertPointFromScreenToNative(host, &end_in_native); |
184 if (vertical) { | 173 |
174 if (std::abs(start_in_native.x() - end_in_native.x()) < | |
175 std::abs(start_in_native.y() - end_in_native.y())) { | |
185 // vertical in native | 176 // vertical in native |
186 int x = std::abs(native_bounds.x() - start_in_native.x()) < | 177 int x = std::abs(native_bounds.x() - start_in_native.x()) < |
187 std::abs(native_bounds.right() - start_in_native.x()) | 178 std::abs(native_bounds.right() - start_in_native.x()) |
188 ? native_bounds.x() | 179 ? native_bounds.x() |
189 : native_bounds.right() - 1; | 180 : native_bounds.right() - 1; |
190 return gfx::Rect(x, std::min(start_in_native.y(), end_in_native.y()), 1, | 181 return gfx::Rect(x, std::min(start_in_native.y(), end_in_native.y()), 1, |
191 end_in_native.y() - start_in_native.y()); | 182 std::abs(end_in_native.y() - start_in_native.y())); |
192 } else { | 183 } else { |
193 // horizontal in native | 184 // horizontal in native |
194 int y = std::abs(native_bounds.y() - start_in_native.y()) < | 185 int y = std::abs(native_bounds.y() - start_in_native.y()) < |
195 std::abs(native_bounds.bottom() - start_in_native.y()) | 186 std::abs(native_bounds.bottom() - start_in_native.y()) |
196 ? native_bounds.y() | 187 ? native_bounds.y() |
197 : native_bounds.bottom() - 1; | 188 : native_bounds.bottom() - 1; |
198 return gfx::Rect(std::min(start_in_native.x(), end_in_native.x()), y, | 189 return gfx::Rect(std::min(start_in_native.x(), end_in_native.x()), y, |
199 end_in_native.x() - start_in_native.x(), 1); | 190 std::abs(end_in_native.x() - start_in_native.x()), 1); |
200 } | 191 } |
201 } | 192 } |
202 | 193 |
203 // Moves the cursor to the point inside the root that is closest to | 194 // Moves the cursor to the point inside the root that is closest to |
204 // the point_in_screen, which is outside of the root window. | 195 // the point_in_screen, which is outside of the root window. |
205 void MoveCursorTo(AshWindowTreeHost* ash_host, | 196 void MoveCursorTo(AshWindowTreeHost* ash_host, |
206 const gfx::Point& point_in_screen, | 197 const gfx::Point& point_in_screen, |
207 bool update_last_location_now) { | 198 bool update_last_location_now) { |
208 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 199 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
209 gfx::Point point_in_native = point_in_screen; | 200 gfx::Point point_in_native = point_in_screen; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, | 237 int FindDisplayIndexContainingPoint(const std::vector<gfx::Display>& displays, |
247 const gfx::Point& point_in_screen) { | 238 const gfx::Point& point_in_screen) { |
248 auto iter = std::find_if(displays.begin(), displays.end(), | 239 auto iter = std::find_if(displays.begin(), displays.end(), |
249 [point_in_screen](const gfx::Display& display) { | 240 [point_in_screen](const gfx::Display& display) { |
250 return display.bounds().Contains(point_in_screen); | 241 return display.bounds().Contains(point_in_screen); |
251 }); | 242 }); |
252 return iter == displays.end() ? -1 : (iter - displays.begin()); | 243 return iter == displays.end() ? -1 : (iter - displays.begin()); |
253 } | 244 } |
254 | 245 |
255 } // namespace ash | 246 } // namespace ash |
OLD | NEW |