diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index e6c07a987..0358f3f81 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -369,6 +369,7 @@ var CPSplitViewHorizontalImage = nil, - (void)mouseDown:(CPEvent)anEvent { + // FIXME: This should not trap events if not on a divider! [self trackDivider:anEvent]; } diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index ad6579c99..774be7efc 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -525,31 +525,6 @@ CPTexturedBackgroundWindowMask [_delegate windowDidResize:self]; } -/* - @ignore -*/ -- (void)trackMoveWithEvent:(CPEvent)anEvent -{ - var type = [anEvent type]; - - if (type == CPLeftMouseUp) - return; - - else if (type == CPLeftMouseDown) - _mouseDraggedPoint = [self convertBaseToBridge:[anEvent locationInWindow]]; - - else if (type == CPLeftMouseDragged) - { - var location = [self convertBaseToBridge:[anEvent locationInWindow]]; - - [self setFrameOrigin:CGPointMake(_CGRectGetMinX(_frame) + (location.x - _mouseDraggedPoint.x), _CGRectGetMinY(_frame) + (location.y - _mouseDraggedPoint.y))]; - - _mouseDraggedPoint = location; - } - - [CPApp setTarget:self selector:@selector(trackMoveWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES]; -} - /*! Makes the receiver the front most window in the screen ordering. @param aSender the object that requested this diff --git a/AppKit/CPWindow/_CPStandardWindowView.j b/AppKit/CPWindow/_CPStandardWindowView.j index a2416233d..5c1c4995e 100644 --- a/AppKit/CPWindow/_CPStandardWindowView.j +++ b/AppKit/CPWindow/_CPStandardWindowView.j @@ -277,9 +277,9 @@ var STANDARD_GRADIENT_HEIGHT = 41.0; - (void)mouseDown:(CPEvent)anEvent { if (CGRectContainsPoint([_headView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil])) - [[self owningWindow] trackMoveWithEvent:anEvent]; + return [self trackMoveWithEvent:anEvent]; - return [super mouseDown:anEvent]; + [super mouseDown:anEvent]; } @end diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index 451c3e209..e5ec2da77 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -23,6 +23,8 @@ @import "CPView.j" @import "CPImageView.j" +#include "../CoreGraphics/CGGeometry.h" + var _CPWindowViewResizeIndicatorImage = nil; @@ -36,6 +38,9 @@ var _CPWindowViewResizeIndicatorImage = nil; CPView _toolbarView; CPWindow _owningWindow; + + CGRect _resizeFrame; + CGPoint _mouseDraggedPoint; } + (void)initialize @@ -111,15 +116,12 @@ var _CPWindowViewResizeIndicatorImage = nil; } if ([theWindow isMovableByWindowBackground]) - [theWindow trackMoveWithEvent:anEvent]; + [self trackMoveWithEvent:anEvent]; else [super mouseDown:anEvent]; } -/* - @ignore -*/ - (void)trackResizeWithEvent:(CPEvent)anEvent { var location = [anEvent locationInWindow], @@ -143,6 +145,30 @@ var _CPWindowViewResizeIndicatorImage = nil; [CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES]; } +- (void)trackMoveWithEvent:(CPEvent)anEvent +{ + var type = [anEvent type]; + + if (type === CPLeftMouseUp) + return; + + else if (type === CPLeftMouseDown) + _mouseDraggedPoint = [[self owningWindow] convertBaseToBridge:[anEvent locationInWindow]]; + + else if (type === CPLeftMouseDragged) + { + var theWindow = [self owningWindow], + location = [theWindow convertBaseToBridge:[anEvent locationInWindow]], + frame = [theWindow frame]; + + [theWindow setFrameOrigin:CGPointMake(_CGRectGetMinX(frame) + (location.x - _mouseDraggedPoint.x), _CGRectGetMinY(frame) + (location.y - _mouseDraggedPoint.y))]; + + _mouseDraggedPoint = location; + } + + [CPApp setTarget:self selector:@selector(trackMoveWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES]; +} + - (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator { if (shouldShowResizeIndicator)