summaryrefslogtreecommitdiff
path: root/src/sdl_fb.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-02-25 18:20:28 -0800
committerVito Caputo <vcaputo@pengaru.com>2018-02-26 05:18:59 -0800
commitded1f41f810c25eac77899250d2223ea251a899f (patch)
tree81dd342a2f6e53699ffccbb0b8e6df1b4abc961c /src/sdl_fb.c
parent29a6c98f522236a9abb9a8f2e83fdf76bc39c614 (diff)
sdl_fb: drain event queue on page flip
Diffstat (limited to 'src/sdl_fb.c')
-rw-r--r--src/sdl_fb.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/sdl_fb.c b/src/sdl_fb.c
index 52cf556..b663848 100644
--- a/src/sdl_fb.c
+++ b/src/sdl_fb.c
@@ -120,10 +120,31 @@ static int sdl_fb_page_free(void *context, void *page)
}
+static int sdl_ready()
+{
+ SDL_Event ev;
+
+ /* It's important on Windows in particular to
+ * drain the event queue vs. just SDL_QuitRequested()
+ */
+ while (SDL_PollEvent(&ev)) {
+ if (ev.type == SDL_QUIT)
+ return -EPIPE;
+ }
+
+ return 0;
+}
+
+
static int sdl_fb_page_flip(void *context, void *page)
{
sdl_fb_t *c = context;
sdl_fb_page_t *p = page;
+ int r;
+
+ r = sdl_ready();
+ if (r < 0)
+ return r;
if (SDL_UpdateTexture(c->texture, NULL, p->surface->pixels, p->surface->pitch) < 0)
return -1;
@@ -136,9 +157,6 @@ static int sdl_fb_page_flip(void *context, void *page)
SDL_RenderPresent(c->renderer);
- if (SDL_QuitRequested())
- return -EPIPE;
-
return 0;
}
© All Rights Reserved