From aa2f88e5f624164c5203d88adcafa7b7e23e401b Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Thu, 8 Dec 2022 08:25:39 +0000 Subject: [PATCH] Remove software cursor state for hardware cursor Switching between software and hardware cursor could cause a glitch as described in #5560. Fixes #5560 --- Source/engine/render/scrollrt.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 0a472c6b4..c8888784e 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -232,14 +232,20 @@ bool ShouldShowCursor() void DrawCursor(const Surface &out) { DrawnCursor &cursor = GetDrawnCursor(); + if (IsHardwareCursor()) { + SetHardwareCursorVisible(ShouldShowCursor()); + cursor.rect.size = { 0, 0 }; + return; + } + if (pcurs <= CURSOR_NONE || !ShouldShowCursor()) { - cursor.rect.size.width = 0; + cursor.rect.size = { 0, 0 }; return; } Size cursSize = GetInvItemSize(pcurs); if (cursSize.width == 0 || cursSize.height == 0) { - cursor.rect.size.width = 0; + cursor.rect.size = { 0, 0 }; return; } @@ -1598,14 +1604,8 @@ void scrollrt_draw_game_screen() const Surface &out = GlobalBackBuffer(); UndrawCursor(out); - DrawMain(out, hgt, false, false, false, false, false); - - if (IsHardwareCursor()) { - SetHardwareCursorVisible(ShouldShowCursor()); - } else { - DrawCursor(out); - } + DrawCursor(out); RenderPresent(); } @@ -1673,11 +1673,7 @@ void DrawAndBlit() if (*sgOptions.Graphics.showManaValues) DrawFlaskValues(out, { mainPanel.position.x + mainPanel.size.width - 138, mainPanel.position.y + 28 }, MyPlayer->_pMana >> 6, MyPlayer->_pMaxMana >> 6); - if (IsHardwareCursor()) { - SetHardwareCursorVisible(ShouldShowCursor()); - } else { - DrawCursor(out); - } + DrawCursor(out); DrawFPS(out);