Fixed: resizing a window did not attempt to maintain a minimum margin on screen.

Previously, window moves were constrained such that a minimum margin of the window was visible on screen, but window resizes were not constrained, allowing the user to effectively move the window off screen.

Now resizes are constrained such that a minimum margin of the window is always visible on screen so that the window does not get "lost".
This commit is contained in:
Aparajita Fishman
2013-08-09 08:28:36 -04:00
parent 2183c6d383
commit 3c2a2f39fc
+32 -1
View File
@@ -631,7 +631,38 @@ _CPWindowViewResizeSlop = 3;
newHeight = startHeight;
}
[theWindow _setFrame:CGRectMake(newX, newY, newWidth, newHeight) display:YES animate:NO constrainWidth:NO constrainHeight:NO];
// When resizing, we always constrain to the usable screen.
frame = CGRectMake(newX, newY, newWidth, newHeight);
var constrainedFrame = [theWindow _constrainOriginOfFrame:frame],
dx = constrainedFrame.origin.x - frame.origin.x,
dy = constrainedFrame.origin.y - frame.origin.y;
// When resizing from the left or top, we adjust the origin and size.
switch (_resizeRegion)
{
case _CPWindowViewResizeRegionBottomLeft:
case _CPWindowViewResizeRegionLeft:
case _CPWindowViewResizeRegionTopLeft:
case _CPWindowViewResizeRegionTop:
case _CPWindowViewResizeRegionTopRight:
frame.origin = constrainedFrame.origin;
frame.size.width -= dx;
frame.size.height -= dy;
}
// When resizing from the right or bottom, we only adjust the size.
switch (_resizeRegion)
{
case _CPWindowViewResizeRegionTopRight:
case _CPWindowViewResizeRegionRight:
case _CPWindowViewResizeRegionBottomRight:
case _CPWindowViewResizeRegionBottom:
frame.size.width += dx;
frame.size.height += dy;
}
[theWindow _setFrame:frame display:YES animate:NO constrainWidth:NO constrainHeight:NO];
[self setCursorForLocation:location resizing:YES];
}