Prevent input.setMouseGrab from interfering with window focus

This commit is contained in:
LJ Sonic 2021-08-18 20:58:13 +02:00
parent 5340db5f67
commit 9b7263855e
4 changed files with 15 additions and 3 deletions

View file

@ -43,6 +43,7 @@
#include "lzf.h"
#include "lua_script.h"
#include "lua_hook.h"
#include "lua_libs.h"
#include "md5.h"
#include "m_perfstats.h"
@ -3331,6 +3332,9 @@ static inline void SV_GenContext(void)
//
void D_QuitNetGame(void)
{
mousegrabbedbylua = true;
I_UpdateMouseGrab();
if (!netgame || !netbuffer)
return;

View file

@ -19,6 +19,8 @@
#include "lua_script.h"
#include "lua_libs.h"
boolean mousegrabbedbylua = true;
///////////////
// FUNCTIONS //
///////////////
@ -106,14 +108,14 @@ static int lib_shiftKeyNum(lua_State *L)
static int lib_getMouseGrab(lua_State *L)
{
lua_pushboolean(L, I_GetMouseGrab());
lua_pushboolean(L, mousegrabbedbylua);
return 1;
}
static int lib_setMouseGrab(lua_State *L)
{
boolean grab = luaL_checkboolean(L, 1);
I_SetMouseGrab(grab);
mousegrabbedbylua = luaL_checkboolean(L, 1);
I_UpdateMouseGrab();
return 0;
}

View file

@ -12,6 +12,8 @@
extern lua_State *gL;
extern boolean mousegrabbedbylua;
#define MUTABLE_TAGS
#define LREG_VALID "VALID_USERDATA"

View file

@ -73,6 +73,8 @@
#include "../console.h"
#include "../command.h"
#include "../r_main.h"
#include "../lua_script.h"
#include "../lua_libs.h"
#include "../lua_hook.h"
#include "sdlmain.h"
#ifdef HWRENDER
@ -372,6 +374,8 @@ static boolean IgnoreMouse(void)
if (gamestate != GS_LEVEL && gamestate != GS_INTERMISSION &&
gamestate != GS_CONTINUING && gamestate != GS_CUTSCENE)
return true;
if (!mousegrabbedbylua)
return true;
return false;
}