From 43e1de19aa4e9b70ebbf152ea33aae3f59bed396 Mon Sep 17 00:00:00 2001 From: Bruno Van de Velde Date: Sun, 30 Jun 2024 22:31:02 +0200 Subject: [PATCH] DefaultBackendWindow::pollEvent was incorrectly returning false when it encountered an event that TGUI didn't handle, this caused significant lagging in the Gui Builder when using SFML 3 and moving the mouse --- src/DefaultBackendWindow.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/DefaultBackendWindow.cpp b/src/DefaultBackendWindow.cpp index f5b4669c8..b34875fcb 100644 --- a/src/DefaultBackendWindow.cpp +++ b/src/DefaultBackendWindow.cpp @@ -151,16 +151,22 @@ namespace tgui bool pollEvent(Event& event) override { #if SFML_VERSION_MAJOR >= 3 - if (const auto eventSFML = m_window.pollEvent()) - return m_gui->convertEvent(*eventSFML, event); - else // No new events - return false; + while (const auto eventSFML = m_window.pollEvent()) + { + if (m_gui->convertEvent(*eventSFML, event)) + return true; + } + + return false; // No new events #else sf::Event eventSFML; - if (m_window.pollEvent(eventSFML)) - return m_gui->convertEvent(eventSFML, event); - else // No new events - return false; + while (m_window.pollEvent(eventSFML)) + { + if (m_gui->convertEvent(eventSFML, event)) + return true; + } + + return false; // No new events #endif } @@ -290,10 +296,13 @@ namespace tgui bool pollEvent(Event& event) override { SDL_Event eventSDL; - if (SDL_PollEvent(&eventSDL) != 0) - return m_gui->convertEvent(eventSDL, event); - else // No new events - return false; + while (SDL_PollEvent(&eventSDL) != 0) + { + if (m_gui->convertEvent(eventSDL, event)) + return true; + } + + return false; // No new events } void draw() override