From 9b727d191c9cea2324a8505296b08d0719a49207 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 Aug 2013 12:09:54 +0300 Subject: fix delays is window minimized in SDL2. --- src/client.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 8a197d5aa..9c3397f72 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1051,15 +1051,8 @@ int Client::gameExec() // This is done because at some point tick_time will wrap. lastTickTime = tick_time; -#ifdef USE_SDL2 - // +++ need check active state - frame_count++; - if (gui) - gui->draw(); - mainGraphics->updateScreen(); -#else - // Update the screen when application is active, delay otherwise. - if (SDL_GetAppState() & SDL_APPACTIVE) + // Update the screen when application is visible, delay otherwise. + if (!mIsMinimized) { frame_count++; if (gui) @@ -1070,7 +1063,6 @@ int Client::gameExec() { SDL_Delay(100); } -#endif BLOCK_START("~Client::SDL_framerateDelay") if (mLimitFps) @@ -3132,6 +3124,13 @@ void Client::handleSDL2WindowEvent(const SDL_Event &event) case SDL_WINDOWEVENT_FOCUS_LOST: setInputFocused(false); break; + case SDL_WINDOWEVENT_MINIMIZED: + setIsMinimized(true); + break; + case SDL_WINDOWEVENT_RESTORED: + case SDL_WINDOWEVENT_MAXIMIZED: + setIsMinimized(false); + break; default: break; } -- cgit v1.2.3-60-g2f50