Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1675)

Unified Diff: ash/wm/window_resizer.cc

Issue 11087037: Dont allow the user to 'resize a window out of the workarea' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698