From cdea7e238c4a8f15e89fc85f93315bb3b099d512 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 14 Oct 2020 13:18:18 +0200 Subject: [PATCH] Platform/Unix/X11EventQueue: Fix bug where messeges where not flushed to the event queue. XEventsQueued(disp, QueuedAlready) only returns the number of events currently in the queue and does not flush new events. So this must happen elsewhere and if it does not we will never see any events. i noticed this bug when removing the call to glXSwapBuffers(). Fix this by using XPending() instead as this flushes new events if the queue is empty before returning the length. see https://tronche.com/gui/x/xlib/event-handling/XEventsQueued.html and https://tronche.com/gui/x/xlib/event-handling/XPending.html --- source/Platform/Unix/X11EventQueue.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Platform/Unix/X11EventQueue.cpp b/source/Platform/Unix/X11EventQueue.cpp index 06438e4..19f4177 100644 --- a/source/Platform/Unix/X11EventQueue.cpp +++ b/source/Platform/Unix/X11EventQueue.cpp @@ -28,7 +28,7 @@ bool X11EventQueue::poll(Event& event) return false; } - if (XEventsQueued(m_disp, QueuedAlready)) { + if (XPending(m_disp)) { XEvent xevent; XNextEvent(m_disp, &xevent); @@ -63,6 +63,7 @@ bool X11EventQueue::poll(Event& event) break; default: // Pass to window. + Log::info("X11: Window Event"); X11WindowEventHandler::process(m_disp, xevent); } }