From 3c2a2f39fc9d8068dffb8448b10012c70cbab445 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Mon, 5 Aug 2013 10:13:36 -0400 Subject: [PATCH] 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". --- AppKit/CPWindow/_CPWindowView.j | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index 30fdc2e7a..09c4e9a0d 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -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]; }