| 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/property_util.h" | 9 #include "ash/wm/property_util.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 width += x_multiplier * (*delta_x); | 264 width += x_multiplier * (*delta_x); |
| 265 | 265 |
| 266 // Ensure we don't shrink past the minimum width and clamp delta_x | 266 // Ensure we don't shrink past the minimum width and clamp delta_x |
| 267 // for the window origin computation. | 267 // for the window origin computation. |
| 268 if (width < min_width) { | 268 if (width < min_width) { |
| 269 width = min_width; | 269 width = min_width; |
| 270 *delta_x = -x_multiplier * (details.initial_bounds.width() - min_width); | 270 *delta_x = -x_multiplier * (details.initial_bounds.width() - min_width); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // And don't let the window go bigger than the display. | 273 // And don't let the window go bigger than the display. |
| 274 int max_width = | 274 int max_width = Shell::GetAshScreen()->GetDisplayNearestWindow( |
| 275 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().width(); | 275 details.window).bounds().width(); |
| 276 if (width > max_width) { | 276 if (width > max_width) { |
| 277 width = max_width; | 277 width = max_width; |
| 278 *delta_x = -x_multiplier * (details.initial_bounds.width() - max_width); | 278 *delta_x = -x_multiplier * (details.initial_bounds.width() - max_width); |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 return width; | 281 return width; |
| 282 } | 282 } |
| 283 | 283 |
| 284 // static | 284 // static |
| 285 int WindowResizer::GetHeightForDrag(const Details& details, | 285 int WindowResizer::GetHeightForDrag(const Details& details, |
| 286 int min_height, | 286 int min_height, |
| 287 int* delta_y) { | 287 int* delta_y) { |
| 288 int height = details.initial_bounds.height(); | 288 int height = details.initial_bounds.height(); |
| 289 if (details.size_change_direction & kBoundsChangeDirection_Vertical) { | 289 if (details.size_change_direction & kBoundsChangeDirection_Vertical) { |
| 290 // Along the bottom edge, positive delta_y increases the window size. | 290 // Along the bottom edge, positive delta_y increases the window size. |
| 291 int y_multiplier = IsBottomEdge(details.window_component) ? 1 : -1; | 291 int y_multiplier = IsBottomEdge(details.window_component) ? 1 : -1; |
| 292 height += y_multiplier * (*delta_y); | 292 height += y_multiplier * (*delta_y); |
| 293 | 293 |
| 294 // Ensure we don't shrink past the minimum height and clamp delta_y | 294 // Ensure we don't shrink past the minimum height and clamp delta_y |
| 295 // for the window origin computation. | 295 // for the window origin computation. |
| 296 if (height < min_height) { | 296 if (height < min_height) { |
| 297 height = min_height; | 297 height = min_height; |
| 298 *delta_y = -y_multiplier * (details.initial_bounds.height() - min_height); | 298 *delta_y = -y_multiplier * (details.initial_bounds.height() - min_height); |
| 299 } | 299 } |
| 300 | 300 |
| 301 // And don't let the window go bigger than the display. | 301 // And don't let the window go bigger than the display. |
| 302 int max_height = | 302 int max_height = Shell::GetAshScreen()->GetDisplayNearestWindow( |
| 303 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height(); | 303 details.window).bounds().height(); |
| 304 if (height > max_height) { | 304 if (height > max_height) { |
| 305 height = max_height; | 305 height = max_height; |
| 306 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height); | 306 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 return height; | 309 return height; |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace aura | 312 } // namespace aura |
| OLD | NEW |