SDL_SetWindowMouseRect doesn't always work on wayland
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);
Are you testing against the main branch, or a release version?
Are you testing against the main branch, or a release version?
main branch
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.
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.