From 9007986fb0f41581e8cc0dc6d1c653f544542f57 Mon Sep 17 00:00:00 2001 From: Oliver Behnke <oliver.behnke@aei.mpg.de> Date: Thu, 26 Nov 2020 18:50:19 +0100 Subject: [PATCH] Try and prevent premature fullscreen exits * Sometimes window events are received prematurely (probably caused by the initial window resizing) * Ignore window events until the window is actually visible --- src/framework/WindowManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/framework/WindowManager.cpp b/src/framework/WindowManager.cpp index 56db0aa..dba0d9f 100644 --- a/src/framework/WindowManager.cpp +++ b/src/framework/WindowManager.cpp @@ -276,10 +276,13 @@ void WindowManager::eventLoop() (event.type == SDL_MOUSEMOTION || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_KEYDOWN)) { - // we're in screensaver mode so exit on user input - SDL_GL_DeleteContext(m_GLContext); - SDL_DestroyWindow(m_Window); - SDL_Quit(); + // don't handle events prematurely + if((SDL_GetWindowFlags(m_Window) & SDL_WINDOW_SHOWN)) { + // we're in screensaver mode so exit on user input + SDL_GL_DeleteContext(m_GLContext); + SDL_DestroyWindow(m_Window); + SDL_Quit(); + } } else if (event.motion.state & (SDL_BUTTON(1) | SDL_BUTTON(3)) && event.type == SDL_MOUSEMOTION) { -- GitLab