# HG changeset patch # User Michael Pavone # Date 1459140130 25200 # Node ID ae58e7c3c3285a646a2bf911ad18cd0618891eda # Parent c8a0dbd7752c4a48c93dd2156c1bb3a3c0a99446 Poll events regularly to avoid unresponsive app warnings. Handle quit event diff -r c8a0dbd7752c -r ae58e7c3c328 src/main.c --- a/src/main.c Sun Mar 27 21:31:34 2016 -0700 +++ b/src/main.c Sun Mar 27 21:42:10 2016 -0700 @@ -107,6 +107,7 @@ vdp_run(&context->video, CYCLES_PER_FRAME); context->proc->cycles -= CYCLES_PER_FRAME; context->video.cycles -= CYCLES_PER_FRAME; + system_poll_events(); } } diff -r c8a0dbd7752c -r ae58e7c3c328 src/system.h --- a/src/system.h Sun Mar 27 21:31:34 2016 -0700 +++ b/src/system.h Sun Mar 27 21:42:10 2016 -0700 @@ -4,5 +4,6 @@ int system_init(int width, int height); uint16_t *system_get_framebuffer(int *pitch); void system_framebuffer_updated(); +void system_poll_events(); #endif //SYSTEM_H_ diff -r c8a0dbd7752c -r ae58e7c3c328 src/system_sdl.c --- a/src/system_sdl.c Sun Mar 27 21:31:34 2016 -0700 +++ b/src/system_sdl.c Sun Mar 27 21:42:10 2016 -0700 @@ -1,5 +1,6 @@ #include #include +#include SDL_Window *window; @@ -49,3 +50,17 @@ SDL_RenderPresent(renderer); } +void system_poll_events() +{ + SDL_Event event; + while(SDL_PollEvent(&event)) + { + switch (event.type) + { + case SDL_QUIT: + exit(0); + break; + } + } +} +