From 87f6314dabdc2067a19e01f8b29f9ecc38ed825b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 8 Mar 2014 14:13:27 +0000 Subject: move scheduleing into browser operation table --- cocoa/apple_image.m | 11 ++++++----- cocoa/gui.m | 2 ++ cocoa/schedule.h | 19 +++++++++++++++++++ cocoa/schedule.m | 20 +++++++++----------- 4 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 cocoa/schedule.h (limited to 'cocoa') diff --git a/cocoa/apple_image.m b/cocoa/apple_image.m index ab17f8ab4..c6f9df324 100644 --- a/cocoa/apple_image.m +++ b/cocoa/apple_image.m @@ -25,7 +25,8 @@ #include "image/bitmap.h" #include "desktop/plotters.h" #include "utils/utils.h" -#include "utils/schedule.h" + +#include "cocoa/schedule.h" typedef struct apple_image_content { struct content base; @@ -147,7 +148,7 @@ static void animate_image_cb( void *ptr ) data.redraw.object = &ai->base; content_broadcast( &ai->base, CONTENT_MSG_REDRAW, data ); - schedule( ai->frameTimes[ai->currentFrame], animate_image_cb, ai ); + cocoa_schedule(ai->frameTimes[ai->currentFrame], animate_image_cb, ai ); } /** @@ -190,10 +191,10 @@ bool apple_image_convert(struct content *c) ai->frameTimes = calloc( ai->frames , sizeof(int)); for (NSUInteger i = 0; i < frames; i++) { [image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: i]]; - ai->frameTimes[i] = 100 * [[image valueForProperty: NSImageCurrentFrameDuration] floatValue]; + ai->frameTimes[i] = 1000 * [[image valueForProperty: NSImageCurrentFrameDuration] floatValue]; } [image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: 0]]; - schedule( ai->frameTimes[0], animate_image_cb, ai ); + cocoa_schedule( ai->frameTimes[0], animate_image_cb, ai ); } return true; @@ -206,7 +207,7 @@ void apple_image_destroy(struct content *c) [(id)ai_c->bitmap release]; ai_c->bitmap = NULL; - schedule_remove( animate_image_cb, c ); + cocoa_schedule(-1, animate_image_cb, c ); } diff --git a/cocoa/gui.m b/cocoa/gui.m index eba33014b..9ba614475 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -25,6 +25,7 @@ #import "cocoa/BrowserWindowController.h" #import "cocoa/FormSelectMenu.h" #import "cocoa/fetch.h" +#import "cocoa/schedule.h" #import "desktop/gui.h" #import "desktop/netsurf.h" @@ -294,6 +295,7 @@ struct gui_window_table *cocoa_window_table = &window_table; static struct gui_browser_table browser_table = { .poll = gui_poll, + .schedule = cocoa_schedule, .launch_url = gui_launch_url, .create_form_select_menu = gui_create_form_select_menu, diff --git a/cocoa/schedule.h b/cocoa/schedule.h new file mode 100644 index 000000000..43b2c1462 --- /dev/null +++ b/cocoa/schedule.h @@ -0,0 +1,19 @@ +/* + * Copyright 2011 Sven Weidauer + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +nserror cocoa_schedule(int t, void (*callback)(void *p), void *p); diff --git a/cocoa/schedule.m b/cocoa/schedule.m index 1ad75b390..2dd9a81f6 100644 --- a/cocoa/schedule.m +++ b/cocoa/schedule.m @@ -17,7 +17,8 @@ */ #import -#import "utils/schedule.h" + +#import "cocoa/schedule.h" @interface ScheduledCallback : NSObject { void (*callback)( void *userData ); @@ -73,18 +74,15 @@ static NSMutableSet *timerSet = nil; @end -/* In platform specific schedule.c. */ -void schedule(int t, void (*callback)(void *p), void *p) -{ - ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p]; - [cb schedule: (NSTimeInterval)t / 100]; - [cb release]; -} - -void schedule_remove(void (*callback)(void *p), void *p) +/* exported interface documented in cocoa/schedule.h */ +nserror cocoa_schedule(int t, void (*callback)(void *p), void *p) { ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p]; [timerSet removeObject: cb]; + if (t >= 0) { + [cb schedule: (NSTimeInterval)t / 1000]; + } [cb release]; -} + return NSERROR_OK; +} -- cgit v1.2.3