Timer based reformatting, so reformat happens also while resizing windows.

svn path=/trunk/netsurf/; revision=11519
This commit is contained in:
Sven Weidauer 2011-01-28 14:40:25 +00:00
parent 3ba2596f5c
commit 48c6ba4b49
2 changed files with 28 additions and 15 deletions

View File

@ -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

View File

@ -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];
}