OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/window_resizer.h" | 5 #include "ash/wm/window_resizer.h" |
6 | 6 |
7 #include "ash/screen_ash.h" | 7 #include "ash/screen_ash.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/coordinate_conversion.h" |
9 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| 11 #include "ui/aura/client/screen_position_client.h" |
10 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
11 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
12 #include "ui/aura/window_delegate.h" | 14 #include "ui/aura/window_delegate.h" |
13 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
14 #include "ui/base/ui_base_types.h" | 16 #include "ui/base/ui_base_types.h" |
15 #include "ui/compositor/scoped_layer_animation_settings.h" | 17 #include "ui/compositor/scoped_layer_animation_settings.h" |
16 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
17 | 19 |
18 namespace ash { | 20 namespace ash { |
19 | 21 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // static | 178 // static |
177 int WindowResizer::AlignToGridRoundDown(int location, int grid_size) { | 179 int WindowResizer::AlignToGridRoundDown(int location, int grid_size) { |
178 if (grid_size <= 1 || location % grid_size == 0) | 180 if (grid_size <= 1 || location % grid_size == 0) |
179 return location; | 181 return location; |
180 return location / grid_size * grid_size; | 182 return location / grid_size * grid_size; |
181 } | 183 } |
182 | 184 |
183 // static | 185 // static |
184 gfx::Rect WindowResizer::CalculateBoundsForDrag( | 186 gfx::Rect WindowResizer::CalculateBoundsForDrag( |
185 const Details& details, | 187 const Details& details, |
186 const gfx::Point& location, | 188 const gfx::Point& location_in_screen, |
187 int grid_size) { | 189 int grid_size) { |
188 if (!details.is_resizable) | 190 if (!details.is_resizable) |
189 return details.initial_bounds; | 191 return details.initial_bounds; |
190 | 192 |
| 193 gfx::Point location = location_in_screen; |
| 194 wm::ConvertPointFromScreen(details.window->GetRootWindow(), &location); |
| 195 |
191 int delta_x = location.x() - details.initial_location_in_parent.x(); | 196 int delta_x = location.x() - details.initial_location_in_parent.x(); |
192 int delta_y = location.y() - details.initial_location_in_parent.y(); | 197 int delta_y = location.y() - details.initial_location_in_parent.y(); |
193 | 198 |
194 // The minimize size constraint may limit how much we change the window | 199 // The minimize size constraint may limit how much we change the window |
195 // position. For example, dragging the left edge to the right should stop | 200 // position. For example, dragging the left edge to the right should stop |
196 // repositioning the window when the minimize size is reached. | 201 // repositioning the window when the minimize size is reached. |
197 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y, grid_size); | 202 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y, grid_size); |
198 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); | 203 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); |
199 | 204 |
200 gfx::Rect new_bounds(origin, size); | 205 gfx::Rect new_bounds(origin, size); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height(); | 337 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height(); |
333 if (height > max_height) { | 338 if (height > max_height) { |
334 height = max_height; | 339 height = max_height; |
335 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height); | 340 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height); |
336 } | 341 } |
337 } | 342 } |
338 return height; | 343 return height; |
339 } | 344 } |
340 | 345 |
341 } // namespace aura | 346 } // namespace aura |
OLD | NEW |