diff --git a/src/d3d9/d3d9_cursor.cpp b/src/d3d9/d3d9_cursor.cpp index cff32e58d..9535e46c7 100644 --- a/src/d3d9/d3d9_cursor.cpp +++ b/src/d3d9/d3d9_cursor.cpp @@ -29,6 +29,15 @@ namespace dxvk { void D3D9Cursor::UpdateCursor(int X, int Y) { + // SetCursorPosition is used to directly update the position of software cursors, + // but keep track of the cursor position even when using hardware cursors, in order + // to ensure a smooth transition/overlap from one type to the other. + m_sCursor.X = X; + m_sCursor.Y = Y; + + if (unlikely(m_sCursor.Width > 0 && m_sCursor.Height > 0)) + return; + POINT currentPos = { }; if (::GetCursorPos(¤tPos) && currentPos == POINT{ X, Y }) return; @@ -37,15 +46,6 @@ namespace dxvk { } - void D3D9Cursor::RefreshSoftwareCursorPosition() { - POINT currentPos = { }; - ::GetCursorPos(¤tPos); - - m_sCursor.X = static_cast(currentPos.x) - m_sCursor.XHotSpot; - m_sCursor.Y = static_cast(currentPos.y) - m_sCursor.YHotSpot; - } - - BOOL D3D9Cursor::ShowCursor(BOOL bShow) { // Cursor visibility remains unchanged (typically FALSE) if the cursor isn't set. if (unlikely(m_hCursor == nullptr && !IsSoftwareCursor())) @@ -127,11 +127,6 @@ namespace dxvk { } - void D3D9Cursor::RefreshSoftwareCursorPosition() { - Logger::warn("D3D9Cursor::RefreshSoftwareCursorPosition: Not supported on current platform."); - } - - BOOL D3D9Cursor::ShowCursor(BOOL bShow) { Logger::warn("D3D9Cursor::ShowCursor: Not supported on current platform."); return std::exchange(m_visible, bShow); diff --git a/src/d3d9/d3d9_cursor.h b/src/d3d9/d3d9_cursor.h index c45338d43..4da6354dd 100644 --- a/src/d3d9/d3d9_cursor.h +++ b/src/d3d9/d3d9_cursor.h @@ -47,8 +47,6 @@ namespace dxvk { void UpdateCursor(int X, int Y); - void RefreshSoftwareCursorPosition(); - BOOL ShowCursor(BOOL bShow); HRESULT SetHardwareCursor(UINT XHotSpot, UINT YHotSpot, const CursorBitmap& bitmap); diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 340f6f39c..bea0e9201 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4052,14 +4052,13 @@ namespace dxvk { DWORD dwFlags) { if (m_cursor.IsSoftwareCursor()) { - m_cursor.RefreshSoftwareCursorPosition(); - D3D9_SOFTWARE_CURSOR* pSoftwareCursor = m_cursor.GetSoftwareCursor(); UINT cursorWidth = pSoftwareCursor->DrawCursor ? pSoftwareCursor->Width : 0; UINT cursorHeight = pSoftwareCursor->DrawCursor ? pSoftwareCursor->Height : 0; - m_implicitSwapchain->SetCursorPosition(pSoftwareCursor->X, pSoftwareCursor->Y, + m_implicitSwapchain->SetCursorPosition(pSoftwareCursor->X - pSoftwareCursor->XHotSpot, + pSoftwareCursor->Y - pSoftwareCursor->YHotSpot, cursorWidth, cursorHeight); // Once a hardware cursor has been set or the device has been reset, @@ -4070,8 +4069,6 @@ namespace dxvk { pSoftwareCursor->Height = 0; pSoftwareCursor->XHotSpot = 0; pSoftwareCursor->YHotSpot = 0; - pSoftwareCursor->X = 0; - pSoftwareCursor->Y = 0; pSoftwareCursor->ResetCursor = false; } }