Skip to content

Instantly share code, notes, and snippets.

@lcd047
Created May 12, 2017 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcd047/6f9655b95025934b7719086edea50d53 to your computer and use it in GitHub Desktop.
Save lcd047/6f9655b95025934b7719086edea50d53 to your computer and use it in GitHub Desktop.
diff -urp openttd-1.7.0.old/src/video/sdl_v.cpp openttd-1.7.0/src/video/sdl_v.cpp
--- openttd-1.7.0.old/src/video/sdl_v.cpp 2017-05-12 19:57:29.568021877 +0300
+++ openttd-1.7.0/src/video/sdl_v.cpp 2017-05-12 19:53:51.471029678 +0300
@@ -13,6 +13,7 @@
#include "../stdafx.h"
#include "../openttd.h"
+#include "../command_func.h"
#include "../gfx_func.h"
#include "../sdl.h"
#include "../rev.h"
@@ -584,6 +585,14 @@ int VideoDriver_SDL::PollEvent()
break;
case SDL_ACTIVEEVENT:
+ if (!_networking && _game_mode == GM_NORMAL &&
+ (_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED &&
+ (ev.active.state & SDL_APPACTIVE) && !ev.active.gain) {
+ DEBUG(driver, 1, "SDL: minimised window, pausing");
+ DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
+ break;
+ }
+
if (!(ev.active.state & SDL_APPMOUSEFOCUS)) break;
if (ev.active.gain) { // mouse entered the window, enable cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment