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:
parent
54a26dde3d
commit
13554f18bd
@ -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<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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user