From ae14542c9a96e1c10a73f9e06fd3f62dd42d088e Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 17 Jun 2016 09:22:31 -0400 Subject: [PATCH] Improved uiMainSteps(). --- README.md | 3 +++ darwin/main.m | 3 +-- test/main.c | 2 +- ui.h | 2 +- unix/main.c | 4 +++- windows/main.cpp | 4 ++-- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8a71e539..6d165442 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ This README is being written.
*Note that today's entry (Eastern Time) may be updated later today.* +* **17 June 2016** + * `uiMainSteps()` no longer takes any arguments and no longer needs to invoke a function to do the work. You still need to call it, but once you do, it will return immediately and you can then get right to your main loop. + * **16 June 2016** * Added `uiWindowContentSize()`, `uiWindowSetContentSize()`, and `uiWindowOnContentSizeChanged()` methods for manipulating uiWindow content sizes. Note the use of "content size"; the size you work with does NOT include window decorations (titlebars, menus, etc.). * Added `uiWindowFullscreen()` and `uiWindowSetFullscreen()` to allow making fullscreen uiWindows, taking advantage of OS facilities for fullscreen and without changing the screen resolution (!). diff --git a/darwin/main.m b/darwin/main.m index 6faef4f4..2c934330 100644 --- a/darwin/main.m +++ b/darwin/main.m @@ -159,13 +159,12 @@ void uiMain(void) [realNSApp() run]; } -void uiMainSteps(void (*f)(void *), void *data) +void uiMainSteps(void) { isRunning = ^{ return stepsIsRunning; }; stepsIsRunning = YES; - (*f)(data); } // see also: diff --git a/test/main.c b/test/main.c index 1ae5ec12..803326b5 100644 --- a/test/main.c +++ b/test/main.c @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) if (!steps) uiMain(); else { - uiMainSteps(NULL, NULL); + uiMainSteps(); while (uiMainStep(1)) ; } diff --git a/ui.h b/ui.h index 82079371..7012dc16 100644 --- a/ui.h +++ b/ui.h @@ -45,7 +45,7 @@ _UI_EXTERN void uiUninit(void); _UI_EXTERN void uiFreeInitError(const char *err); _UI_EXTERN void uiMain(void); -_UI_EXTERN void uiMainSteps(void (*f)(void *), void *data); +_UI_EXTERN void uiMainSteps(void); _UI_EXTERN int uiMainStep(int wait); _UI_EXTERN void uiQuit(void); diff --git a/unix/main.c b/unix/main.c index bdd22eeb..d6eff223 100644 --- a/unix/main.c +++ b/unix/main.c @@ -39,13 +39,15 @@ void uiMain(void) static gboolean stepsQuit = FALSE; +// the only difference is we ignore the return value from gtk_main_iteration_do(), since it will always be TRUE if gtk_main() was never called +// gtk_main_iteration_do() will still run the main loop regardless static gboolean stepsIteration(gboolean block) { gtk_main_iteration_do(block); return stepsQuit; } -void uiMainSteps(void (*f)(void *), void *data) +void uiMainSteps(void) { iteration = stepsIteration; } diff --git a/windows/main.cpp b/windows/main.cpp index 5cc34332..eb6d8492 100644 --- a/windows/main.cpp +++ b/windows/main.cpp @@ -77,9 +77,9 @@ void uiMain(void) ; } -void uiMainSteps(void (*f)(void *), void *data) +void uiMainSteps(void) { - (*f)(data); + // don't need to do anything here } static int peekMessage(MSG *msg)