diff --git a/Headers/gnustep/gui/GSTrackingRect.h b/Headers/gnustep/gui/GSTrackingRect.h index a8923fcab..934d88a7a 100644 --- a/Headers/gnustep/gui/GSTrackingRect.h +++ b/Headers/gnustep/gui/GSTrackingRect.h @@ -3,7 +3,7 @@ Tracking rectangle class - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996,1999 Free Software Foundation, Inc. Author: Scott Christley Date: 1996 @@ -38,18 +38,20 @@ NSTrackingRectTag tag; id owner; void *user_data; - BOOL inside; - BOOL isValid; - BOOL ownerRespondsToMouseEntered; - BOOL ownerRespondsToMouseExited; + struct TrackFlagsType { + unsigned inside:1; + unsigned isValid:1; + unsigned checked:1; + unsigned ownerRespondsToMouseEntered:1; + unsigned ownerRespondsToMouseExited:1; + } flags; } -// Instance methods -- initWithRect: (NSRect)aRect - tag: (NSTrackingRectTag)aTag - owner: anObject - userData: (void *)theData - inside: (BOOL)flag; +- (id) initWithRect: (NSRect)aRect + tag: (NSTrackingRectTag)aTag + owner: (id)anObject + userData: (void *)theData + inside: (BOOL)flag; - (NSRect) rectangle; - (NSTrackingRectTag) tag; @@ -60,12 +62,13 @@ - (BOOL) isValid; - (void) invalidate; -// -// NSCoding protocol -// +/* + * NSCoding protocol + */ - (void) encodeWithCoder: (NSCoder*)aCoder; - (id) initWithCoder: (NSCoder*)aDecoder; @end -#endif // _GNUstep_H_GSTrackingRect +#endif /* _GNUstep_H_GSTrackingRect */ + diff --git a/Headers/gnustep/gui/NSCursor.h b/Headers/gnustep/gui/NSCursor.h index 3ba872182..a3f15e6b3 100644 --- a/Headers/gnustep/gui/NSCursor.h +++ b/Headers/gnustep/gui/NSCursor.h @@ -3,7 +3,7 @@ Holds an image to use as a cursor - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996,1999 Free Software Foundation, Inc. Author: Scott Christley Date: 1996 @@ -36,58 +36,58 @@ @interface NSCursor : NSObject { - // Attributes - NSImage *cursor_image; - NSPoint hot_spot; - BOOL is_set_on_mouse_entered; - BOOL is_set_on_mouse_exited; - - void *cid; + NSImage *cursor_image; + NSPoint hot_spot; + BOOL is_set_on_mouse_entered; + BOOL is_set_on_mouse_exited; + void *cid; } -// -// Initializing a New NSCursor Object -// -- (id)initWithImage:(NSImage *)newImage; +/* + * Initializing a New NSCursor Object + */ +- (id) initWithImage: (NSImage *)newImage; +- (id) initWithImage: (NSImage *)newImage + hotSpot: (NSPoint)hotSpot; -// -// Defining the Cursor -// -- (NSPoint)hotSpot; -- (NSImage *)image; -- (void)setHotSpot:(NSPoint)spot; -- (void)setImage:(NSImage *)newImage; +/* + * Defining the Cursor + */ +- (NSPoint) hotSpot; +- (NSImage*) image; +- (void) setHotSpot: (NSPoint)spot; +- (void) setImage: (NSImage *)newImage; -// -// Setting the Cursor -// -+ (void)hide; -+ (void)pop; -+ (void)setHiddenUntilMouseMoves:(BOOL)flag; -+ (BOOL)isHiddenUntilMouseMoves; -+ (void)unhide; -- (BOOL)isSetOnMouseEntered; -- (BOOL)isSetOnMouseExited; -- (void)mouseEntered:(NSEvent *)theEvent; -- (void)mouseExited:(NSEvent *)theEvent; -- (void)pop; -- (void)push; -- (void)set; -- (void)setOnMouseEntered:(BOOL)flag; -- (void)setOnMouseExited:(BOOL)flag; +/* + * Setting the Cursor + */ ++ (void) hide; ++ (void) pop; ++ (void) setHiddenUntilMouseMoves: (BOOL)flag; ++ (BOOL) isHiddenUntilMouseMoves; ++ (void) unhide; +- (BOOL) isSetOnMouseEntered; +- (BOOL) isSetOnMouseExited; +- (void) mouseEntered: (NSEvent*)theEvent; +- (void) mouseExited: (NSEvent*)theEvent; +- (void) pop; +- (void) push; +- (void) set; +- (void) setOnMouseEntered: (BOOL)flag; +- (void) setOnMouseExited: (BOOL)flag; + +/* + * Getting the Cursor + */ ++ (NSCursor*) arrowCursor; ++ (NSCursor*) currentCursor; ++ (NSCursor*) IBeamCursor; -// -// Getting the Cursor -// -+ (NSCursor *)arrowCursor; -+ (NSCursor *)currentCursor; -+ (NSCursor *)IBeamCursor; - -// -// NSCoding protocol -// -- (void)encodeWithCoder:aCoder; -- initWithCoder:aDecoder; +/* + * NSCoding protocol + */ +- (void) encodeWithCoder: (NSCoder*)aCoder; +- (id) initWithCoder: (NSCoder*)aDecoder; @end @@ -97,4 +97,4 @@ typedef enum { GSIBeamCursor } GSCursorTypes; -#endif // _GNUstep_H_NSCursor +#endif /* _GNUstep_H_NSCursor */ diff --git a/Headers/gnustep/gui/NSResponder.h b/Headers/gnustep/gui/NSResponder.h index c01a04d48..040d39baa 100644 --- a/Headers/gnustep/gui/NSResponder.h +++ b/Headers/gnustep/gui/NSResponder.h @@ -58,6 +58,7 @@ unsigned has_trkrects:1; /* This view has tracking rects */ unsigned has_draginfo:1; /* View/window has drag types */ unsigned opaque_view:1; + unsigned valid_rects:1; /* Some cursor rects are valid */ } _rFlags; } diff --git a/Headers/gnustep/gui/NSTextField.h b/Headers/gnustep/gui/NSTextField.h index f718d077b..ddaf57504 100644 --- a/Headers/gnustep/gui/NSTextField.h +++ b/Headers/gnustep/gui/NSTextField.h @@ -41,7 +41,6 @@ // Attributes id _delegate; SEL _error_action; - NSCursor *_text_cursor; NSText *_text_object; } diff --git a/Source/GSTrackingRect.m b/Source/GSTrackingRect.m index d3ed9329e..6a13e06fd 100644 --- a/Source/GSTrackingRect.m +++ b/Source/GSTrackingRect.m @@ -3,7 +3,7 @@ Tracking rectangle class - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996,1999 Free Software Foundation, Inc. Author: Scott Christley Date: 1996 @@ -31,9 +31,9 @@ @implementation GSTrackingRect -// -// Class methods -// +/* + * Class methods + */ + (void) initialize { if (self == [GSTrackingRect class]) @@ -42,39 +42,28 @@ } } -// -// Instance methods -// -// -// Initialization -// -- initWithRect: (NSRect)aRect - tag: (NSTrackingRectTag)aTag - owner: anObject - userData: (void *)theData - inside: (BOOL)flag +- (id) initWithRect: (NSRect)aRect + tag: (NSTrackingRectTag)aTag + owner: (id)anObject + userData: (void *)theData + inside: (BOOL)flag { rectangle = aRect; tag = aTag; owner = anObject; - if (owner) + if (owner != nil) { - [owner retain]; - if ([owner respondsToSelector: @selector(mouseEntered:)]) - ownerRespondsToMouseEntered = YES; - if ([owner respondsToSelector: @selector(mouseExited:)]) - ownerRespondsToMouseExited = YES; + RETAIN(owner); } user_data = theData; - inside = flag; - isValid = YES; + flags.inside = flag; + flags.isValid = YES; return self; } - (void) dealloc { - if (owner) - [owner release]; + TEST_RELEASE(owner); [super dealloc]; } @@ -88,7 +77,7 @@ return tag; } -- owner +- (id) owner { return owner; } @@ -100,34 +89,34 @@ - (BOOL) inside { - return inside; + return flags.inside; } - (BOOL) isValid { - return isValid; + return flags.isValid; } - (void) invalidate { - if (isValid) + if (flags.isValid) { - isValid = NO; - if (owner) + flags.isValid = NO; + flags.checked = NO; + if (owner != nil) { - [owner release]; - owner = nil; - ownerRespondsToMouseEntered = NO; - ownerRespondsToMouseExited = NO; + DESTROY(owner); } } } -// -// NSCoding protocol -// +/* + * NSCoding protocol + */ - (void) encodeWithCoder: (NSCoder*)aCoder { + BOOL inside = flags.inside; + [aCoder encodeRect: rectangle]; [aCoder encodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag]; [aCoder encodeObject: owner]; @@ -136,10 +125,13 @@ - (id) initWithCoder: (NSCoder*)aDecoder { + BOOL inside; + rectangle = [aDecoder decodeRect]; [aDecoder decodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag]; [aDecoder decodeValueOfObjCType: @encode(id) at: &owner]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &inside]; + flags.inside = inside; return self; } diff --git a/Source/NSCell.m b/Source/NSCell.m index 1c55fa7a6..7f7b26611 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -112,7 +113,7 @@ static NSColor *shadowCol; /* * Instance methods */ -- _init +- (id) _init { cell_type = NSNullCellType; cell_image = nil; @@ -1113,6 +1114,26 @@ static NSColor *shadowCol; */ - (void) resetCursorRect: (NSRect)cellFrame inView: (NSView *)controlView { + if (cell_type == NSTextCellType && cell_enabled == YES + && (cell_selectable == YES || cell_editable == YES)) + { + static NSCursor *c = nil; + NSRect r; + + if (c == nil) + { + c = RETAIN([NSCursor IBeamCursor]); + } + r = NSIntersectionRect(cellFrame, [controlView visibleRect]); + /* + * Here we depend on an undocumented feature of NSCursor which may or + * may not exist in OPENSTEP or MacOS-X ... + * If we add a cursor rect to a view and don't set it to be set on + * either entry to or exit from the view, we push it on entry and + * pop it from the cursor stack on exit. + */ + [controlView addCursorRect: r cursor: c]; + } } /* diff --git a/Source/NSControl.m b/Source/NSControl.m index 594bfd28d..a45dfea91 100644 --- a/Source/NSControl.m +++ b/Source/NSControl.m @@ -480,6 +480,11 @@ static Class cellClass; [self sendAction: [self action] to: [self target]]; } +- (void) resetCursorRects +{ + [cell resetCursorRect: bounds inView: self]; +} + - (BOOL) ignoresMultiClick { return NO; diff --git a/Source/NSCursor.m b/Source/NSCursor.m index 3956cb955..eb277a764 100644 --- a/Source/NSCursor.m +++ b/Source/NSCursor.m @@ -3,7 +3,7 @@ Holds an image to use as a cursor - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996,1999 Free Software Foundation, Inc. Author: Scott Christley Date: 1996 @@ -39,10 +39,10 @@ static BOOL gnustep_gui_hidden_until_move; @implementation NSCursor -// -// Class methods -// -+ (void)initialize +/* + * Class methods + */ ++ (void) initialize { if (self == [NSCursor class]) { @@ -52,11 +52,11 @@ static BOOL gnustep_gui_hidden_until_move; // Initialize class variables gnustep_gui_cursor_stack = [[NSMutableArray alloc] initWithCapacity: 2]; gnustep_gui_hidden_until_move = YES; - gnustep_gui_current_cursor = [[NSCursor arrowCursor] retain]; + [[self arrowCursor] push]; } } -- (void *)_cid +- (void *) _cid { return cid; } @@ -66,181 +66,207 @@ static BOOL gnustep_gui_hidden_until_move; cid = id; } -// -// Setting the Cursor -// -+ (void)hide +/* + * Setting the Cursor + */ ++ (void) hide { DPShidecursor(GSCurrentContext()); } -+ (void)pop ++ (void) pop { - // The object we pop is the current cursor - if ([gnustep_gui_cursor_stack count]) { - gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject]; - [gnustep_gui_cursor_stack removeLastObject]; - } + /* + * The object we pop is the current cursor + */ + if ([gnustep_gui_cursor_stack count] > 1) + { + [gnustep_gui_cursor_stack removeLastObject]; + gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject]; - // If the stack isn't empty then get the new current cursor - // Otherwise the cursor will stay the same - if ([gnustep_gui_cursor_stack count]) - gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject]; - - if ([gnustep_gui_current_cursor _cid]) - DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1, - [gnustep_gui_current_cursor _cid]); + if ([gnustep_gui_current_cursor _cid]) + { + DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1, + [gnustep_gui_current_cursor _cid]); + } + } } -+ (void)setHiddenUntilMouseMoves:(BOOL)flag ++ (void) setHiddenUntilMouseMoves: (BOOL)flag { gnustep_gui_hidden_until_move = flag; } -+ (BOOL)isHiddenUntilMouseMoves ++ (BOOL) isHiddenUntilMouseMoves { return gnustep_gui_hidden_until_move; } -+ (void)unhide ++ (void) unhide { DPSshowcursor(GSCurrentContext()); } -// -// Getting the Cursor -// -+ (NSCursor *)arrowCursor +/* + * Getting the Cursor + */ ++ (NSCursor*) arrowCursor { - void *c; - NSCursor *cur = AUTORELEASE([[NSCursor alloc] initWithImage: nil]); + void *c; + NSCursor *cur = AUTORELEASE([[NSCursor alloc] initWithImage: nil]); + DPSstandardcursor(GSCurrentContext(), GSArrowCursor, &c); [cur _setCid: c]; return cur; } -+ (NSCursor *)currentCursor ++ (NSCursor*) currentCursor { return gnustep_gui_current_cursor; } -+ (NSCursor *)IBeamCursor ++ (NSCursor*) IBeamCursor { - void *c; - NSCursor *cur = AUTORELEASE([[NSCursor alloc] initWithImage: nil]); + void *c; + NSCursor *cur = AUTORELEASE([[NSCursor alloc] initWithImage: nil]); + DPSstandardcursor(GSCurrentContext(), GSIBeamCursor, &c); [cur _setCid: c]; return cur; } -// -// Instance methods -// - -// -// Initializing a New NSCursor Object -// -- init +/* + * Initializing a New NSCursor Object + */ +- (id) init { - return [self initWithImage: nil]; + return [self initWithImage: nil hotSpot: NSMakePoint(0,15)]; } -- (id)initWithImage:(NSImage *)newImage +- (id) initWithImage: (NSImage *)newImage { - [super init]; - - cursor_image = newImage; - is_set_on_mouse_entered = NO; - is_set_on_mouse_exited = NO; + return [self initWithImage: newImage + hotSpot: NSMakePoint(0,15)]; +} +- (id) initWithImage: (NSImage *)newImage hotSpot: (NSPoint)spot +{ + self = [super init]; + if (self != nil) + { + cursor_image = newImage; + hot_spot = spot; + is_set_on_mouse_entered = NO; + is_set_on_mouse_exited = NO; + } return self; } -// -// Defining the Cursor -// -- (NSPoint)hotSpot +/* + * Defining the Cursor + */ +- (NSPoint) hotSpot { return hot_spot; } -- (NSImage *)image +- (NSImage*) image { return cursor_image; } -- (void)setHotSpot:(NSPoint)spot +- (void) setHotSpot: (NSPoint)spot { hot_spot = spot; } -- (void)setImage:(NSImage *)newImage +- (void) setImage: (NSImage *)newImage { cursor_image = newImage; } -// -// Setting the Cursor -// -- (BOOL)isSetOnMouseEntered +/* + * Setting the Cursor + */ +- (BOOL) isSetOnMouseEntered { return is_set_on_mouse_entered; } -- (BOOL)isSetOnMouseExited +- (BOOL) isSetOnMouseExited { return is_set_on_mouse_exited; } -// Hmm, how is this mouse entered/exited suppose to work? -// Is it simply what the doc says? -// If the cursor is set when the mouse enters -// then how does it get unset when the mouse exits? -- (void)mouseEntered:(NSEvent *)theEvent +- (void) mouseEntered: (NSEvent*)theEvent { - if (is_set_on_mouse_entered) - [self set]; + if (is_set_on_mouse_entered == YES) + { + [self set]; + } + else if (is_set_on_mouse_exited == NO) + { + /* + * Undocumented behavior - if a cursor is not set on exit or entry, + * we assume a push-pop situation instead. + */ + [self push]; + } } -- (void)mouseExited:(NSEvent *)theEvent +- (void) mouseExited: (NSEvent*)theEvent { - if (is_set_on_mouse_exited) - [self set]; + if (is_set_on_mouse_exited == YES) + { + [self set]; + } + else if (is_set_on_mouse_entered == NO) + { + /* + * Undocumented behavior - if a cursor is not set on exit or entry, + * we assume a push-pop situation instead. + */ + [self pop]; + } } -- (void)pop +- (void) pop { [NSCursor pop]; } -- (void)push +- (void) push { [gnustep_gui_cursor_stack addObject: self]; gnustep_gui_current_cursor = self; if (cid) - DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1, cid); + { + DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1, cid); + } } -- (void)set +- (void) set { gnustep_gui_current_cursor = self; if (cid) - DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1, cid); + { + DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1, cid); + } } -- (void)setOnMouseEntered:(BOOL)flag +- (void) setOnMouseEntered: (BOOL)flag { is_set_on_mouse_entered = flag; } -- (void)setOnMouseExited:(BOOL)flag +- (void) setOnMouseExited: (BOOL)flag { is_set_on_mouse_exited = flag; } -// -// NSCoding protocol -// +/* + * NSCoding protocol + */ - (void) encodeWithCoder: (NSCoder*)aCoder { } diff --git a/Source/NSTextField.m b/Source/NSTextField.m index ade22e0b6..050b5577c 100644 --- a/Source/NSTextField.m +++ b/Source/NSTextField.m @@ -66,32 +66,19 @@ [cell setEnabled: YES]; [cell setEditable: YES]; [self setDrawsBackground: YES]; - _text_cursor = [[NSCursor IBeamCursor] retain]; _text_object = nil; return self; } -- (void) dealloc -{ - [_text_cursor release]; - [super dealloc]; -} - // // Creating copies // -- (void) setTextCursor: (NSCursor *)aCursor -{ - ASSIGN(_text_cursor, aCursor); -} - - (id) copyWithZone: (NSZone*)zone { - id c; + NSTextField *c; - c = [(id)super copyWithZone: zone]; - [c setTextCursor: [NSCursor IBeamCursor]]; + c = [super copyWithZone: zone]; return c; } @@ -441,13 +428,6 @@ // In all other cases return YES; } -// -// Manage the cursor -// -- (void) resetCursorRects -{ - [self addCursorRect: bounds cursor: _text_cursor]; -} // // NSCoding protocol diff --git a/Source/NSView.m b/Source/NSView.m index 46684d35a..9728d7035 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -1792,26 +1792,36 @@ GSSetDragTypes(NSView* obj, NSArray *types) */ - (void) addCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject { - GSTrackingRect *m; + if (window != nil) + { + GSTrackingRect *m; - if (window) - aRect = [self convertRect: aRect toView: nil]; - m = [rectClass allocWithZone: NSDefaultMallocZone()]; - m = [m initWithRect: aRect - tag: 0 - owner: anObject - userData: NULL - inside: YES]; - [cursor_rects addObject: m]; - RELEASE(m); - _rFlags.has_currects = 1; + aRect = [self convertRect: aRect toView: nil]; + m = [rectClass allocWithZone: NSDefaultMallocZone()]; + m = [m initWithRect: aRect + tag: 0 + owner: anObject + userData: NULL + inside: YES]; + [cursor_rects addObject: m]; + RELEASE(m); + _rFlags.has_currects = 1; + _rFlags.valid_rects = 1; + } } - (void) discardCursorRects { - [cursor_rects makeObjectsPerformSelector: @selector(invalidate)]; - [cursor_rects removeAllObjects]; - _rFlags.has_currects = 0; + if (_rFlags.has_currects != 0) + { + if (_rFlags.valid_rects != 0) + { + [cursor_rects makeObjectsPerformSelector: @selector(invalidate)]; + _rFlags.valid_rects = 0; + } + [cursor_rects removeAllObjects]; + _rFlags.has_currects = 0; + } } - (void) removeCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject @@ -1830,16 +1840,22 @@ GSSetDragTypes(NSView* obj, NSArray *types) [o invalidate]; [cursor_rects removeObject: o]; if ([cursor_rects count] == 0) - _rFlags.has_currects = 0; + { + _rFlags.has_currects = 0; + _rFlags.valid_rects = 0; + } break; } else - o = [e nextObject]; + { + o = [e nextObject]; + } } } - (void) resetCursorRects -{} +{ +} static NSView* findByTag(NSView *view, int aTag, unsigned *level) { @@ -2530,6 +2546,10 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level) unsigned count; coordinates_valid = NO; + if (_rFlags.valid_rects != 0) + { + [window invalidateCursorRectsForView: self]; + } if (_rFlags.has_subviews) { count = [sub_views count]; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 5b6a72450..abd092103 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -1077,31 +1077,39 @@ static NSMapTable* windowmaps = NULL; cursor_rects_enabled = NO; } -- (void) discardCursorRectsForView: (NSView *)theView +static void +discardCursorRectsForView(NSView *theView) { - if (((NSViewPtr)theView)->_rFlags.has_currects) - [theView discardCursorRects]; - - if (((NSViewPtr)theView)->_rFlags.has_subviews) + if (theView != nil) { - NSArray *s = ((NSViewPtr)theView)->sub_views; - unsigned count = [s count]; - - if (count) + if (((NSViewPtr)theView)->_rFlags.has_currects) { - NSView *subs[count]; - unsigned i; + [theView discardCursorRects]; + } - [s getObjects: subs]; - for (i = 0; i < count; i++) - [self discardCursorRectsForView: subs[i]]; + if (((NSViewPtr)theView)->_rFlags.has_subviews) + { + NSArray *s = ((NSViewPtr)theView)->sub_views; + unsigned count = [s count]; + + if (count) + { + NSView *subs[count]; + unsigned i; + + [s getObjects: subs]; + for (i = 0; i < count; i++) + { + discardCursorRectsForView(subs[i]); + } + } } } } - (void) discardCursorRects { - [self discardCursorRectsForView: [content_view superview]]; + discardCursorRectsForView([content_view superview]); } - (void) enableCursorRects @@ -1111,34 +1119,46 @@ static NSMapTable* windowmaps = NULL; - (void) invalidateCursorRectsForView: (NSView *)aView { - cursor_rects_valid = NO; + if (((NSViewPtr)aView)->_rFlags.valid_rects) + { + [((NSViewPtr)aView)->cursor_rects + makeObjectsPerformSelector: @selector(invalidate)]; + ((NSViewPtr)aView)->_rFlags.valid_rects = 0; + cursor_rects_valid = NO; + } } -- (void) resetCursorRectsForView: (NSView *)theView +static void +resetCursorRectsForView(NSView *theView) { - if (((NSViewPtr)theView)->_rFlags.has_currects) - [theView resetCursorRects]; - - if (((NSViewPtr)theView)->_rFlags.has_subviews) + if (theView != nil) { - NSArray *s = ((NSViewPtr)theView)->sub_views; - unsigned count = [s count]; + [theView resetCursorRects]; - if (count) + if (((NSViewPtr)theView)->_rFlags.has_subviews) { - NSView *subs[count]; - unsigned i; + NSArray *s = ((NSViewPtr)theView)->sub_views; + unsigned count = [s count]; - [s getObjects: subs]; - for (i = 0; i < count; i++) - [self resetCursorRectsForView: subs[i]]; + if (count) + { + NSView *subs[count]; + unsigned i; + + [s getObjects: subs]; + for (i = 0; i < count; i++) + { + resetCursorRectsForView(subs[i]); + } + } } } } - (void) resetCursorRects { - [self resetCursorRectsForView: [content_view superview]]; + [self discardCursorRects]; + resetCursorRectsForView([content_view superview]); cursor_rects_valid = YES; } @@ -1463,7 +1483,17 @@ static NSMapTable* windowmaps = NULL; if ((!last) && (now)) // Mouse entered event { - if (r->ownerRespondsToMouseEntered) + if (r->flags.checked == NO) + { + if ([r->owner respondsToSelector: + @selector(mouseEntered:)]) + r->flags.ownerRespondsToMouseEntered = YES; + if ([r->owner respondsToSelector: + @selector(mouseExited:)]) + r->flags.ownerRespondsToMouseExited = YES; + r->flags.checked = YES; + } + if (r->flags.ownerRespondsToMouseEntered) { NSEvent *e; @@ -1482,7 +1512,17 @@ static NSMapTable* windowmaps = NULL; if ((last) && (!now)) // Mouse exited event { - if (r->ownerRespondsToMouseExited) + if (r->flags.checked == NO) + { + if ([r->owner respondsToSelector: + @selector(mouseEntered:)]) + r->flags.ownerRespondsToMouseEntered = YES; + if ([r->owner respondsToSelector: + @selector(mouseExited:)]) + r->flags.ownerRespondsToMouseExited = YES; + r->flags.checked = YES; + } + if (r->flags.ownerRespondsToMouseExited) { NSEvent *e; @@ -1524,7 +1564,7 @@ static NSMapTable* windowmaps = NULL; - (void) _checkCursorRectangles: (NSView *)theView forEvent: (NSEvent *)theEvent { - if (((NSViewPtr)theView)->_rFlags.has_currects) + if (((NSViewPtr)theView)->_rFlags.valid_rects) { NSArray *tr = ((NSViewPtr)theView)->cursor_rects; unsigned count = [tr count]; @@ -1534,8 +1574,6 @@ static NSMapTable* windowmaps = NULL; { GSTrackingRect *rects[count]; NSPoint loc = [theEvent locationInWindow]; - NSPoint lastConv; - NSPoint locConv; unsigned i; [tr getObjects: rects]; @@ -1552,8 +1590,8 @@ static NSMapTable* windowmaps = NULL; /* * Check for presence of point in rectangle. */ - last = NSMouseInRect(lastConv, r->rectangle, NO); - now = NSMouseInRect(locConv, r->rectangle, NO); + last = NSMouseInRect(last_point, r->rectangle, NO); + now = NSMouseInRect(loc, r->rectangle, NO); // Mouse entered if ((!last) && (now)) @@ -1635,7 +1673,6 @@ static NSMapTable* windowmaps = NULL; if (!cursor_rects_valid) { - [self discardCursorRects]; [self resetCursorRects]; } @@ -1763,19 +1800,16 @@ static NSMapTable* windowmaps = NULL; case NSCursorUpdate: // Cursor update { - GSTrackingRect *r =(GSTrackingRect *)[theEvent userData]; - NSCursor *c = (NSCursor *)[r owner]; + GSTrackingRect *r =(GSTrackingRect *)[theEvent userData]; + NSCursor *c = (NSCursor *)[r owner]; - c = (NSCursor *)[r owner]; if ([theEvent trackingNumber]) // It's a mouse entered { - if (c && [c isSetOnMouseEntered]) - [c set]; + [c mouseEntered: theEvent]; } else // it is a mouse exited { - if (c && [c isSetOnMouseExited]) - [c set]; + [c mouseExited: theEvent]; } } break;