Skip to content

Commit

Permalink
[d3d9] Update software cursor position using SetCursorPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Feb 4, 2025
1 parent bd69d1e commit bb789b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
21 changes: 7 additions & 14 deletions src/d3d9/d3d9_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ namespace dxvk {


void D3D9Cursor::UpdateCursor(int X, int Y) {
// SetCursorPosition is used to directly update the position of software cursors.
if (unlikely(m_sCursor.Width > 0 && m_sCursor.Height > 0)) {
m_sCursor.X = X - m_sCursor.XHotSpot;
m_sCursor.Y = Y - m_sCursor.YHotSpot;
return;
}

POINT currentPos = { };
if (::GetCursorPos(&currentPos) && currentPos == POINT{ X, Y })
return;
Expand All @@ -37,15 +44,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()))
Expand Down Expand Up @@ -127,11 +125,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);
Expand Down
2 changes: 0 additions & 2 deletions src/d3d9/d3d9_cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4052,8 +4052,6 @@ 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;
Expand Down

0 comments on commit bb789b3

Please sign in to comment.