From dccbb376a0f41d2b77aeb0f4be93468fe5fdc7a1 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 6 Mar 2020 10:29:49 +0200 Subject: [PATCH] Changed: Windows focus events in Direct3d --- code/nel/src/3d/driver/direct3d/driver_direct3d.cpp | 10 ++++++++++ code/nel/src/3d/driver/direct3d/driver_direct3d.h | 1 + .../src/3d/driver/direct3d/driver_direct3d_inputs.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 691be14df..1ab29c3a0 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -197,6 +197,7 @@ CDriverD3D::CDriverD3D() _BackBuffer = NULL; _Maximized = false; _HandlePossibleSizeChangeNextSize = false; + _WindowFocus = true; _Interval = 1; _AGPMemoryAllocated = 0; _VRAMMemoryAllocated = 0; @@ -1164,6 +1165,14 @@ void D3DWndProc(CDriverD3D *driver, HWND hWnd, UINT message, WPARAM wParam, LPAR } } + if ((message == WM_SETFOCUS) || (message == WM_KILLFOCUS)) + { + if (driver != NULL) + { + driver->_WindowFocus = (message == WM_SETFOCUS); + } + } + if (driver->_EventEmitter.getNumEmitters() > 0) { CWinEventEmitter *we = NLMISC::safe_cast(driver->_EventEmitter.getEmitter(0)); @@ -1370,6 +1379,7 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r // Reset window state _Maximized = false; _HandlePossibleSizeChangeNextSize = false; + _WindowFocus = true; if (_HWnd) { diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index 8f8048368..636695670 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -2324,6 +2324,7 @@ private: sint32 _WindowY; bool _DestroyWindow; bool _Maximized; + bool _WindowFocus; bool _HandlePossibleSizeChangeNextSize; GfxMode _CurrentMode; uint _Interval; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp index d26741faf..d5b4ef482 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp @@ -374,7 +374,7 @@ void CDriverD3D::setMousePos(float x, float y) { H_AUTO_D3D(CDriverD3D_setMousePos); - if (_HWnd == EmptyWindow) + if (_HWnd == EmptyWindow || !_WindowFocus) return; // convert position size from float to pixels