Tue, 07 Nov 2023 20:59:10 +0100
use the context flag to quit the application
src/ascension/window.h | file | annotate | diff | comparison | revisions | |
src/window.c | file | annotate | diff | comparison | revisions |
--- a/src/ascension/window.h Tue Nov 07 20:24:08 2023 +0100 +++ b/src/ascension/window.h Tue Nov 07 20:59:10 2023 +0100 @@ -63,7 +63,7 @@ /** * Dispatches events and synchronizes all initialized windows. * - * @return false, if one of the events is a QUIT event, true otherwise + * @return false, if the application wants to quit, true otherwise */ bool asc_loop_next(void);
--- a/src/window.c Tue Nov 07 20:24:08 2023 +0100 +++ b/src/window.c Tue Nov 07 20:59:10 2023 +0100 @@ -28,6 +28,7 @@ #include "ascension/window.h" #include "ascension/context.h" #include "ascension/error.h" +#include "ascension/utils.h" #include <cx/linked_list.h> #include <cx/printf.h> @@ -66,7 +67,9 @@ SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { - case SDL_QUIT:return false; + case SDL_QUIT: + asc_set_flag(&asc_context.flags, ASC_FLAG_QUIT); + break; case SDL_WINDOWEVENT: { if (event.window.type == SDL_WINDOWEVENT_RESIZED) asc_event_window_resized( @@ -93,7 +96,8 @@ asc_window_sync(&asc_context.windows[i]); } } - return true; + + return !asc_test_flag(asc_context.flags, ASC_FLAG_QUIT); } void asc_window_settings_init_defaults(AscWindowSettings* settings) {