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/shell.h" | 7 #include "ash/shell.h" |
8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // repositioning the window when the minimize size is reached. | 195 // repositioning the window when the minimize size is reached. |
196 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y, grid_size); | 196 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y, grid_size); |
197 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); | 197 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); |
198 | 198 |
199 gfx::Rect new_bounds(origin, size); | 199 gfx::Rect new_bounds(origin, size); |
200 // Update bottom edge to stay in the work area when we are resizing | 200 // Update bottom edge to stay in the work area when we are resizing |
201 // by dragging the bottome edge or corners. | 201 // by dragging the bottome edge or corners. |
202 if (details.window_component == HTBOTTOM || | 202 if (details.window_component == HTBOTTOM || |
203 details.window_component == HTBOTTOMRIGHT || | 203 details.window_component == HTBOTTOMRIGHT || |
204 details.window_component == HTBOTTOMLEFT) { | 204 details.window_component == HTBOTTOMLEFT) { |
205 gfx::Rect work_area = gfx::Screen::GetMonitorNearestWindow( | 205 gfx::Rect work_area = gfx::Screen::GetDisplayNearestWindow( |
206 details.window).work_area(); | 206 details.window).work_area(); |
207 if (new_bounds.bottom() > work_area.bottom()) | 207 if (new_bounds.bottom() > work_area.bottom()) |
208 new_bounds.Inset(0, 0, 0, | 208 new_bounds.Inset(0, 0, 0, |
209 new_bounds.bottom() - work_area.bottom()); | 209 new_bounds.bottom() - work_area.bottom()); |
210 } | 210 } |
211 if (details.bounds_change & kBoundsChange_Resizes && | 211 if (details.bounds_change & kBoundsChange_Resizes && |
212 details.bounds_change & kBoundsChange_Repositions && new_bounds.y() < 0) { | 212 details.bounds_change & kBoundsChange_Repositions && new_bounds.y() < 0) { |
213 int delta = new_bounds.y(); | 213 int delta = new_bounds.y(); |
214 new_bounds.set_y(0); | 214 new_bounds.set_y(0); |
215 new_bounds.set_height(new_bounds.height() + delta); | 215 new_bounds.set_height(new_bounds.height() + delta); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 // Ensure we don't shrink past the minimum width and clamp delta_x | 288 // Ensure we don't shrink past the minimum width and clamp delta_x |
289 // for the window origin computation. | 289 // for the window origin computation. |
290 if (width < min_width) { | 290 if (width < min_width) { |
291 width = min_width; | 291 width = min_width; |
292 *delta_x = -x_multiplier * (details.initial_bounds.width() - min_width); | 292 *delta_x = -x_multiplier * (details.initial_bounds.width() - min_width); |
293 } | 293 } |
294 | 294 |
295 // And don't let the window go bigger than the monitor. | 295 // And don't let the window go bigger than the monitor. |
296 int max_width = | 296 int max_width = |
297 gfx::Screen::GetMonitorNearestWindow(details.window).bounds().width(); | 297 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().width(); |
298 if (width > max_width) { | 298 if (width > max_width) { |
299 width = max_width; | 299 width = max_width; |
300 *delta_x = -x_multiplier * (details.initial_bounds.width() - max_width); | 300 *delta_x = -x_multiplier * (details.initial_bounds.width() - max_width); |
301 } | 301 } |
302 } | 302 } |
303 return width; | 303 return width; |
304 } | 304 } |
305 | 305 |
306 // static | 306 // static |
307 int WindowResizer::GetHeightForDrag(const Details& details, | 307 int WindowResizer::GetHeightForDrag(const Details& details, |
(...skipping 13 matching lines...) Expand all Loading... |
321 | 321 |
322 // Ensure we don't shrink past the minimum height and clamp delta_y | 322 // Ensure we don't shrink past the minimum height and clamp delta_y |
323 // for the window origin computation. | 323 // for the window origin computation. |
324 if (height < min_height) { | 324 if (height < min_height) { |
325 height = min_height; | 325 height = min_height; |
326 *delta_y = -y_multiplier * (details.initial_bounds.height() - min_height); | 326 *delta_y = -y_multiplier * (details.initial_bounds.height() - min_height); |
327 } | 327 } |
328 | 328 |
329 // And don't let the window go bigger than the monitor. | 329 // And don't let the window go bigger than the monitor. |
330 int max_height = | 330 int max_height = |
331 gfx::Screen::GetMonitorNearestWindow(details.window).bounds().height(); | 331 gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height(); |
332 if (height > max_height) { | 332 if (height > max_height) { |
333 height = max_height; | 333 height = max_height; |
334 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height); | 334 *delta_y = -y_multiplier * (details.initial_bounds.height() - max_height); |
335 } | 335 } |
336 } | 336 } |
337 return height; | 337 return height; |
338 } | 338 } |
339 | 339 |
340 } // namespace aura | 340 } // namespace aura |
OLD | NEW |