diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index de09bd48c..e116e541d 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -1164,6 +1164,10 @@ namespace opengl glDisableClientState(GL_VERTEX_ARRAY); } + bool Graphics::hasFocus() + { + return SDL_GetAppState() & SDL_APPINPUTFOCUS; + } } // opengl } // graphics } // love diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index 1fc653abc..5e3bbd103 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -528,6 +528,8 @@ namespace opengl void drawTest(Image * image, float x, float y, float a, float sx, float sy, float ox, float oy); + bool hasFocus(); + }; // Graphics } // opengl diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index ee50d046a..2d4986bd3 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -922,6 +922,12 @@ namespace opengl return 0; } + int w_hasFocus(lua_State * L) + { + luax_pushboolean(L, instance->hasFocus()); + return 1; + } + // List of functions to wrap. static const luaL_Reg functions[] = { @@ -1007,6 +1013,8 @@ namespace opengl { "translate", w_translate }, + { "hasFocus", w_hasFocus }, + { 0, 0 } }; diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index 776978351..d29d49b8b 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/src/modules/graphics/opengl/wrap_Graphics.h @@ -101,6 +101,7 @@ namespace opengl int w_rotate(lua_State * L); int w_scale(lua_State * L); int w_translate(lua_State * L); + int w_hasFocus(lua_State * L); extern "C" LOVE_EXPORT int luaopen_love_graphics(lua_State * L); } // opengl