summaryrefslogtreecommitdiff
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
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
-rw-r--r--cocoa/BrowserView.m30
-rw-r--r--cocoa/gui.m13
2 files changed, 28 insertions, 15 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
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 517489f33..33ab922d3 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -46,8 +46,6 @@ NSString * const kHotlistFileOption = @"Hotlist";
NSString * const kHomepageURLOption = @"HomepageURL";
NSString * const kOptionsFileOption = @"ClassicOptionsFile";
-static NSMutableSet *cocoa_all_browser_views = nil;
-
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
void gui_multitask(void)
@@ -66,11 +64,6 @@ void gui_poll(bool active)
[NSApp sendEvent: event];
[NSApp updateWindows];
}
-
- if (browser_reformat_pending) {
- [cocoa_all_browser_views makeObjectsPerformSelector: @selector( reformat )];
- browser_reformat_pending = false;
- }
}
void gui_quit(void)
@@ -106,11 +99,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
[[parent browserView] addSubview: [result view]];
}
- if (cocoa_all_browser_views == nil) {
- cocoa_all_browser_views = [[NSMutableSet alloc] init];
- }
- [cocoa_all_browser_views addObject: [result browserView]];
-
return (struct gui_window *)result;
}
@@ -124,7 +112,6 @@ void gui_window_destroy(struct gui_window *g)
BrowserViewController *vc = (BrowserViewController *)g;
if ([vc browser]->parent != NULL) [[vc view] removeFromSuperview];
- [cocoa_all_browser_views removeObject: [vc browserView]];
[vc release];
}