SDL icon indicating copy to clipboard operation
SDL copied to clipboard

SDL_SetWindowMouseRect doesn't always work on wayland

Open GameParrot opened this issue 7 months ago • 3 comments

SDL_SetWindowMouseRect sometimes does not work correctly on wayland (kde). It randomly does not restrict the mouse cursor, even when in relative mode (and returns success). It seems to happen more often when it is enabled and disabled very fast. My code:

float x, y;
SDL_GetMouseState(&x, &y);
SDL_Rect r = {.x = (int)x, .y = (int)y, .w = 1, .h = 1};
SDL_SetWindowMouseRect(window, &r);
SDL_SetWindowRelativeMouseMode(window, true);

GameParrot avatar May 19 '25 00:05 GameParrot

Are you testing against the main branch, or a release version?

Kontrabant avatar May 19 '25 01:05 Kontrabant

Are you testing against the main branch, or a release version?

main branch

GameParrot avatar May 19 '25 02:05 GameParrot

The issue seems to be that the cursor rect is ignored if a mouse button is down when it is requested. A workaround is to delay setting relative mode and cursor rect until no mouse buttons are down.

GameParrot avatar May 19 '25 03:05 GameParrot

This should be fixed in the 3.4 branch, as pointer locking/confining was considerably improved in the Wayland backend as part of the big input refactoring.

Kontrabant avatar Sep 14 '25 21:09 Kontrabant