From 0c7c4173c22586f5e033cfdf004fba9013084efa Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 12 Oct 2014 11:08:01 +0100 Subject: remove use of deprecated netsurf_quit variable in win32 The core no longer needs to run the event polling loop as fetches are now scheduler driven. This is part of a series which will ultimately remove netsurf_poll callback altogether. --- windows/gui.c | 50 ++++++++++++++++++++++++++++---------------------- windows/gui.h | 4 ++++ windows/main.c | 6 +++--- 3 files changed, 35 insertions(+), 25 deletions(-) (limited to 'windows') diff --git a/windows/gui.c b/windows/gui.c index 19a31c1be..b7ca31366 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -61,6 +61,8 @@ #include "windows/windbg.h" #include "windows/filetype.h" +static bool win32_quit = false; + HINSTANCE hInstance; /** win32 application instance handle. */ struct gui_window *input_window = NULL; @@ -95,37 +97,42 @@ static void nsws_set_scale(struct gui_window *gw, float scale) browser_window_set_scale(gw->bw, scale, true); } - -static void win32_poll(bool active) +/* exported interface documented in gui.h */ +void win32_run(void) { MSG Msg; /* message from system */ BOOL bRet; /* message fetch result */ int timeout; /* timeout in miliseconds */ UINT timer_id = 0; - /* run the scheduler and discover how long to wait for the next event */ - timeout = schedule_run(); + while (!win32_quit) { + /* run the scheduler and discover how long to wait for + * the next event. + */ + timeout = schedule_run(); - if (timeout == 0) { - bRet = PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE); - } else { - if (timeout > 0) { - /* set up a timer to ensure we get woken */ - timer_id = SetTimer(NULL, 0, timeout, NULL); - } + if (timeout == 0) { + bRet = PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE); + } else { + if (timeout > 0) { + /* set up a timer to ensure we get woken */ + timer_id = SetTimer(NULL, 0, timeout, NULL); + } - /* wait for a message */ - bRet = GetMessage(&Msg, NULL, 0, 0); + /* wait for a message */ + bRet = GetMessage(&Msg, NULL, 0, 0); - /* if a timer was sucessfully created remove it */ - if (timer_id != 0) { - KillTimer(NULL, timer_id); + /* if a timer was sucessfully created remove it */ + if (timer_id != 0) { + KillTimer(NULL, timer_id); + timer_id = 0; + } } - } - if (bRet > 0) { - TranslateMessage(&Msg); - DispatchMessage(&Msg); + if (bRet > 0) { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } } } @@ -1124,7 +1131,7 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) RemoveProp(hwnd, TEXT("GuiWnd")); browser_window_destroy(gw->bw); if (--open_windows <= 0) { - netsurf_quit = true; + win32_quit = true; } break; @@ -2126,7 +2133,6 @@ struct gui_fetch_table *win32_fetch_table = &fetch_table; static struct gui_browser_table browser_table = { - .poll = win32_poll, .schedule = win32_schedule, }; diff --git a/windows/gui.h b/windows/gui.h index 82ae83642..007afe7c8 100644 --- a/windows/gui.h +++ b/windows/gui.h @@ -97,5 +97,9 @@ nserror nsws_create_main_class(HINSTANCE hinstance); */ bool nsws_window_go(HWND hwnd, const char *url); +/** + * Run the win32 message loop with scheduling + */ +void win32_run(void); #endif diff --git a/windows/main.c b/windows/main.c index 20f9f041a..40b083f51 100644 --- a/windows/main.c +++ b/windows/main.c @@ -54,7 +54,7 @@ static nsurl *gui_get_resource_url(const char *path) return url; } -/** +/** * Ensures output logging stream is available */ static bool nslog_ensure(FILE *fptr) @@ -70,7 +70,7 @@ static bool nslog_ensure(FILE *fptr) } /** - * Set option defaults for framebuffer frontend + * Set option defaults for windows frontend * * @param defaults The option table to update. * @return error status. @@ -202,7 +202,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) if (ret != NSERROR_OK) { warn_user(messages_get_errorcode(ret), 0); } else { - netsurf_main_loop(); + win32_run(); } netsurf_exit(); -- cgit v1.2.3