Changed: Ignore setMousePos if window does not have input focus.

feature/pre-code-move
Nimetu 5 years ago
parent 1337908369
commit 0bec2ee2ff

@ -234,6 +234,7 @@ CDriverGL::CDriverGL()
_win = EmptyWindow;
_WindowX = 0;
_WindowY = 0;
_WindowFocus = true;
_WindowVisible = true;
_DestroyWindow = false;
_Maximized = false;

@ -723,6 +723,7 @@ private:
bool _Maximized;
uint _Interval;
bool _Resizable;
bool _WindowFocus;
sint32 _DecorationWidth;
sint32 _DecorationHeight;

@ -509,7 +509,7 @@ void CDriverGL::setMousePos(float x, float y)
{
H_AUTO_OGL(CDriverGL_setMousePos)
if (_win == EmptyWindow)
if (_win == EmptyWindow || !_WindowFocus)
return;
sint x1 = (sint)((float)_CurrentMode.Width*x);
@ -612,6 +612,7 @@ bool CDriverGL::isSystemCursorInClientArea()
#ifdef NL_OS_WINDOWS
return IsWindowVisible(_win) != FALSE;
#endif
return _WindowFocus;
}
else
{
@ -650,7 +651,13 @@ bool CDriverGL::isSystemCursorInClientArea()
{
return false;
}
#elif defined(NL_OS_MAC)
// TODO: implement this
#elif defined (NL_OS_UNIX)
// TODO: implement this
#endif
// TODO: probably wrong if NeL window is docked inside parent (ie QT widget)
return _WindowFocus;
}
return true;

@ -106,6 +106,13 @@ bool GlWndProc(CDriverGL *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM
driver->_WndActive = true;
}
}
else if ((message == WM_SETFOCUS) || (message == WM_KILLFOCUS))
{
if (driver != NULL)
{
driver->_WindowFocus = (message == WM_SETFOCUS);
}
}
bool trapMessage = false;
if (driver->_EventEmitter.getNumEmitters() > 0)
@ -291,6 +298,18 @@ bool GlWndProc(CDriverGL *driver, XEvent &e)
break;
case FocusIn:
{
driver->_WindowFocus = true;
return driver->_EventEmitter.processMessage(e);
}
case FocusOut:
{
driver->_WindowFocus = false;
return driver->_EventEmitter.processMessage(e);
}
default:
// Process the message by the emitter

Loading…
Cancel
Save