From da5d7982c6e040a68f22ff5d36e775ca209385a3 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 13 Jul 2020 17:31:30 +0100 Subject: [PATCH] Improve SDL2 event handling accuracy Now the event loop doesn't run constantly when the window isn't focussed. This should match the original WinAPI code's behaviour. --- src/Backends/Platform/SDL2.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Backends/Platform/SDL2.cpp b/src/Backends/Platform/SDL2.cpp index 268f28f3..d707c3af 100644 --- a/src/Backends/Platform/SDL2.cpp +++ b/src/Backends/Platform/SDL2.cpp @@ -165,13 +165,14 @@ void PlaybackBackend_EnableDragAndDrop(void) bool Backend_SystemTask(bool active) { - while (SDL_PollEvent(NULL)) - { - SDL_Event event; - - if (!SDL_WaitEvent(&event)) + if (!active) + if (!SDL_WaitEvent(NULL)) return false; + SDL_Event event; + + while (SDL_PollEvent(&event)) + { switch (event.type) { case SDL_KEYUP: