From b212e59a20f304132e8c6636771d250ac7998ad3 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Thu, 6 Nov 2003 19:41:41 +0000 Subject: [project @ 2003-11-06 19:41:41 by bursa] Mask null polls and use PollIdle when appropriate. svn path=/import/netsurf/; revision=406 --- desktop/gui.h | 3 ++- desktop/netsurf.c | 55 +++++++++++++++++++++++++++++++++++-------------------- desktop/netsurf.h | 4 ++-- 3 files changed, 39 insertions(+), 23 deletions(-) (limited to 'desktop') diff --git a/desktop/gui.h b/desktop/gui.h index bb52979c2..aa87b6681 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -15,6 +15,7 @@ typedef enum { SAFE, UNSAFE } gui_safety; struct gui_window; typedef struct gui_window gui_window; +#include #include "netsurf/desktop/browser.h" struct gui_message @@ -51,7 +52,7 @@ void gui_download_window_error(gui_window *g, const char *error); void gui_init(int argc, char** argv); void gui_multitask(void); -void gui_poll(void); +void gui_poll(bool active); gui_safety gui_window_set_redraw_safety(gui_window* g, gui_safety s); diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 0392d986a..ebc364612 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -6,6 +6,8 @@ * Copyright 2003 James Bursa */ +#include +#include #include "netsurf/desktop/options.h" #include "netsurf/desktop/netsurf.h" #include "netsurf/desktop/browser.h" @@ -13,21 +15,35 @@ #include "netsurf/content/cache.h" #include "netsurf/content/fetch.h" #include "netsurf/utils/log.h" -#include -int netsurf_quit = 0; +bool netsurf_quit = false; static void netsurf_init(int argc, char** argv); +static void netsurf_poll(void); static void netsurf_exit(void); -void netsurf_poll(void) +/** + * Gui NetSurf main(). + */ + +int main(int argc, char** argv) { - gui_poll(); - fetch_poll(); + netsurf_init(argc, argv); + + while (!netsurf_quit) + netsurf_poll(); + + netsurf_exit(); + + return EXIT_SUCCESS; } +/** + * Initialise components used by gui NetSurf. + */ + void netsurf_init(int argc, char** argv) { stdout = stderr; @@ -41,24 +57,23 @@ void netsurf_init(int argc, char** argv) } -void netsurf_exit(void) -{ - cache_quit(); - fetch_quit(); -} - +/** + * Poll components which require it. + */ -int main(int argc, char** argv) +void netsurf_poll(void) { - netsurf_init(argc, argv); + gui_poll(fetch_active); + fetch_poll(); +} - while (netsurf_quit == 0) - netsurf_poll(); - LOG(("Netsurf quit!")); - netsurf_exit(); +/** + * Clean up components used by gui NetSurf. + */ - return 0; +void netsurf_exit(void) +{ + cache_quit(); + fetch_quit(); } - - diff --git a/desktop/netsurf.h b/desktop/netsurf.h index 67329e164..aa3bf8b54 100644 --- a/desktop/netsurf.h +++ b/desktop/netsurf.h @@ -8,9 +8,9 @@ #ifndef _NETSURF_DESKTOP_NETSURF_H_ #define _NETSURF_DESKTOP_NETSURF_H_ -extern int netsurf_quit; +#include -void netsurf_poll(void); +extern bool netsurf_quit; #endif -- cgit v1.2.3