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