From 48c6ba4b498a74c76d6e74db68c6cb82c378c3c7 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Fri, 28 Jan 2011 14:40:25 +0000 Subject: Timer based reformatting, so reformat happens also while resizing windows. svn path=/trunk/netsurf/; revision=11519 --- cocoa/BrowserView.m | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'cocoa/BrowserView.m') diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m index fd7c938db..a88b31032 100644 --- a/cocoa/BrowserView.m +++ b/cocoa/BrowserView.m @@ -35,6 +35,9 @@ - (void) scrollVertical: (CGFloat) amount; - (CGFloat) pageScroll; ++ (void)reformatTimerFired: (NSTimer *) timer; +- (void) reformat; + @end @implementation BrowserView @@ -44,6 +47,7 @@ static const CGFloat CaretWidth = 1.0; static const NSTimeInterval CaretBlinkTime = 0.8; +static NSMutableArray *cocoa_reformat_pending = nil; - (void) dealloc; { @@ -378,6 +382,12 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) { browser->reformat_pending = true; browser_reformat_pending = true; + + if (cocoa_reformat_pending == nil) { + cocoa_reformat_pending = [[NSMutableArray alloc] init]; + } + [cocoa_reformat_pending addObject: self]; + [super adjustFrame]; } @@ -420,10 +430,26 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) - (void) reformat; { - if (!browser->reformat_pending) return; - NSRect size = [[self superview] frame]; browser_window_reformat( browser, cocoa_pt_to_px( NSWidth( size ) ), cocoa_pt_to_px( NSHeight( size ) ) ); } ++ (void)reformatTimerFired: (NSTimer *) timer; +{ + if (browser_reformat_pending) { + [cocoa_reformat_pending makeObjectsPerformSelector: @selector( reformat )]; + [cocoa_reformat_pending removeAllObjects]; + browser_reformat_pending = false; + } +} + ++ (void) initialize; +{ + NSTimer *timer = [[NSTimer alloc] initWithFireDate: nil interval: 0.02 + target: self selector: @selector(reformatTimerFired:) + userInfo: nil repeats: YES]; + [[NSRunLoop currentRunLoop] addTimer: timer forMode: NSRunLoopCommonModes]; + [timer release]; +} + @end -- cgit v1.2.3