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 |
1.1 --- a/src/ascension/window.h Tue Nov 07 20:24:08 2023 +0100 1.2 +++ b/src/ascension/window.h Tue Nov 07 20:59:10 2023 +0100 1.3 @@ -63,7 +63,7 @@ 1.4 /** 1.5 * Dispatches events and synchronizes all initialized windows. 1.6 * 1.7 - * @return false, if one of the events is a QUIT event, true otherwise 1.8 + * @return false, if the application wants to quit, true otherwise 1.9 */ 1.10 bool asc_loop_next(void); 1.11
2.1 --- a/src/window.c Tue Nov 07 20:24:08 2023 +0100 2.2 +++ b/src/window.c Tue Nov 07 20:59:10 2023 +0100 2.3 @@ -28,6 +28,7 @@ 2.4 #include "ascension/window.h" 2.5 #include "ascension/context.h" 2.6 #include "ascension/error.h" 2.7 +#include "ascension/utils.h" 2.8 2.9 #include <cx/linked_list.h> 2.10 #include <cx/printf.h> 2.11 @@ -66,7 +67,9 @@ 2.12 SDL_Event event; 2.13 while (SDL_PollEvent(&event)) { 2.14 switch (event.type) { 2.15 - case SDL_QUIT:return false; 2.16 + case SDL_QUIT: 2.17 + asc_set_flag(&asc_context.flags, ASC_FLAG_QUIT); 2.18 + break; 2.19 case SDL_WINDOWEVENT: { 2.20 if (event.window.type == SDL_WINDOWEVENT_RESIZED) 2.21 asc_event_window_resized( 2.22 @@ -93,7 +96,8 @@ 2.23 asc_window_sync(&asc_context.windows[i]); 2.24 } 2.25 } 2.26 - return true; 2.27 + 2.28 + return !asc_test_flag(asc_context.flags, ASC_FLAG_QUIT); 2.29 } 2.30 2.31 void asc_window_settings_init_defaults(AscWindowSettings* settings) {