Skip to content

Commit

Permalink
Window resize fixes
Browse files Browse the repository at this point in the history
- Track mouse exit from window resize rect instead of unconditionally setting arrow cursor.
- Don't show the resize cursors for full platform windows.
- Show the resize down cursor if the top of a window is being resized and it has reached the bottom of the menubar.
- Make windows in CPToolbarTest resizable to test resizing behavior with toolbars.
- Added a full platform window and menubar to the test app.
  • Loading branch information
Aparajita Fishman committed Jan 5, 2013
1 parent d072f17 commit f1a171a
Show file tree
Hide file tree
Showing 8 changed files with 2,393 additions and 101 deletions.
11 changes: 9 additions & 2 deletions AppKit/CPApplication.j
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ CPRunContinuesResponse = -1002;
CPArray _eventListeners;

CPEvent _currentEvent;
CPWindow _lastMouseMoveWindow;

CPArray _windows;
CPWindow _keyWindow;
Expand Down Expand Up @@ -621,10 +622,16 @@ CPRunContinuesResponse = -1002;
return;
}

if ([anEvent type] == CPMouseMoved)
{
if (theWindow !== _lastMouseMoveWindow)
[_lastMouseMoveWindow _mouseExitedResizeRect];

_lastMouseMoveWindow = theWindow;
}

if (theWindow)
[theWindow sendEvent:anEvent];
else if ([anEvent type] == CPMouseMoved)
[[CPCursor arrowCursor] set];
}

/*!
Expand Down
9 changes: 7 additions & 2 deletions AppKit/CPWindow/CPWindow.j
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,11 @@ CPTexturedBackgroundWindowMask
_ignoresMouseEvents = shouldIgnoreMouseEvents;
}

- (void)_mouseExitedResizeRect
{
[[CPCursor arrowCursor] set];
}

// Managing Titles

/*!
Expand Down Expand Up @@ -3285,8 +3290,8 @@ var keyViewComparator = function(lhs, rhs, context)
- (BOOL)_isValidMousePoint:(CGPoint)aPoint
{
// If we are using the new resizing mode, mouse events are valid
// outside the window's frame.
var mouseFrame = ((_styleMask & CPResizableWindowMask) && (CPWindowResizeStyle === CPWindowResizeStyleModern)) ? _CGRectInset(_frame, -CPWindowResizeSlop, -CPWindowResizeSlop) : _frame;
// outside the window's frame for non-full platform windows.
var mouseFrame = (!_isFullPlatformWindow && (_styleMask & CPResizableWindowMask) && (CPWindowResizeStyle === CPWindowResizeStyleModern)) ? _CGRectInset(_frame, -CPWindowResizeSlop, -CPWindowResizeSlop) : _frame;

return CGRectContainsPoint(mouseFrame, aPoint);
}
Expand Down
11 changes: 8 additions & 3 deletions AppKit/CPWindow/_CPWindowView.j
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,15 @@ var _CPWindowViewResizeIndicatorImage = nil,
*/
- (void)setCursorForLocation:(CGPoint)aPoint resizing:(BOOL)isResizing
{
if (!(_styleMask & CPResizableWindowMask) ||
var theWindow = [self window];

if ([theWindow isFullPlatformWindow] ||
!(_styleMask & CPResizableWindowMask) ||
(CPWindowResizeStyle !== CPWindowResizeStyleModern))
return;

var theWindow = [self window],
resizeRegion = isResizing ? _resizeRegion : [self resizeRegionForPoint:[theWindow convertBaseToGlobal:aPoint]],
var globalPoint = [theWindow convertBaseToGlobal:aPoint],
resizeRegion = isResizing ? _resizeRegion : [self resizeRegionForPoint:globalPoint],
minSize = nil,
maxSize = nil,
frameSize;
Expand Down Expand Up @@ -301,6 +304,8 @@ var _CPWindowViewResizeIndicatorImage = nil,
[[CPCursor resizeUpCursor] set];
else if (maxSize && (frameSize.height === maxSize.height))
[[CPCursor resizeDownCursor] set];
else if ([CPMenu menuBarVisible] && (_CGRectGetMinY([theWindow frame]) <= [CPMenu menuBarHeight]))
[[CPCursor resizeDownCursor] set];
else
[[CPCursor resizeNorthSouthCursor] set];
break;
Expand Down
3 changes: 2 additions & 1 deletion AppKit/Platform/DOM/CPPlatformWindow+DOM.j
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,6 @@ var resizeTimer = nil;
{
var type = _overriddenEventType || aDOMEvent.type;


// IE's event order is down, up, up, dblclick, so we have create these events artificially.
if (type === @"dblclick")
{
Expand Down Expand Up @@ -1308,6 +1307,7 @@ var resizeTimer = nil;
// if there are any tracking event listeners then show the event guard so we don't lose events to iframes
// TODO Actually check for tracking event listeners, not just any listener but _CPRunModalLoop.
var hasTrackingEventListener = NO;

for (var i = 0; i < CPApp._eventListeners.length; i++)
{
if (CPApp._eventListeners[i]._callback !== _CPRunModalLoop)
Expand All @@ -1316,6 +1316,7 @@ var resizeTimer = nil;
break;
}
}

_lastMouseEventLocation = location;

_DOMEventGuard.style.display = hasTrackingEventListener ? "" : "none";
Expand Down
2 changes: 1 addition & 1 deletion Tests/Manual/CPToolbarTest/AppController.j
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
if (!hasIcon && hasTallItem)
continue;

var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(x, y, 400, 20) styleMask:CPTitledWindowMask],
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(x, y, 400, 20) styleMask:CPTitledWindowMask | CPResizableWindowMask],
contentView = [theWindow contentView];

[theWindow setTitle:"Toolbar (LBL: " + hasLabel + " ICN: " + hasIcon + " SMALL: " + isSmall + " TALLITEM: " + hasTallItem + ")"];
Expand Down
2 changes: 1 addition & 1 deletion Tests/Manual/CPWindowResizeStyle/AppController.j
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
[theWindow makeKeyAndOrderFront:nil];
}

- (void)awakeFromCib
{
[theWindow setFullPlatformWindow:YES];
}

- (@action)resizeStyleDidChange:(id)sender
Expand Down
2 changes: 1 addition & 1 deletion Tests/Manual/CPWindowResizeStyle/Resources/MainMenu.cib

Large diffs are not rendered by default.

Loading

0 comments on commit f1a171a

Please sign in to comment.