From e9cccf0e6fa02b567dd06be04c94e26a1819b166 Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Mon, 20 Dec 2010 22:08:28 +0000 Subject: [PATCH] Fixed Window::WaitEvent sometimes returning (false) when no event occurred git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1760 4e206d99-4929-0410-ac5d-dfc041789085 --- src/SFML/Window/WindowImpl.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index 915232e2..6f448c5f 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -115,8 +115,22 @@ bool WindowImpl::PopEvent(Event& event, bool block) // If the event queue is empty, let's first check if new events are available from the OS if (myEvents.empty()) { + // Special handling of joystick events (we must use polling) ProcessJoystickEvents(); - ProcessEvents(block); + + if (block) + { + // If we are blocking, loop until we actually received a SFML event + // (there may be OS events that make ProcessEvents(true) return, but + // which don't translate to SFML events) + while (myEvents.empty()) + ProcessEvents(true); + } + else + { + // If we are not blocking, just process the pending events + ProcessEvents(false); + } } // Pop the first event of the queue, if it is not empty