1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-23 10:54:14 +01:00

[d3d9] Update software cursor position using SetCursorPosition

This commit is contained in:
WinterSnowfall 2025-02-04 23:34:13 +02:00 committed by Philip Rebohle
parent 54a26dde3d
commit 13554f18bd
3 changed files with 11 additions and 21 deletions

View File

@ -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(&currentPos) && currentPos == POINT{ X, Y })
return;
@ -37,15 +46,6 @@ namespace dxvk {
}
void D3D9Cursor::RefreshSoftwareCursorPosition() {
POINT currentPos = { };
::GetCursorPos(&currentPos);
m_sCursor.X = static_cast<int32_t>(currentPos.x) - m_sCursor.XHotSpot;
m_sCursor.Y = static_cast<int32_t>(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);

View File

@ -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);

View File

@ -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;
}
}