Index: ash/wm/window_resizer.cc |
diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc |
index c759c9162ab84bda43fb1a4c3f6afacfd7e38ac7..a0a0c3a417923e9377b1a244ca87833363e2c700 100644 |
--- a/ash/wm/window_resizer.cc |
+++ b/ash/wm/window_resizer.cc |
@@ -100,6 +100,9 @@ const int WindowResizer::kBoundsChangeDirection_Horizontal = 1; |
// static |
const int WindowResizer::kBoundsChangeDirection_Vertical = 2; |
+// static |
+const int WindowResizer::kMinimumOnScreenSize = 10; |
+ |
WindowResizer::Details::Details() |
: window(NULL), |
window_component(HTNOWHERE), |
@@ -169,10 +172,36 @@ int WindowResizer::GetBoundsChangeForWindowComponent(int component) { |
// static |
gfx::Rect WindowResizer::CalculateBoundsForDrag( |
const Details& details, |
- const gfx::Point& location) { |
+ const gfx::Point& passed_location) { |
if (!details.is_resizable) |
return details.initial_bounds; |
+ gfx::Point location = passed_location; |
+ gfx::Rect work_area = |
sky
2012/10/09 23:58:53
Move work_area inside if.
Mr4D (OOO till 08-26)
2012/10/10 23:14:35
cannot since it's being used in line 233 as well.
|
+ ScreenAsh::GetDisplayWorkAreaBoundsInParent(details.window); |
+ |
+ // Don't allow the user to "resize a window" out of the screen. |
+ if (details.bounds_change & kBoundsChange_Resizes) { |
+ if (details.size_change_direction & kBoundsChangeDirection_Horizontal) { |
+ if (IsRightEdge(details.window_component)) { |
+ location.set_x( |
+ std::max(location.x(), |
+ work_area.x() + WindowResizer::kMinimumOnScreenSize)); |
+ } else { |
+ location.set_x( |
+ std::min(location.x(), |
+ work_area.right() - WindowResizer::kMinimumOnScreenSize)); |
+ } |
+ } |
+ if (details.size_change_direction & kBoundsChangeDirection_Vertical) { |
+ if (!IsBottomEdge(details.window_component)) { |
+ location.set_y( |
+ std::min(location.y(), work_area.bottom() - |
+ WindowResizer::kMinimumOnScreenSize)); |
+ } |
+ } |
+ } |
+ |
int delta_x = location.x() - details.initial_location_in_parent.x(); |
int delta_y = location.y() - details.initial_location_in_parent.y(); |
@@ -195,12 +224,10 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( |
gfx::Rect new_bounds(origin, size); |
// Update bottom edge to stay in the work area when we are resizing |
- // by dragging the bottome edge or corners. |
+ // by dragging the bottom edge or corners. |
if (details.window_component == HTBOTTOM || |
details.window_component == HTBOTTOMRIGHT || |
details.window_component == HTBOTTOMLEFT) { |
- gfx::Rect work_area = |
- ScreenAsh::GetDisplayWorkAreaBoundsInParent(details.window); |
if (new_bounds.bottom() > work_area.bottom()) |
new_bounds.Inset(0, 0, 0, |
new_bounds.bottom() - work_area.bottom()); |
@@ -211,6 +238,7 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( |
new_bounds.set_y(0); |
new_bounds.set_height(new_bounds.height() + delta); |
} |
+ |
return new_bounds; |
} |