Skip to content

Commit

Permalink
DefaultBackendWindow::pollEvent was incorrectly returning false when …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
texus committed Jun 30, 2024
1 parent 1a607dc commit 43e1de1
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/DefaultBackendWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 43e1de1

Please sign in to comment.