mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
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:
parent
b02a0ecc16
commit
5b81c06c1a
10 changed files with 281 additions and 182 deletions
27
ChangeLog
27
ChangeLog
|
@ -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>
|
||||
|
||||
* Headers/AppKit/GSTrackingRect.h: Add a couple of ivars and make
|
||||
|
|
|
@ -39,6 +39,23 @@
|
|||
{
|
||||
NSInterfaceStyle interface_style;
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -121,7 +121,7 @@ enum {
|
|||
with:(NSView *)newView;
|
||||
- (void)sortSubviewsUsingFunction:(int (*)(id ,id ,void *))compare
|
||||
context:(void *)context;
|
||||
- (NSMutableArray *)subviews;
|
||||
- (NSArray *)subviews;
|
||||
- (NSView *)superview;
|
||||
- (NSWindow *)window;
|
||||
- (void)viewWillMoveToSuperview:(NSView *)newSuper;
|
||||
|
@ -246,7 +246,6 @@ enum {
|
|||
- (void)removeCursorRect:(NSRect)aRect
|
||||
cursor:(NSCursor *)anObject;
|
||||
- (void)resetCursorRects;
|
||||
- (NSArray *)cursorRectangles;
|
||||
|
||||
//
|
||||
// Assigning a Tag
|
||||
|
@ -268,7 +267,6 @@ enum {
|
|||
owner:(id)anObject
|
||||
userData:(void *)data
|
||||
assumeInside:(BOOL)flag;
|
||||
- (NSArray *)trackingRectangles;
|
||||
|
||||
//
|
||||
// Dragging
|
||||
|
|
|
@ -978,6 +978,10 @@ void __dummy_GMAppKit_functionForLinking() {}
|
|||
[self setAutoresizingMask:
|
||||
[unarchiver decodeUnsignedIntWithName:@"autoresizingMask"]];
|
||||
|
||||
_rFlags.flipped_view = [self isFlipped];
|
||||
if ([sub_views count])
|
||||
_rFlags.has_subviews = 1;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,8 @@
|
|||
object: _documentView];
|
||||
}
|
||||
|
||||
_rFlags.flipped_view = [self isFlipped];
|
||||
|
||||
/* TODO: invoke superview's reflectScrolledClipView: ? */
|
||||
[[self superview] reflectScrolledClipView: self];
|
||||
}
|
||||
|
@ -366,7 +368,7 @@
|
|||
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return (_documentView != nil) ? [_documentView isFlipped] : NO;
|
||||
return (_documentView != nil) ? _documentView->_rFlags.flipped_view : NO;
|
||||
}
|
||||
|
||||
- (BOOL) acceptsFirstResponder
|
||||
|
|
|
@ -255,7 +255,7 @@ static Class rulerViewClass = nil;
|
|||
if (!_vertScroller)
|
||||
{
|
||||
[self setVerticalScroller: [[NSScroller new] autorelease]];
|
||||
if (_contentView && ![_contentView isFlipped])
|
||||
if (_contentView && !_contentView->_rFlags.flipped_view)
|
||||
[_vertScroller setFloatValue: 1];
|
||||
}
|
||||
[self addSubview: _vertScroller];
|
||||
|
@ -309,14 +309,14 @@ static Class rulerViewClass = nil;
|
|||
}
|
||||
else
|
||||
{
|
||||
if (![_contentView isFlipped])
|
||||
if (!_contentView->_rFlags.flipped_view)
|
||||
{
|
||||
// If view is flipped
|
||||
// reverse the scroll direction
|
||||
amount = -amount;
|
||||
}
|
||||
NSDebugLog (@"increment/decrement: amount = %f, flipped = %d",
|
||||
amount, [_contentView isFlipped]);
|
||||
amount, _contentView->_rFlags.flipped_view);
|
||||
point.y = clipViewBounds.origin.y + amount;
|
||||
}
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ static Class rulerViewClass = nil;
|
|||
}
|
||||
else
|
||||
{
|
||||
if (![_contentView isFlipped])
|
||||
if (!_contentView->_rFlags.flipped_view)
|
||||
floatValue = 1 - floatValue;
|
||||
point.y = floatValue * (documentRect.size.height
|
||||
- clipViewBounds.size.height);
|
||||
|
@ -370,7 +370,7 @@ static Class rulerViewClass = nil;
|
|||
/ documentFrame.size.height;
|
||||
floatValue = (clipViewBounds.origin.y - documentFrame.origin.y)
|
||||
/ (documentFrame.size.height - clipViewBounds.size.height);
|
||||
if (![_contentView isFlipped])
|
||||
if (!_contentView->_rFlags.flipped_view)
|
||||
floatValue = 1 - floatValue;
|
||||
[_vertScroller setFloatValue: floatValue
|
||||
knobProportion: knobProportion];
|
||||
|
@ -484,7 +484,7 @@ static Class rulerViewClass = nil;
|
|||
horizScrollerRect.size.width = contentRect.size.width;
|
||||
horizScrollerRect.size.height = scrollerWidth;
|
||||
|
||||
if ([self isFlipped])
|
||||
if (_rFlags.flipped_view)
|
||||
{
|
||||
horizScrollerRect.origin.y += contentRect.size.height + 1;
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ static Class rulerViewClass = nil;
|
|||
{
|
||||
float ypos = scrollerWidth + borderThickness + 1;
|
||||
|
||||
if ([self isFlipped])
|
||||
if (_rFlags.flipped_view)
|
||||
ypos = [self bounds].size.height - ypos;
|
||||
DPSmoveto(ctxt, horizLinePosition, ypos);
|
||||
DPSrlineto(ctxt, horizLineLength - 1, 0);
|
||||
|
@ -588,7 +588,7 @@ static Class rulerViewClass = nil;
|
|||
- (void) setDocumentView: (NSView*)aView
|
||||
{
|
||||
[_contentView setDocumentView: aView];
|
||||
if (_contentView && ![_contentView isFlipped])
|
||||
if (_contentView && !_contentView->_rFlags.flipped_view)
|
||||
[_vertScroller setFloatValue: 1];
|
||||
[self tile];
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ static Class cellClass;
|
|||
// Compute the float value
|
||||
floatValue = (position - (slotRect.origin.y + knobRect.size.height/2))
|
||||
/ (slotRect.size.height - knobRect.size.height);
|
||||
if ([self isFlipped])
|
||||
if (_rFlags.flipped_view)
|
||||
floatValue = 1 - floatValue;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -416,7 +416,7 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
|
|||
* 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.
|
||||
*/
|
||||
if ([self isFlipped])
|
||||
if (_rFlags.flipped_view)
|
||||
dimpleOrigin.y -= dimpleSize.height;
|
||||
[dimpleImage compositeToPoint: dimpleOrigin operation: NSCompositeSourceOver];
|
||||
}
|
||||
|
|
|
@ -137,6 +137,11 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
autoresizingMask = NSViewNotSizable;
|
||||
coordinates_valid = NO;
|
||||
|
||||
/*
|
||||
* Keep a note of whether this is a flipped view or not.
|
||||
*/
|
||||
_rFlags.flipped_view = [self isFlipped];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -167,6 +172,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
[aView viewWillMoveToSuperview: self];
|
||||
[aView setNextResponder: self];
|
||||
[sub_views addObject: aView];
|
||||
_rFlags.has_subviews = 1;
|
||||
[aView resetCursorRects];
|
||||
[aView setNeedsDisplay: YES];
|
||||
[aView release];
|
||||
|
@ -205,6 +211,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
[sub_views insertObject: aView atIndex: index];
|
||||
else
|
||||
[sub_views insertObject: aView atIndex: index+1];
|
||||
_rFlags.has_subviews = 1;
|
||||
[aView resetCursorRects];
|
||||
[aView setNeedsDisplay: YES];
|
||||
[aView release];
|
||||
|
@ -258,8 +265,6 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
|
||||
- (void) removeFromSuperviewWithoutNeedingDisplay
|
||||
{
|
||||
NSMutableArray *views;
|
||||
|
||||
/*
|
||||
* We MUST make sure that coordinates are invalidated even if we have
|
||||
* 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)
|
||||
[window makeFirstResponder: window];
|
||||
views = [super_view subviews];
|
||||
[views removeObjectIdenticalTo: self];
|
||||
[super_view->sub_views removeObjectIdenticalTo: self];
|
||||
if ([super_view->sub_views count] == 0)
|
||||
super_view->_rFlags.has_subviews = 0;
|
||||
super_view = nil;
|
||||
[self viewWillMoveToWindow: nil];
|
||||
}
|
||||
|
||||
- (void) removeFromSuperview
|
||||
{
|
||||
NSMutableArray *views;
|
||||
NSWindow *win;
|
||||
|
||||
/*
|
||||
|
@ -301,13 +306,14 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
|
||||
if ([window firstResponder] == self)
|
||||
[window makeFirstResponder: window];
|
||||
views = [super_view subviews];
|
||||
[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;
|
||||
window = nil;
|
||||
super_view = nil;
|
||||
|
||||
[views removeObjectIdenticalTo: self];
|
||||
}
|
||||
|
||||
- (void) replaceSubview: (NSView*)oldView with: (NSView*)newView
|
||||
|
@ -333,6 +339,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
[newView viewWillMoveToSuperview: self];
|
||||
[newView setNextResponder: self];
|
||||
[sub_views addObject: newView];
|
||||
_rFlags.has_subviews = 1;
|
||||
[newView resetCursorRects];
|
||||
[newView setNeedsDisplay: YES];
|
||||
[newView release];
|
||||
|
@ -366,6 +373,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
[newView viewWillMoveToSuperview: self];
|
||||
[newView setNextResponder: self];
|
||||
[sub_views addObject: newView];
|
||||
_rFlags.has_subviews = 1;
|
||||
[newView resetCursorRects];
|
||||
[newView setNeedsDisplay: YES];
|
||||
[newView release];
|
||||
|
@ -782,7 +790,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
r.origin = [matrix pointInMatrixSpace: r.origin];
|
||||
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;
|
||||
|
||||
return r;
|
||||
|
@ -810,7 +818,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
r.origin = [matrix pointInMatrixSpace: r.origin];
|
||||
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;
|
||||
|
||||
return r;
|
||||
|
@ -968,7 +976,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
}
|
||||
if (autoresizingMask & (NSViewMaxYMargin | NSViewMinYMargin))
|
||||
{
|
||||
if ([super_view isFlipped] == YES)
|
||||
if (super_view && super_view->_rFlags.flipped_view == YES)
|
||||
{
|
||||
if (autoresizingMask & NSViewMaxYMargin)
|
||||
{
|
||||
|
@ -1408,12 +1416,14 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
inside: YES];
|
||||
[cursor_rects addObject: m];
|
||||
[m release];
|
||||
_rFlags.has_currects = 1;
|
||||
}
|
||||
|
||||
- (void) discardCursorRects
|
||||
{
|
||||
[cursor_rects makeObjectsPerformSelector: @selector(invalidate)];
|
||||
[cursor_rects removeAllObjects];
|
||||
_rFlags.has_currects = 0;
|
||||
}
|
||||
|
||||
- (void) removeCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject
|
||||
|
@ -1430,6 +1440,8 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
{
|
||||
[o invalidate];
|
||||
[cursor_rects removeObject: o];
|
||||
if ([cursor_rects count] == 0)
|
||||
_rFlags.has_currects = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -1604,7 +1616,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
if ([m tag] == tag)
|
||||
{
|
||||
[tracking_rects removeObjectAtIndex: i];
|
||||
|
||||
if ([tracking_rects count] == 0)
|
||||
_rFlags.has_trkrects = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1640,15 +1653,10 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
userData: data
|
||||
inside: flag] autorelease];
|
||||
[tracking_rects addObject: m];
|
||||
|
||||
_rFlags.has_trkrects = 1;
|
||||
return t;
|
||||
}
|
||||
|
||||
- (NSArray*) trackingRectangles
|
||||
{
|
||||
return tracking_rects;
|
||||
}
|
||||
|
||||
//
|
||||
// Dragging
|
||||
//
|
||||
|
@ -1850,6 +1858,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &autoresize_subviews];
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1881,9 +1897,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
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
|
||||
|
@ -1911,11 +1932,6 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
return -1;
|
||||
}
|
||||
|
||||
- (NSArray*) cursorRectangles
|
||||
{
|
||||
return cursor_rects;
|
||||
}
|
||||
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return NO;
|
||||
|
@ -2043,14 +2059,14 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
else
|
||||
{
|
||||
NSRect superviewsVisibleRect;
|
||||
BOOL wasFlipped = [super_view isFlipped];
|
||||
BOOL wasFlipped = super_view->_rFlags.flipped_view;
|
||||
float vals[6];
|
||||
NSAffineTransform *pMatrix = [super_view _matrixToWindow];
|
||||
|
||||
[pMatrix getMatrix: vals];
|
||||
[matrixToWindow setMatrix: vals];
|
||||
(*appImp)(matrixToWindow, appSel, frameMatrix);
|
||||
if ([self isFlipped] != wasFlipped)
|
||||
if (_rFlags.flipped_view != wasFlipped)
|
||||
{
|
||||
/*
|
||||
* The flipping process must result in a coordinate system that
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <AppKit/GSTrackingRect.h>
|
||||
#include <AppKit/NSSliderCell.h>
|
||||
#include <AppKit/NSScreen.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSCursor.h>
|
||||
|
||||
|
||||
|
@ -88,6 +89,12 @@
|
|||
|
||||
@implementation NSWindow
|
||||
|
||||
typedef struct NSView_struct
|
||||
{
|
||||
@defs(NSView)
|
||||
} *NSViewPtr;
|
||||
|
||||
|
||||
/*
|
||||
* Class variables
|
||||
*/
|
||||
|
@ -812,16 +819,24 @@ static IMP ctImp;
|
|||
|
||||
- (void) discardCursorRectsForView: (NSView *)theView
|
||||
{
|
||||
NSArray *s;
|
||||
id e;
|
||||
NSView *v;
|
||||
if (((NSViewPtr)theView)->_rFlags.has_currects)
|
||||
[theView discardCursorRects];
|
||||
|
||||
[theView discardCursorRects];
|
||||
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
||||
{
|
||||
NSArray *s = ((NSViewPtr)theView)->sub_views;
|
||||
unsigned count = [s count];
|
||||
|
||||
s = [theView subviews];
|
||||
e = [s objectEnumerator];
|
||||
while ((v = [e nextObject]))
|
||||
[self discardCursorRectsForView: v];
|
||||
if (count)
|
||||
{
|
||||
NSView *subs[count];
|
||||
unsigned i;
|
||||
|
||||
[s getObjects: subs];
|
||||
for (i = 0; i < count; i++)
|
||||
[self discardCursorRectsForView: subs[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) discardCursorRects
|
||||
|
@ -841,16 +856,24 @@ static IMP ctImp;
|
|||
|
||||
- (void) resetCursorRectsForView: (NSView *)theView
|
||||
{
|
||||
NSArray *s;
|
||||
id e;
|
||||
NSView *v;
|
||||
if (((NSViewPtr)theView)->_rFlags.has_currects)
|
||||
[theView resetCursorRects];
|
||||
|
||||
[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
|
||||
e = [s objectEnumerator]; // view's subviews
|
||||
while ((v = [e nextObject]))
|
||||
[self resetCursorRectsForView: v];
|
||||
if (count)
|
||||
{
|
||||
NSView *subs[count];
|
||||
unsigned i;
|
||||
|
||||
[s getObjects: subs];
|
||||
for (i = 0; i < count; i++)
|
||||
[self resetCursorRectsForView: subs[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resetCursorRects
|
||||
|
@ -1072,69 +1095,70 @@ static IMP ctImp;
|
|||
- (void) _checkTrackingRectangles: (NSView *)theView
|
||||
forEvent: (NSEvent *)theEvent
|
||||
{
|
||||
NSArray *tr = [theView trackingRectangles];
|
||||
NSArray *sb = [theView subviews];
|
||||
unsigned count;
|
||||
|
||||
/*
|
||||
* Loop through the tracking rectangles
|
||||
*/
|
||||
count = [tr count];
|
||||
if (count > 0)
|
||||
if (((NSViewPtr)theView)->_rFlags.has_trkrects)
|
||||
{
|
||||
GSTrackingRect *rects[count];
|
||||
NSPoint loc = [theEvent locationInWindow];
|
||||
BOOL flipped = [theView isFlipped];
|
||||
unsigned i;
|
||||
NSArray *tr = ((NSViewPtr)theView)->tracking_rects;
|
||||
unsigned count = [tr count];
|
||||
|
||||
[tr getObjects: rects];
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
/*
|
||||
* Loop through the tracking rectangles
|
||||
*/
|
||||
if (count > 0)
|
||||
{
|
||||
BOOL last;
|
||||
BOOL now;
|
||||
GSTrackingRect *r = rects[i];
|
||||
GSTrackingRect *rects[count];
|
||||
NSPoint loc = [theEvent locationInWindow];
|
||||
BOOL flipped = ((NSViewPtr)theView)->_rFlags.flipped_view;
|
||||
unsigned i;
|
||||
|
||||
/* Check mouse at last point */
|
||||
last = NSMouseInRect(last_point, r->rectangle, flipped);
|
||||
/* Check mouse at current point */
|
||||
now = NSMouseInRect(loc, r->rectangle, flipped);
|
||||
[tr getObjects: rects];
|
||||
|
||||
if ((!last) && (now)) // Mouse entered event
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
if (r->ownerRespondsToMouseEntered)
|
||||
{
|
||||
NSEvent *e;
|
||||
BOOL last;
|
||||
BOOL now;
|
||||
GSTrackingRect *r = rects[i];
|
||||
|
||||
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];
|
||||
/* Check mouse at last point */
|
||||
last = NSMouseInRect(last_point, r->rectangle, flipped);
|
||||
/* Check mouse at current point */
|
||||
now = NSMouseInRect(loc, r->rectangle, flipped);
|
||||
|
||||
if ((!last) && (now)) // Mouse entered event
|
||||
{
|
||||
if (r->ownerRespondsToMouseEntered)
|
||||
{
|
||||
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 (r->ownerRespondsToMouseExited)
|
||||
if ((last) && (!now)) // Mouse exited event
|
||||
{
|
||||
NSEvent *e;
|
||||
if (r->ownerRespondsToMouseExited)
|
||||
{
|
||||
NSEvent *e;
|
||||
|
||||
e = [NSEvent enterExitEventWithType: NSMouseExited
|
||||
location: loc
|
||||
modifierFlags: [theEvent modifierFlags]
|
||||
timestamp: 0
|
||||
windowNumber: [theEvent windowNumber]
|
||||
context: NULL
|
||||
eventNumber: 0
|
||||
trackingNumber: r->tag
|
||||
userData: r->user_data];
|
||||
[r->owner mouseExited: e];
|
||||
e = [NSEvent enterExitEventWithType: NSMouseExited
|
||||
location: loc
|
||||
modifierFlags: [theEvent modifierFlags]
|
||||
timestamp: 0
|
||||
windowNumber: [theEvent windowNumber]
|
||||
context: NULL
|
||||
eventNumber: 0
|
||||
trackingNumber: r->tag
|
||||
userData: r->user_data];
|
||||
[r->owner mouseExited: e];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1143,89 +1167,95 @@ static IMP ctImp;
|
|||
/*
|
||||
* Check tracking rectangles for the subviews
|
||||
*/
|
||||
count = [sb count];
|
||||
if (count > 0)
|
||||
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
||||
{
|
||||
NSView *subs[count];
|
||||
unsigned i;
|
||||
NSArray *sb = ((NSViewPtr)theView)->sub_views;
|
||||
unsigned count = [sb count];
|
||||
|
||||
[sb getObjects: subs];
|
||||
for (i = 0; i < count; ++i)
|
||||
(*ctImp)(self, ctSel, subs[i], theEvent);
|
||||
if (count > 0)
|
||||
{
|
||||
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
|
||||
{
|
||||
NSArray *tr = [theView cursorRectangles];
|
||||
NSArray *sb = [theView subviews];
|
||||
unsigned count;
|
||||
|
||||
// Loop through cursor rectangles
|
||||
count = [tr count];
|
||||
if (count > 0)
|
||||
if (((NSViewPtr)theView)->_rFlags.has_currects)
|
||||
{
|
||||
GSTrackingRect *rects[count];
|
||||
NSPoint loc = [theEvent locationInWindow];
|
||||
NSPoint lastConv;
|
||||
NSPoint locConv;
|
||||
BOOL flipped = [theView isFlipped];
|
||||
unsigned i;
|
||||
NSArray *tr = ((NSViewPtr)theView)->cursor_rects;
|
||||
unsigned count = [tr count];
|
||||
|
||||
/*
|
||||
* Convert points from window to view coordinates.
|
||||
*/
|
||||
lastConv = [theView convertPoint: last_point fromView: nil];
|
||||
locConv = [theView convertPoint: loc fromView: nil];
|
||||
|
||||
[tr getObjects: rects];
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
// Loop through cursor rectangles
|
||||
if (count > 0)
|
||||
{
|
||||
GSTrackingRect *r = rects[i];
|
||||
BOOL last;
|
||||
BOOL now;
|
||||
|
||||
if ([r isValid] == NO)
|
||||
continue;
|
||||
GSTrackingRect *rects[count];
|
||||
NSPoint loc = [theEvent locationInWindow];
|
||||
NSPoint lastConv;
|
||||
NSPoint locConv;
|
||||
BOOL flipped = ((NSViewPtr)theView)->_rFlags.flipped_view;
|
||||
unsigned i;
|
||||
|
||||
/*
|
||||
* Check for presence of point in rectangle.
|
||||
* Convert points from window to view coordinates.
|
||||
*/
|
||||
last = NSMouseInRect(lastConv, r->rectangle, flipped);
|
||||
now = NSMouseInRect(locConv, r->rectangle, flipped);
|
||||
lastConv = [theView convertPoint: last_point fromView: nil];
|
||||
locConv = [theView convertPoint: loc fromView: nil];
|
||||
|
||||
// Mouse entered
|
||||
if ((!last) && (now))
|
||||
[tr getObjects: rects];
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
NSEvent *e;
|
||||
GSTrackingRect *r = rects[i];
|
||||
BOOL last;
|
||||
BOOL now;
|
||||
|
||||
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;
|
||||
if ([r isValid] == NO)
|
||||
continue;
|
||||
|
||||
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];
|
||||
/*
|
||||
* Check for presence of point in rectangle.
|
||||
*/
|
||||
last = NSMouseInRect(lastConv, r->rectangle, flipped);
|
||||
now = NSMouseInRect(locConv, r->rectangle, flipped);
|
||||
|
||||
// Mouse entered
|
||||
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)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
|
||||
*/
|
||||
count = [sb count];
|
||||
if (count > 0)
|
||||
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
||||
{
|
||||
NSView *subs[count];
|
||||
unsigned i;
|
||||
NSArray *sb = ((NSViewPtr)theView)->sub_views;
|
||||
unsigned count = [sb count];
|
||||
|
||||
[sb getObjects: subs];
|
||||
for (i = 0; i < count; ++i)
|
||||
(*ccImp)(self, ccSel, subs[i], theEvent);
|
||||
if (count > 0)
|
||||
{
|
||||
NSView *subs[count];
|
||||
unsigned i;
|
||||
|
||||
[sb getObjects: subs];
|
||||
for (i = 0; i < count; ++i)
|
||||
(*ccImp)(self, ccSel, subs[i], theEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue