summaryrefslogtreecommitdiff
path: root/cocoa/BrowserView.m
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-01-28 14:40:25 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-01-28 14:40:25 +0000
commit48c6ba4b498a74c76d6e74db68c6cb82c378c3c7 (patch)
tree98d873d9ed028f115c4ff512fcfe2521433a26d2 /cocoa/BrowserView.m
parent3ba2596f5c5c82af5c342359e29e9f65160f4f56 (diff)
downloadnetsurf-48c6ba4b498a74c76d6e74db68c6cb82c378c3c7.tar.gz
netsurf-48c6ba4b498a74c76d6e74db68c6cb82c378c3c7.tar.bz2
Timer based reformatting, so reformat happens also while resizing windows.
svn path=/trunk/netsurf/; revision=11519
Diffstat (limited to 'cocoa/BrowserView.m')
-rw-r--r--cocoa/BrowserView.m30
1 files changed, 28 insertions, 2 deletions
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