summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-24 12:09:54 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:17 +0300
commit9b727d191c9cea2324a8505296b08d0719a49207 (patch)
tree819b7af1ab2c71ed2c9ccda725f51ead590fdbd7
parentfe8eaac0bddd1d6416bf16abdb9206290fcced2f (diff)
downloadmv-9b727d191c9cea2324a8505296b08d0719a49207.tar.gz
mv-9b727d191c9cea2324a8505296b08d0719a49207.tar.bz2
mv-9b727d191c9cea2324a8505296b08d0719a49207.tar.xz
mv-9b727d191c9cea2324a8505296b08d0719a49207.zip
fix delays is window minimized in SDL2.
-rw-r--r--src/client.cpp19
1 files changed, 9 insertions, 10 deletions
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;
}