Skip to content
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

Relative mouse mode drag does not report mouse button state. #11246

Open
mcourteaux opened this issue Oct 17, 2024 · 0 comments
Open

Relative mouse mode drag does not report mouse button state. #11246

mcourteaux opened this issue Oct 17, 2024 · 0 comments

Comments

@mcourteaux
Copy link

mcourteaux commented Oct 17, 2024

I have implemented a slider which supports relative mouse mode, to drag more precise than the pixels on the screen. The SDL_MouseMotionEvent::state field loses its mouse button flags when enabling relative mouse mode in Wayland and XWayland. I did not experience this issue before migrating from SDL2 to SDL3.

Eyeballing the code (without proper debugging so far), I'm a bit suspicious about these:

SDL/src/events/SDL_mouse.c

Lines 741 to 744 in 4612db2

if ((!mouse->relative_mode || mouse->warp_emulation_active) && mouseID != SDL_TOUCH_MOUSEID) {
// We're not in relative mode, so all mouse events are global mouse events
mouseID = SDL_GLOBAL_MOUSE_ID;
}

SDL/src/events/SDL_mouse.c

Lines 932 to 937 in 4612db2

if (!mouse->relative_mode && mouseID != SDL_TOUCH_MOUSEID) {
// We're not in relative mode, so all mouse events are global mouse events
mouseID = SDL_GLOBAL_MOUSE_ID;
}
source = GetMouseInputSource(mouse, mouseID, down, button);

This suggests that if we enter relative mouse mode, there is a different SDL_MouseID used. I fear that that might cause it to keep track of the button state in a different SDL_MouseInputSource, which gets obtained here:

event.motion.state = SDL_GetMouseButtonState(mouse, mouseID, true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant