From b100262a155138d194f5b35b58e89951238e38cc Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 14 Oct 2017 11:42:03 -0400 Subject: [PATCH] process multiple queued events up to a maximum time before redrawing screen --- src/gui/Window.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/Window.cc b/src/gui/Window.cc index 9f59172..003a664 100644 --- a/src/gui/Window.cc +++ b/src/gui/Window.cc @@ -11,6 +11,10 @@ #define INITIAL_HEIGHT 800 #define FONT_SIZE 16 +/* Process multiple queued events for up to this long before stopping to + * redraw the screen. */ +#define MAX_EVENT_PROCESS_TIME 50000 + /** * Initialize OpenGL. * @@ -145,7 +149,13 @@ void Window::run_event_loop() redraw(); } Jtk_WaitEvent(&event); + uint64_t event_time = Jtk_UsTime(); handle_event(event); + while (Jtk_CheckEvent(&event) && + ((Jtk_UsTime() - event_time) < MAX_EVENT_PROCESS_TIME)) + { + handle_event(event); + } } }