From 5a1e6c552a1d33b6aba7dc129679c941bfe1b5d0 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 17 Dec 2018 15:11:30 -0500 Subject: [PATCH] ignore lmouse and rmouse lua input when main window isnt focused. it seems unlikely anyone would want these for any other purpose (xmouse and ymouse are based on the emulated window so the clicks should be too) untested. intended for SF bug 836 --- src/lua-engine.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 409334e1..e09333e3 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -2421,6 +2421,11 @@ static int input_get(lua_State *L) { int mask = (i == VK_CAPITAL || i == VK_NUMLOCK || i == VK_SCROLL) ? 0x01 : 0x80; if(keys[i] & mask) { + //ignore mouse buttons if the main window isn't focused + if(i==1 || i==2) + if(GetForegroundWindow()!=hAppWnd) + continue; + const char* name = s_keyToName[i]; if(name) { @@ -2439,6 +2444,12 @@ static int input_get(lua_State *L) { if(name) { int active; + + //ignore mouse buttons if the main window isn't focused + if(i==1 || i==2) + if(GetForegroundWindow()!=hAppWnd) + continue; + if(i == VK_CAPITAL || i == VK_NUMLOCK || i == VK_SCROLL) active = GetKeyState(i) & 0x01; else