Skip to content

WIN_ShowCursor function is now capable of processing NULL as a SDL_Cursor* (repost) #13713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions include/SDL3/SDL_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -4420,11 +4420,29 @@ extern "C" {
*/
#define SDL_HINT_DEBUG_LOGGING "SDL_DEBUG_LOGGING"

/**
* On Windows, this hint forces SDL to call SetCursor(NULL) to hide the mouse cursor,
* instead of using an invisible blank cursor.
*
* This may be required in certain environments (e.g., VMware or specific RDP configurations),
* where SetCursorPos() does not function correctly if the cursor is not truly hidden using SetCursor(NULL).
*
* By default, SDL uses a transparent cursor surface to simulate a hidden cursor,
* which avoids issues in some scenarios (e.g., multi-window focus handling).
* However, this method may not work properly in all virtualized environments.
*
* Set this hint to "1" to restore the previous behavior and force SetCursor(NULL) to be used.
*
* This hint is only applicable on Windows.
*/
#define SDL_HINT_WINDOWS_FORCE_NULL_CURSOR "SDL_WINDOWS_FORCE_NULL_CURSOR"

/**
* An enumeration of hint priorities.
*
* \since This enum is available since SDL 3.2.0.
*/

typedef enum SDL_HintPriority
{
SDL_HINT_DEFAULT,
Expand Down
14 changes: 11 additions & 3 deletions src/video/windows/SDL_windowsmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,20 +434,28 @@ static HCURSOR GetCachedCursor(SDL_Cursor *cursor)
static bool WIN_ShowCursor(SDL_Cursor *cursor)
{
if (!cursor) {
cursor = SDL_blank_cursor;
if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_NULL_CURSOR, true)) {
SDL_cursor = NULL;
SetCursor(NULL);

return false;
} else {
cursor = SDL_blank_cursor;
}
}

if (cursor) {
if (cursor->internal->surface) {
SDL_cursor = GetCachedCursor(cursor);
} else {
SDL_cursor = cursor->internal->cursor;
}
} else {
SDL_cursor = NULL;
}

if (SDL_GetMouseFocus() != NULL) {
SetCursor(SDL_cursor);
}

return true;
}

Expand Down
Loading