-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
X11 mouse position has subtle issues #11646
Comments
For clarification, are you seeing this behavior on a real X11 session, when running via XWayland, or both? |
I've tested this in GNOME on Arch Linux, in both Wayland and X11. It happens on both a real X11 session and Xwayland, but doesn't happen running natively on Wayland. @12Me21 and @y-ack were both able to reproduce this on their computers. @y-ack has also confirmed this doesn't happen on Windows. I'd like to provide more videos, but while recording I discovered a bug in OBS preventing me from accurately recording the mouse position, so now I'm investigating that too. In the meantime, adding this code to SDL_SetRenderDrawColor(renderer, 0, 255, 0, 128);
SDL_RenderLine(renderer, SDL_floorf(mouse_x), 0, SDL_floorf(mouse_x), 240);
SDL_RenderLine(renderer, 0, SDL_floorf(mouse_y), 320, SDL_floorf(mouse_y)); |
This seems like a mismatch between the coordinates provided by XInput and XQueryPointer. XInput does provide the root coordinates in motion events, so that should be used if a window has focus to avoid possible relative/global mismatches. Can you test this branch and see if it fixes your issue: https://github.com/Kontrabant/SDL/tree/x11_coordinate_mismatch |
Before this branch, With this branch, So, this doesn't fix the issue. However, this suggests to me that the problem lies with the Xinput code specifically, and indeed, when I build without Xinput support, the bug does not occur. |
SDL/src/video/x11/SDL_x11xinput2.c Lines 451 to 454 in 5608bf5
Commenting out these lines fixes the bug, though I don't know why. |
Here's a YouTube video showcasing the below code.
driver
is the current video driver,mouse
is the position from the latest mouse motion event, andgmouse
is the position fromSDL_GetGlobalMouseState
.It's hard to pin down exactly what's wrong, but you can see instances where
mouse
seems to lag behindgmouse
, instances where the mouse cursor visibly moves a pixel but this isn't reflected in SDL, and so on.As best as I can tell,
SDL_VIDEO_DRIVER=wayland
doesn't have these issues.The text was updated successfully, but these errors were encountered: