diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index c5d7b1d05..90b17958f 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -234,6 +234,7 @@ CDriverGL::CDriverGL() _win = EmptyWindow; _WindowX = 0; _WindowY = 0; + _WindowFocus = true; _WindowVisible = true; _DestroyWindow = false; _Maximized = false; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index e9aa2e905..9bd19b14d 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -723,6 +723,7 @@ private: bool _Maximized; uint _Interval; bool _Resizable; + bool _WindowFocus; sint32 _DecorationWidth; sint32 _DecorationHeight; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp index 0d27166fc..3ede88b41 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp @@ -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; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 2ab5a3aba..293cb28bb 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -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