From f2bcb34b09bfb173c287c8a8172e29017a35f63f Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 1 Dec 1999 12:02:09 +0000 Subject: [PATCH] Tidied up some inefficient code that was causing window to be checked much more often that needed. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5344 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 +++++++++- Source/NSCachedImageRep.m | 10 ++++++++++ Source/NSView.m | 5 ----- Source/NSWindow.m | 33 ++++++++++++++++++++++++++++++--- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f25783010..a577a7b9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,12 @@ -Web Dec 1 8:27:00 1999 Richard Frith-Macdonald +Wen Dec 1 11:55:00 1999 Richard Frith-Macdonald + + * Source/NSWindow.m: Removed spurious setNeedsDisplay when changing + the contentView of a window - it's up to the programmer to do that. + * Source/NSView.m: Removed many spurious setNeedsDisplay calls when + altering the view hierarchy - it's up to the programmer to do a + single call at the end of the work. + +Wen Dec 1 8:27:00 1999 Richard Frith-Macdonald Applied and modified/rewrote patch by Jonathan Gapen * Headers/gnustep/gui/NSImage.h: Moved excess BOOL ivar to _flags. diff --git a/Source/NSCachedImageRep.m b/Source/NSCachedImageRep.m index 264fe75d4..f5d7271f3 100644 --- a/Source/NSCachedImageRep.m +++ b/Source/NSCachedImageRep.m @@ -48,6 +48,16 @@ { [super initDefaults]; [self setExcludedFromWindowsMenu: YES]; + [self setAutodisplay: NO]; +} +- (void) display +{ +} +- (void) displayIfNeeded +{ +} +- (void) setViewsNeedDisplay: (BOOL)f +{ } @end diff --git a/Source/NSView.m b/Source/NSView.m index 0a24abe93..9db594ae0 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -271,7 +271,6 @@ GSSetDragTypes(NSView* obj, NSArray *types) [sub_views addObject: aView]; _rFlags.has_subviews = 1; [aView resetCursorRects]; - [aView setNeedsDisplay: YES]; RELEASE(aView); } @@ -310,7 +309,6 @@ GSSetDragTypes(NSView* obj, NSArray *types) [sub_views insertObject: aView atIndex: index+1]; _rFlags.has_subviews = 1; [aView resetCursorRects]; - [aView setNeedsDisplay: YES]; RELEASE(aView); } @@ -413,7 +411,6 @@ GSSetDragTypes(NSView* obj, NSArray *types) if ([window firstResponder] == self) [window makeFirstResponder: window]; - [super_view setNeedsDisplayInRect: frame]; RETAIN(self); [super_view->sub_views removeObjectIdenticalTo: self]; if ([super_view->sub_views count] == 0) @@ -448,7 +445,6 @@ GSSetDragTypes(NSView* obj, NSArray *types) [sub_views addObject: newView]; _rFlags.has_subviews = 1; [newView resetCursorRects]; - [newView setNeedsDisplay: YES]; RELEASE(newView); } else if ([sub_views indexOfObjectIdenticalTo: oldView] != NSNotFound) @@ -482,7 +478,6 @@ GSSetDragTypes(NSView* obj, NSArray *types) [sub_views addObject: newView]; _rFlags.has_subviews = 1; [newView resetCursorRects]; - [newView setNeedsDisplay: YES]; RELEASE(newView); } } diff --git a/Source/NSWindow.m b/Source/NSWindow.m index f26945ed9..b1489e229 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -373,7 +373,6 @@ static NSMapTable* windowmaps = NULL; [[wv subviews] count]); [content_view setNextResponder: self]; - [content_view setNeedsDisplay: YES]; // Make sure we redraw. } /* @@ -682,6 +681,16 @@ static NSMapTable* windowmaps = NULL; unsigned i; NSWindow *w; + if (_rFlags.needs_display == YES) + { + /* + * Don't keep trying to update the window while it is ordered out + */ + [[NSRunLoop currentRunLoop] + cancelPerformSelector: @selector(_handleWindowNeedsDisplay:) + target: self + argument: nil]; + } if ([self isKeyWindow]) { [self resignKeyWindow]; @@ -743,7 +752,25 @@ static NSMapTable* windowmaps = NULL; } } } - + else + { + if (_rFlags.needs_display == NO) + { + /* + * Once we are ordered back in, we will want to update the window + * whenever there is anything to do. + */ + [[NSRunLoop currentRunLoop] + performSelector: @selector(_handleWindowNeedsDisplay:) + target: self + argument: nil + order: 600000 + modes: [NSArray arrayWithObjects: + NSDefaultRunLoopMode, + NSModalPanelRunLoopMode, + NSEventTrackingRunLoopMode, nil]]; + } + } DPSorderwindow(GSCurrentContext(), place, otherWin, [self windowNumber]); } @@ -1108,7 +1135,7 @@ static NSMapTable* windowmaps = NULL; - (void) _handleWindowNeedsDisplay: (id)bogus { - [self displayIfNeeded]; + [self displayIfNeeded]; } - (void) setViewsNeedDisplay: (BOOL)flag