Major optimisation effort.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4228 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-05-07 20:08:51 +00:00
parent 6b82d01416
commit d888b218dd
10 changed files with 281 additions and 182 deletions

View file

@ -1,3 +1,30 @@
Fri May 7 21:25:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
Large and complex changes made in order to speed up operation of the
gui. Roughly double the speed of an app - but stability will
probably suffer for a while.
* Headers/AppKit/NSResponder.h: Added flags structure for use by
NSView (and others) for optimisation.
* Headers/AppKit/NSView.h: Made ([-subviews]) return an array.
Removed ([-cursorRectangles]) and ([-trackingRectangles])
* Model/GMAppKit.m: Added code to ensure that 'flipped_view' and
'has_subviews' flags are setup correctly on unarchiving.
* Source/NSView.m: Removed ([-cursorRectangles]) and
([-trackingRectangles]). Added 'flipped_view' flag throughout, to
avoid necessity of sending ([-isFlipped]) message except at
initialisation. Added 'has_currect' flag to say if the view has any
cursor rectangles. Added 'has_trkrect' flag to say if the view has
any tracking rectangles. Added 'has_subviews' flag to say if the
view has any subviews. Make use of the new flags.
* Source/NSClipView.m: Added code to update 'flipped_view' flag when
the codument view is changed.
* Source/NSClipView.m: Added code to update 'flipped_view' flag when
the document view is changed.
* Source/NSScrollView.m: Make use of the 'flipped_view' flag.
* Source/NSSplitView.m: Make use of the 'flipped_view' flag.
* Source/NSWindow.m: For tracking rectangles and cursor rectangles,
make use of the new flags maintained by NSView.
Fri May 7 12:16:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Fri May 7 12:16:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Headers/AppKit/GSTrackingRect.h: Add a couple of ivars and make * Headers/AppKit/GSTrackingRect.h: Add a couple of ivars and make

View file

@ -39,6 +39,23 @@
{ {
NSInterfaceStyle interface_style; NSInterfaceStyle interface_style;
NSResponder *next_responder; NSResponder *next_responder;
/*
* Flags for internal use by NSResponder and it's subclasses.
*/
@public
struct _rFlagsType {
/*
* 'flipped_view' is set in NSViews designated initialiser (and other
* methods that create views) to be the value returned by [-isFlipped]
* This caching assumes that the value returned by [-isFlipped] will
* not change during the views lifetime - if it does, the view must
* be sure to change the flag accordingly.
*/
unsigned flipped_view:1;
unsigned has_subviews:1;
unsigned has_currects:1;
unsigned has_trkrects:1;
} _rFlags;
} }
/* /*

View file

@ -121,7 +121,7 @@ enum {
with:(NSView *)newView; with:(NSView *)newView;
- (void)sortSubviewsUsingFunction:(int (*)(id ,id ,void *))compare - (void)sortSubviewsUsingFunction:(int (*)(id ,id ,void *))compare
context:(void *)context; context:(void *)context;
- (NSMutableArray *)subviews; - (NSArray *)subviews;
- (NSView *)superview; - (NSView *)superview;
- (NSWindow *)window; - (NSWindow *)window;
- (void)viewWillMoveToSuperview:(NSView *)newSuper; - (void)viewWillMoveToSuperview:(NSView *)newSuper;
@ -246,7 +246,6 @@ enum {
- (void)removeCursorRect:(NSRect)aRect - (void)removeCursorRect:(NSRect)aRect
cursor:(NSCursor *)anObject; cursor:(NSCursor *)anObject;
- (void)resetCursorRects; - (void)resetCursorRects;
- (NSArray *)cursorRectangles;
// //
// Assigning a Tag // Assigning a Tag
@ -268,7 +267,6 @@ enum {
owner:(id)anObject owner:(id)anObject
userData:(void *)data userData:(void *)data
assumeInside:(BOOL)flag; assumeInside:(BOOL)flag;
- (NSArray *)trackingRectangles;
// //
// Dragging // Dragging

View file

@ -978,6 +978,10 @@ void __dummy_GMAppKit_functionForLinking() {}
[self setAutoresizingMask: [self setAutoresizingMask:
[unarchiver decodeUnsignedIntWithName:@"autoresizingMask"]]; [unarchiver decodeUnsignedIntWithName:@"autoresizingMask"]];
_rFlags.flipped_view = [self isFlipped];
if ([sub_views count])
_rFlags.has_subviews = 1;
return self; return self;
} }

View file

@ -86,6 +86,8 @@
object: _documentView]; object: _documentView];
} }
_rFlags.flipped_view = [self isFlipped];
/* TODO: invoke superview's reflectScrolledClipView: ? */ /* TODO: invoke superview's reflectScrolledClipView: ? */
[[self superview] reflectScrolledClipView: self]; [[self superview] reflectScrolledClipView: self];
} }
@ -366,7 +368,7 @@
- (BOOL) isFlipped - (BOOL) isFlipped
{ {
return (_documentView != nil) ? [_documentView isFlipped] : NO; return (_documentView != nil) ? _documentView->_rFlags.flipped_view : NO;
} }
- (BOOL) acceptsFirstResponder - (BOOL) acceptsFirstResponder

View file

@ -255,7 +255,7 @@ static Class rulerViewClass = nil;
if (!_vertScroller) if (!_vertScroller)
{ {
[self setVerticalScroller: [[NSScroller new] autorelease]]; [self setVerticalScroller: [[NSScroller new] autorelease]];
if (_contentView && ![_contentView isFlipped]) if (_contentView && !_contentView->_rFlags.flipped_view)
[_vertScroller setFloatValue: 1]; [_vertScroller setFloatValue: 1];
} }
[self addSubview: _vertScroller]; [self addSubview: _vertScroller];
@ -309,14 +309,14 @@ static Class rulerViewClass = nil;
} }
else else
{ {
if (![_contentView isFlipped]) if (!_contentView->_rFlags.flipped_view)
{ {
// If view is flipped // If view is flipped
// reverse the scroll direction // reverse the scroll direction
amount = -amount; amount = -amount;
} }
NSDebugLog (@"increment/decrement: amount = %f, flipped = %d", NSDebugLog (@"increment/decrement: amount = %f, flipped = %d",
amount, [_contentView isFlipped]); amount, _contentView->_rFlags.flipped_view);
point.y = clipViewBounds.origin.y + amount; point.y = clipViewBounds.origin.y + amount;
} }
} }
@ -330,7 +330,7 @@ static Class rulerViewClass = nil;
} }
else else
{ {
if (![_contentView isFlipped]) if (!_contentView->_rFlags.flipped_view)
floatValue = 1 - floatValue; floatValue = 1 - floatValue;
point.y = floatValue * (documentRect.size.height point.y = floatValue * (documentRect.size.height
- clipViewBounds.size.height); - clipViewBounds.size.height);
@ -370,7 +370,7 @@ static Class rulerViewClass = nil;
/ documentFrame.size.height; / documentFrame.size.height;
floatValue = (clipViewBounds.origin.y - documentFrame.origin.y) floatValue = (clipViewBounds.origin.y - documentFrame.origin.y)
/ (documentFrame.size.height - clipViewBounds.size.height); / (documentFrame.size.height - clipViewBounds.size.height);
if (![_contentView isFlipped]) if (!_contentView->_rFlags.flipped_view)
floatValue = 1 - floatValue; floatValue = 1 - floatValue;
[_vertScroller setFloatValue: floatValue [_vertScroller setFloatValue: floatValue
knobProportion: knobProportion]; knobProportion: knobProportion];
@ -484,7 +484,7 @@ static Class rulerViewClass = nil;
horizScrollerRect.size.width = contentRect.size.width; horizScrollerRect.size.width = contentRect.size.width;
horizScrollerRect.size.height = scrollerWidth; horizScrollerRect.size.height = scrollerWidth;
if ([self isFlipped]) if (_rFlags.flipped_view)
{ {
horizScrollerRect.origin.y += contentRect.size.height + 1; horizScrollerRect.origin.y += contentRect.size.height + 1;
} }
@ -555,7 +555,7 @@ static Class rulerViewClass = nil;
{ {
float ypos = scrollerWidth + borderThickness + 1; float ypos = scrollerWidth + borderThickness + 1;
if ([self isFlipped]) if (_rFlags.flipped_view)
ypos = [self bounds].size.height - ypos; ypos = [self bounds].size.height - ypos;
DPSmoveto(ctxt, horizLinePosition, ypos); DPSmoveto(ctxt, horizLinePosition, ypos);
DPSrlineto(ctxt, horizLineLength - 1, 0); DPSrlineto(ctxt, horizLineLength - 1, 0);
@ -588,7 +588,7 @@ static Class rulerViewClass = nil;
- (void) setDocumentView: (NSView*)aView - (void) setDocumentView: (NSView*)aView
{ {
[_contentView setDocumentView: aView]; [_contentView setDocumentView: aView];
if (_contentView && ![_contentView isFlipped]) if (_contentView && !_contentView->_rFlags.flipped_view)
[_vertScroller setFloatValue: 1]; [_vertScroller setFloatValue: 1];
[self tile]; [self tile];
} }

View file

@ -195,7 +195,7 @@ static Class cellClass;
// Compute the float value // Compute the float value
floatValue = (position - (slotRect.origin.y + knobRect.size.height/2)) floatValue = (position - (slotRect.origin.y + knobRect.size.height/2))
/ (slotRect.size.height - knobRect.size.height); / (slotRect.size.height - knobRect.size.height);
if ([self isFlipped]) if (_rFlags.flipped_view)
floatValue = 1 - floatValue; floatValue = 1 - floatValue;
} }
else else

View file

@ -416,7 +416,7 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
* Images are always drawn with their bottom-left corner at the origin * Images are always drawn with their bottom-left corner at the origin
* so we must adjust the position to take account of a flipped view. * so we must adjust the position to take account of a flipped view.
*/ */
if ([self isFlipped]) if (_rFlags.flipped_view)
dimpleOrigin.y -= dimpleSize.height; dimpleOrigin.y -= dimpleSize.height;
[dimpleImage compositeToPoint: dimpleOrigin operation: NSCompositeSourceOver]; [dimpleImage compositeToPoint: dimpleOrigin operation: NSCompositeSourceOver];
} }

View file

@ -137,6 +137,11 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
autoresizingMask = NSViewNotSizable; autoresizingMask = NSViewNotSizable;
coordinates_valid = NO; coordinates_valid = NO;
/*
* Keep a note of whether this is a flipped view or not.
*/
_rFlags.flipped_view = [self isFlipped];
return self; return self;
} }
@ -167,6 +172,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
[aView viewWillMoveToSuperview: self]; [aView viewWillMoveToSuperview: self];
[aView setNextResponder: self]; [aView setNextResponder: self];
[sub_views addObject: aView]; [sub_views addObject: aView];
_rFlags.has_subviews = 1;
[aView resetCursorRects]; [aView resetCursorRects];
[aView setNeedsDisplay: YES]; [aView setNeedsDisplay: YES];
[aView release]; [aView release];
@ -205,6 +211,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
[sub_views insertObject: aView atIndex: index]; [sub_views insertObject: aView atIndex: index];
else else
[sub_views insertObject: aView atIndex: index+1]; [sub_views insertObject: aView atIndex: index+1];
_rFlags.has_subviews = 1;
[aView resetCursorRects]; [aView resetCursorRects];
[aView setNeedsDisplay: YES]; [aView setNeedsDisplay: YES];
[aView release]; [aView release];
@ -258,8 +265,6 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
- (void) removeFromSuperviewWithoutNeedingDisplay - (void) removeFromSuperviewWithoutNeedingDisplay
{ {
NSMutableArray *views;
/* /*
* We MUST make sure that coordinates are invalidated even if we have * We MUST make sure that coordinates are invalidated even if we have
* no superview - cos they may have been rebuilt since we lost the * no superview - cos they may have been rebuilt since we lost the
@ -275,15 +280,15 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
if ([window firstResponder] == self) if ([window firstResponder] == self)
[window makeFirstResponder: window]; [window makeFirstResponder: window];
views = [super_view subviews]; [super_view->sub_views removeObjectIdenticalTo: self];
[views removeObjectIdenticalTo: self]; if ([super_view->sub_views count] == 0)
super_view->_rFlags.has_subviews = 0;
super_view = nil; super_view = nil;
[self viewWillMoveToWindow: nil]; [self viewWillMoveToWindow: nil];
} }
- (void) removeFromSuperview - (void) removeFromSuperview
{ {
NSMutableArray *views;
NSWindow *win; NSWindow *win;
/* /*
@ -301,13 +306,14 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
if ([window firstResponder] == self) if ([window firstResponder] == self)
[window makeFirstResponder: window]; [window makeFirstResponder: window];
views = [super_view subviews];
[super_view setNeedsDisplayInRect: frame]; [super_view setNeedsDisplayInRect: frame];
[super_view->sub_views removeObjectIdenticalTo: self];
if ([super_view->sub_views count] == 0)
super_view->_rFlags.has_subviews = 0;
win = window; win = window;
window = nil; window = nil;
super_view = nil; super_view = nil;
[views removeObjectIdenticalTo: self];
} }
- (void) replaceSubview: (NSView*)oldView with: (NSView*)newView - (void) replaceSubview: (NSView*)oldView with: (NSView*)newView
@ -333,6 +339,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
[newView viewWillMoveToSuperview: self]; [newView viewWillMoveToSuperview: self];
[newView setNextResponder: self]; [newView setNextResponder: self];
[sub_views addObject: newView]; [sub_views addObject: newView];
_rFlags.has_subviews = 1;
[newView resetCursorRects]; [newView resetCursorRects];
[newView setNeedsDisplay: YES]; [newView setNeedsDisplay: YES];
[newView release]; [newView release];
@ -366,6 +373,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
[newView viewWillMoveToSuperview: self]; [newView viewWillMoveToSuperview: self];
[newView setNextResponder: self]; [newView setNextResponder: self];
[sub_views addObject: newView]; [sub_views addObject: newView];
_rFlags.has_subviews = 1;
[newView resetCursorRects]; [newView resetCursorRects];
[newView setNeedsDisplay: YES]; [newView setNeedsDisplay: YES];
[newView release]; [newView release];
@ -782,7 +790,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
r.origin = [matrix pointInMatrixSpace: r.origin]; r.origin = [matrix pointInMatrixSpace: r.origin];
r.size = [matrix sizeInMatrixSpace: r.size]; r.size = [matrix sizeInMatrixSpace: r.size];
if ([aView isFlipped] != [self isFlipped]) if (aView->_rFlags.flipped_view != _rFlags.flipped_view)
r.origin.y -= r.size.height; r.origin.y -= r.size.height;
return r; return r;
@ -810,7 +818,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
r.origin = [matrix pointInMatrixSpace: r.origin]; r.origin = [matrix pointInMatrixSpace: r.origin];
r.size = [matrix sizeInMatrixSpace: r.size]; r.size = [matrix sizeInMatrixSpace: r.size];
if ([aView isFlipped] != [self isFlipped]) if (aView->_rFlags.flipped_view != _rFlags.flipped_view)
r.origin.y -= r.size.height; r.origin.y -= r.size.height;
return r; return r;
@ -968,7 +976,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
} }
if (autoresizingMask & (NSViewMaxYMargin | NSViewMinYMargin)) if (autoresizingMask & (NSViewMaxYMargin | NSViewMinYMargin))
{ {
if ([super_view isFlipped] == YES) if (super_view && super_view->_rFlags.flipped_view == YES)
{ {
if (autoresizingMask & NSViewMaxYMargin) if (autoresizingMask & NSViewMaxYMargin)
{ {
@ -1408,12 +1416,14 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
inside: YES]; inside: YES];
[cursor_rects addObject: m]; [cursor_rects addObject: m];
[m release]; [m release];
_rFlags.has_currects = 1;
} }
- (void) discardCursorRects - (void) discardCursorRects
{ {
[cursor_rects makeObjectsPerformSelector: @selector(invalidate)]; [cursor_rects makeObjectsPerformSelector: @selector(invalidate)];
[cursor_rects removeAllObjects]; [cursor_rects removeAllObjects];
_rFlags.has_currects = 0;
} }
- (void) removeCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject - (void) removeCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject
@ -1430,6 +1440,8 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
{ {
[o invalidate]; [o invalidate];
[cursor_rects removeObject: o]; [cursor_rects removeObject: o];
if ([cursor_rects count] == 0)
_rFlags.has_currects = 0;
break; break;
} }
else else
@ -1604,7 +1616,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
if ([m tag] == tag) if ([m tag] == tag)
{ {
[tracking_rects removeObjectAtIndex: i]; [tracking_rects removeObjectAtIndex: i];
if ([tracking_rects count] == 0)
_rFlags.has_trkrects = 0;
return; return;
} }
} }
@ -1640,15 +1653,10 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
userData: data userData: data
inside: flag] autorelease]; inside: flag] autorelease];
[tracking_rects addObject: m]; [tracking_rects addObject: m];
_rFlags.has_trkrects = 1;
return t; return t;
} }
- (NSArray*) trackingRectangles
{
return tracking_rects;
}
// //
// Dragging // Dragging
// //
@ -1850,6 +1858,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &autoresize_subviews]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &autoresize_subviews];
NSDebugLLog(@"NSView", @"NSView: finish decoding\n"); NSDebugLLog(@"NSView", @"NSView: finish decoding\n");
/*
* Keep a note of whether this is a flipped view or not.
*/
_rFlags.flipped_view = [self isFlipped];
if ([sub_views count])
_rFlags.has_subviews = 1;
return self; return self;
} }
@ -1881,9 +1897,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
return autoresizingMask; return autoresizingMask;
} }
- (NSMutableArray*) subviews - (NSArray*) subviews
{ {
return sub_views; /*
* Return a mutable copy 'cos we know that a mutable copy of an array or
* a mutable array does a shallow copy - which is what we want to give
* away - we don't want people to mess with our actual subviews array.
*/
return [[sub_views mutableCopyWithZone: NSDefaultMallocZone()] autorelease];
} }
- (NSView*) superview - (NSView*) superview
@ -1911,11 +1932,6 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
return -1; return -1;
} }
- (NSArray*) cursorRectangles
{
return cursor_rects;
}
- (BOOL) isFlipped - (BOOL) isFlipped
{ {
return NO; return NO;
@ -2043,14 +2059,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
else else
{ {
NSRect superviewsVisibleRect; NSRect superviewsVisibleRect;
BOOL wasFlipped = [super_view isFlipped]; BOOL wasFlipped = super_view->_rFlags.flipped_view;
float vals[6]; float vals[6];
NSAffineTransform *pMatrix = [super_view _matrixToWindow]; NSAffineTransform *pMatrix = [super_view _matrixToWindow];
[pMatrix getMatrix: vals]; [pMatrix getMatrix: vals];
[matrixToWindow setMatrix: vals]; [matrixToWindow setMatrix: vals];
(*appImp)(matrixToWindow, appSel, frameMatrix); (*appImp)(matrixToWindow, appSel, frameMatrix);
if ([self isFlipped] != wasFlipped) if (_rFlags.flipped_view != wasFlipped)
{ {
/* /*
* The flipping process must result in a coordinate system that * The flipping process must result in a coordinate system that

View file

@ -48,6 +48,7 @@
#include <AppKit/GSTrackingRect.h> #include <AppKit/GSTrackingRect.h>
#include <AppKit/NSSliderCell.h> #include <AppKit/NSSliderCell.h>
#include <AppKit/NSScreen.h> #include <AppKit/NSScreen.h>
#include <AppKit/NSView.h>
#include <AppKit/NSCursor.h> #include <AppKit/NSCursor.h>
@ -88,6 +89,12 @@
@implementation NSWindow @implementation NSWindow
typedef struct NSView_struct
{
@defs(NSView)
} *NSViewPtr;
/* /*
* Class variables * Class variables
*/ */
@ -812,16 +819,24 @@ static IMP ctImp;
- (void) discardCursorRectsForView: (NSView *)theView - (void) discardCursorRectsForView: (NSView *)theView
{ {
NSArray *s; if (((NSViewPtr)theView)->_rFlags.has_currects)
id e; [theView discardCursorRects];
NSView *v;
[theView discardCursorRects]; if (((NSViewPtr)theView)->_rFlags.has_subviews)
{
NSArray *s = ((NSViewPtr)theView)->sub_views;
unsigned count = [s count];
s = [theView subviews]; if (count)
e = [s objectEnumerator]; {
while ((v = [e nextObject])) NSView *subs[count];
[self discardCursorRectsForView: v]; unsigned i;
[s getObjects: subs];
for (i = 0; i < count; i++)
[self discardCursorRectsForView: subs[i]];
}
}
} }
- (void) discardCursorRects - (void) discardCursorRects
@ -841,16 +856,24 @@ static IMP ctImp;
- (void) resetCursorRectsForView: (NSView *)theView - (void) resetCursorRectsForView: (NSView *)theView
{ {
NSArray *s; if (((NSViewPtr)theView)->_rFlags.has_currects)
id e; [theView resetCursorRects];
NSView *v;
[theView resetCursorRects]; // Reset cursor rects for view if (((NSViewPtr)theView)->_rFlags.has_subviews)
{
NSArray *s = ((NSViewPtr)theView)->sub_views;
unsigned count = [s count];
s = [theView subviews]; // Reset cursor rects for the if (count)
e = [s objectEnumerator]; // view's subviews {
while ((v = [e nextObject])) NSView *subs[count];
[self resetCursorRectsForView: v]; unsigned i;
[s getObjects: subs];
for (i = 0; i < count; i++)
[self resetCursorRectsForView: subs[i]];
}
}
} }
- (void) resetCursorRects - (void) resetCursorRects
@ -1072,69 +1095,70 @@ static IMP ctImp;
- (void) _checkTrackingRectangles: (NSView *)theView - (void) _checkTrackingRectangles: (NSView *)theView
forEvent: (NSEvent *)theEvent forEvent: (NSEvent *)theEvent
{ {
NSArray *tr = [theView trackingRectangles]; if (((NSViewPtr)theView)->_rFlags.has_trkrects)
NSArray *sb = [theView subviews];
unsigned count;
/*
* Loop through the tracking rectangles
*/
count = [tr count];
if (count > 0)
{ {
GSTrackingRect *rects[count]; NSArray *tr = ((NSViewPtr)theView)->tracking_rects;
NSPoint loc = [theEvent locationInWindow]; unsigned count = [tr count];
BOOL flipped = [theView isFlipped];
unsigned i;
[tr getObjects: rects]; /*
* Loop through the tracking rectangles
for (i = 0; i < count; ++i) */
if (count > 0)
{ {
BOOL last; GSTrackingRect *rects[count];
BOOL now; NSPoint loc = [theEvent locationInWindow];
GSTrackingRect *r = rects[i]; BOOL flipped = ((NSViewPtr)theView)->_rFlags.flipped_view;
unsigned i;
/* Check mouse at last point */ [tr getObjects: rects];
last = NSMouseInRect(last_point, r->rectangle, flipped);
/* Check mouse at current point */
now = NSMouseInRect(loc, r->rectangle, flipped);
if ((!last) && (now)) // Mouse entered event for (i = 0; i < count; ++i)
{ {
if (r->ownerRespondsToMouseEntered) BOOL last;
{ BOOL now;
NSEvent *e; GSTrackingRect *r = rects[i];
e = [NSEvent enterExitEventWithType: NSMouseEntered /* Check mouse at last point */
location: loc last = NSMouseInRect(last_point, r->rectangle, flipped);
modifierFlags: [theEvent modifierFlags] /* Check mouse at current point */
timestamp: 0 now = NSMouseInRect(loc, r->rectangle, flipped);
windowNumber: [theEvent windowNumber]
context: NULL if ((!last) && (now)) // Mouse entered event
eventNumber: 0 {
trackingNumber: r->tag if (r->ownerRespondsToMouseEntered)
userData: r->user_data]; {
[r->owner mouseEntered: e]; NSEvent *e;
e = [NSEvent enterExitEventWithType: NSMouseEntered
location: loc
modifierFlags: [theEvent modifierFlags]
timestamp: 0
windowNumber: [theEvent windowNumber]
context: NULL
eventNumber: 0
trackingNumber: r->tag
userData: r->user_data];
[r->owner mouseEntered: e];
}
} }
}
if ((last) && (!now)) // Mouse exited event if ((last) && (!now)) // Mouse exited event
{
if (r->ownerRespondsToMouseExited)
{ {
NSEvent *e; if (r->ownerRespondsToMouseExited)
{
NSEvent *e;
e = [NSEvent enterExitEventWithType: NSMouseExited e = [NSEvent enterExitEventWithType: NSMouseExited
location: loc location: loc
modifierFlags: [theEvent modifierFlags] modifierFlags: [theEvent modifierFlags]
timestamp: 0 timestamp: 0
windowNumber: [theEvent windowNumber] windowNumber: [theEvent windowNumber]
context: NULL context: NULL
eventNumber: 0 eventNumber: 0
trackingNumber: r->tag trackingNumber: r->tag
userData: r->user_data]; userData: r->user_data];
[r->owner mouseExited: e]; [r->owner mouseExited: e];
}
} }
} }
} }
@ -1143,89 +1167,95 @@ static IMP ctImp;
/* /*
* Check tracking rectangles for the subviews * Check tracking rectangles for the subviews
*/ */
count = [sb count]; if (((NSViewPtr)theView)->_rFlags.has_subviews)
if (count > 0)
{ {
NSView *subs[count]; NSArray *sb = ((NSViewPtr)theView)->sub_views;
unsigned i; unsigned count = [sb count];
[sb getObjects: subs]; if (count > 0)
for (i = 0; i < count; ++i) {
(*ctImp)(self, ctSel, subs[i], theEvent); NSView *subs[count];
unsigned i;
[sb getObjects: subs];
for (i = 0; i < count; ++i)
(*ctImp)(self, ctSel, subs[i], theEvent);
}
} }
} }
- (void) _checkCursorRectangles: (NSView *)theView forEvent: (NSEvent *)theEvent - (void) _checkCursorRectangles: (NSView *)theView forEvent: (NSEvent *)theEvent
{ {
NSArray *tr = [theView cursorRectangles]; if (((NSViewPtr)theView)->_rFlags.has_currects)
NSArray *sb = [theView subviews];
unsigned count;
// Loop through cursor rectangles
count = [tr count];
if (count > 0)
{ {
GSTrackingRect *rects[count]; NSArray *tr = ((NSViewPtr)theView)->cursor_rects;
NSPoint loc = [theEvent locationInWindow]; unsigned count = [tr count];
NSPoint lastConv;
NSPoint locConv;
BOOL flipped = [theView isFlipped];
unsigned i;
/* // Loop through cursor rectangles
* Convert points from window to view coordinates. if (count > 0)
*/
lastConv = [theView convertPoint: last_point fromView: nil];
locConv = [theView convertPoint: loc fromView: nil];
[tr getObjects: rects];
for (i = 0; i < count; ++i)
{ {
GSTrackingRect *r = rects[i]; GSTrackingRect *rects[count];
BOOL last; NSPoint loc = [theEvent locationInWindow];
BOOL now; NSPoint lastConv;
NSPoint locConv;
if ([r isValid] == NO) BOOL flipped = ((NSViewPtr)theView)->_rFlags.flipped_view;
continue; unsigned i;
/* /*
* Check for presence of point in rectangle. * Convert points from window to view coordinates.
*/ */
last = NSMouseInRect(lastConv, r->rectangle, flipped); lastConv = [theView convertPoint: last_point fromView: nil];
now = NSMouseInRect(locConv, r->rectangle, flipped); locConv = [theView convertPoint: loc fromView: nil];
// Mouse entered [tr getObjects: rects];
if ((!last) && (now))
for (i = 0; i < count; ++i)
{ {
NSEvent *e; GSTrackingRect *r = rects[i];
BOOL last;
BOOL now;
e = [NSEvent enterExitEventWithType: NSCursorUpdate if ([r isValid] == NO)
location: loc continue;
modifierFlags: [theEvent modifierFlags]
timestamp: 0
windowNumber: [theEvent windowNumber]
context: [theEvent context]
eventNumber: 0
trackingNumber: (int)YES
userData: (void *)r];
[self postEvent: e atStart: YES];
}
// Mouse exited
if ((last) && (!now))
{
NSEvent *e;
e = [NSEvent enterExitEventWithType: NSCursorUpdate /*
location: loc * Check for presence of point in rectangle.
modifierFlags: [theEvent modifierFlags] */
timestamp: 0 last = NSMouseInRect(lastConv, r->rectangle, flipped);
windowNumber: [theEvent windowNumber] now = NSMouseInRect(locConv, r->rectangle, flipped);
context: [theEvent context]
eventNumber: 0 // Mouse entered
trackingNumber: (int)NO if ((!last) && (now))
userData: (void *)r]; {
[self postEvent: e atStart: YES]; NSEvent *e;
e = [NSEvent enterExitEventWithType: NSCursorUpdate
location: loc
modifierFlags: [theEvent modifierFlags]
timestamp: 0
windowNumber: [theEvent windowNumber]
context: [theEvent context]
eventNumber: 0
trackingNumber: (int)YES
userData: (void *)r];
[self postEvent: e atStart: YES];
}
// Mouse exited
if ((last) && (!now))
{
NSEvent *e;
e = [NSEvent enterExitEventWithType: NSCursorUpdate
location: loc
modifierFlags: [theEvent modifierFlags]
timestamp: 0
windowNumber: [theEvent windowNumber]
context: [theEvent context]
eventNumber: 0
trackingNumber: (int)NO
userData: (void *)r];
[self postEvent: e atStart: YES];
}
} }
} }
} }
@ -1233,15 +1263,20 @@ static IMP ctImp;
/* /*
* Check cursor rectangles for the subviews * Check cursor rectangles for the subviews
*/ */
count = [sb count]; if (((NSViewPtr)theView)->_rFlags.has_subviews)
if (count > 0)
{ {
NSView *subs[count]; NSArray *sb = ((NSViewPtr)theView)->sub_views;
unsigned i; unsigned count = [sb count];
[sb getObjects: subs]; if (count > 0)
for (i = 0; i < count; ++i) {
(*ccImp)(self, ccSel, subs[i], theEvent); NSView *subs[count];
unsigned i;
[sb getObjects: subs];
for (i = 0; i < count; ++i)
(*ccImp)(self, ccSel, subs[i], theEvent);
}
} }
} }