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; _win = EmptyWindow;
_WindowX = 0; _WindowX = 0;
_WindowY = 0; _WindowY = 0;
_WindowFocus = true;
_WindowVisible = true; _WindowVisible = true;
_DestroyWindow = false; _DestroyWindow = false;
_Maximized = false; _Maximized = false;

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

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

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

Loading…
Cancel
Save