Cache the default notification center. In [sendEvent:] handle case

of NSScrollWheel event.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10768 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2001-08-21 23:24:00 +00:00
parent 7c88e9d626
commit 87aaee9c56

View file

@ -407,6 +407,8 @@ static Class viewClass;
static NSMutableSet *autosaveNames; static NSMutableSet *autosaveNames;
static NSRecursiveLock *windowsLock; static NSRecursiveLock *windowsLock;
static NSMapTable* windowmaps = NULL; static NSMapTable* windowmaps = NULL;
static NSNotificationCenter *nc = nil;
/* /*
* Class methods * Class methods
@ -425,6 +427,7 @@ static NSMapTable* windowmaps = NULL;
viewClass = [NSView class]; viewClass = [NSView class];
autosaveNames = [NSMutableSet new]; autosaveNames = [NSMutableSet new];
windowsLock = [NSRecursiveLock new]; windowsLock = [NSRecursiveLock new];
nc = [NSNotificationCenter defaultCenter];
} }
} }
@ -530,7 +533,7 @@ static NSMapTable* windowmaps = NULL;
{ {
NSGraphicsContext *context = GSCurrentContext(); NSGraphicsContext *context = GSCurrentContext();
[[NSNotificationCenter defaultCenter] removeObserver: self]; [nc removeObserver: self];
[[NSRunLoop currentRunLoop] [[NSRunLoop currentRunLoop]
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:) cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
target: self target: self
@ -921,9 +924,8 @@ static NSMapTable* windowmaps = NULL;
if (t && (_firstResponder == t)) if (t && (_firstResponder == t))
{ {
[[NSNotificationCenter defaultCenter] [nc postNotificationName: NSTextDidEndEditingNotification
postNotificationName: NSTextDidEndEditingNotification object: t];
object: t];
[t setText: @""]; [t setText: @""];
[t setDelegate: nil]; [t setDelegate: nil];
[t removeFromSuperview]; [t removeFromSuperview];
@ -984,8 +986,6 @@ static NSMapTable* windowmaps = NULL;
{ {
if (_f.is_key == NO) if (_f.is_key == NO)
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[_firstResponder becomeFirstResponder]; [_firstResponder becomeFirstResponder];
if ((_firstResponder != self) if ((_firstResponder != self)
&& [_firstResponder respondsToSelector: @selector(becomeKeyWindow)]) && [_firstResponder respondsToSelector: @selector(becomeKeyWindow)])
@ -1003,8 +1003,6 @@ static NSMapTable* windowmaps = NULL;
{ {
if (_f.is_main == NO) if (_f.is_main == NO)
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
_f.is_main = YES; _f.is_main = YES;
if (_f.is_key == NO) if (_f.is_key == NO)
{ {
@ -1202,8 +1200,6 @@ static NSMapTable* windowmaps = NULL;
{ {
if (_f.is_key == YES) if (_f.is_key == YES)
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
if ((_firstResponder != self) if ((_firstResponder != self)
&& [_firstResponder respondsToSelector: @selector(resignKeyWindow)]) && [_firstResponder respondsToSelector: @selector(resignKeyWindow)])
[_firstResponder resignKeyWindow]; [_firstResponder resignKeyWindow];
@ -1228,8 +1224,6 @@ static NSMapTable* windowmaps = NULL;
{ {
if (_f.is_main == YES) if (_f.is_main == YES)
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
_f.is_main = NO; _f.is_main = NO;
if (_f.is_key == YES) if (_f.is_key == YES)
{ {
@ -1337,8 +1331,6 @@ static NSMapTable* windowmaps = NULL;
- (void) setFrame: (NSRect)frameRect display: (BOOL)flag - (void) setFrame: (NSRect)frameRect display: (BOOL)flag
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
if (_maximumSize.width > 0 && frameRect.size.width > _maximumSize.width) if (_maximumSize.width > 0 && frameRect.size.width > _maximumSize.width)
{ {
frameRect.size.width = _maximumSize.width; frameRect.size.width = _maximumSize.width;
@ -1528,8 +1520,6 @@ static NSMapTable* windowmaps = NULL;
- (void) update - (void) update
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
/* /*
* if autodisplay is enabled and window display * if autodisplay is enabled and window display
*/ */
@ -1832,7 +1822,6 @@ resetCursorRectsForView(NSView *theView)
*/ */
- (void) close - (void) close
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
CREATE_AUTORELEASE_POOL(pool); CREATE_AUTORELEASE_POOL(pool);
[nc postNotificationName: NSWindowWillCloseNotification object: self]; [nc postNotificationName: NSWindowWillCloseNotification object: self];
@ -1863,8 +1852,6 @@ resetCursorRectsForView(NSView *theView)
*/ */
- (void) _didDeminiaturize: sender - (void) _didDeminiaturize: sender
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
_f.is_miniaturized = NO; _f.is_miniaturized = NO;
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self]; [nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
} }
@ -1894,8 +1881,6 @@ resetCursorRectsForView(NSView *theView)
- (void) miniaturize: (id)sender - (void) miniaturize: (id)sender
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: NSWindowWillMiniaturizeNotification [nc postNotificationName: NSWindowWillMiniaturizeNotification
object: self]; object: self];
@ -2600,13 +2585,17 @@ resetCursorRectsForView(NSView *theView)
} }
break; break;
case NSScrollWheel:
v = [_contentView hitTest: [theEvent locationInWindow]];
[v scrollWheel: theEvent];
break;
case NSAppKitDefined: case NSAppKitDefined:
{ {
id dragInfo; id dragInfo;
int action; int action;
NSEvent *e; NSEvent *e;
GSAppKitSubtype sub = [theEvent subtype]; GSAppKitSubtype sub = [theEvent subtype];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
switch (sub) switch (sub)
{ {
@ -3274,8 +3263,6 @@ resetCursorRectsForView(NSView *theView)
- (void) setDelegate: (id)anObject - (void) setDelegate: (id)anObject
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
if (_delegate) if (_delegate)
{ {
[nc removeObserver: _delegate name: nil object: self]; [nc removeObserver: _delegate name: nil object: self];