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

Fix missed grab state changes in SDL demos #609

Merged
merged 3 commits into from
Mar 16, 2024

Conversation

paccerdk
Copy link
Contributor

Moved grab handling out of nk_sdl_handle_event to nk_sdl_handle_grab, which is now called outside of the event loop.

This change makes the logic similar to the GLFW demos and fixes issues with missed grab state changes and mouse cursor disappearing.

Discussed in #608

Move grab handling out of `nk_sdl_handle_event` to `nk_sdl_handle_grab`,
which is now called outside of the event loop.
This change makes the logic similar to the GLFW demos and fixes issues
with missed grab state changes and mouse cursor disappearing.
Reverted the order of the SDL_WarpMouseInWindow and SDL_GetMouseState
to its original sequence.
This avoids cursor warping to the center of screen on older SDL versions
It causes an additional SDL_MOUSEMOTION event when ungrabbing, but does
not cause any issues.
@paccerdk
Copy link
Contributor Author

Reverted the order of SDL_SetRelativeMouseMode and SDL_WarpMouseInWindow since it was causing the cursor to warp to center of screen on older SDL versions (tested with SDL 2.0.22)

@dumblob
Copy link
Member

dumblob commented Feb 17, 2024

I like the PR, thanks @paccerdk for spending the time with all the investigations across backends!

Reverted the order of SDL_SetRelativeMouseMode and SDL_WarpMouseInWindow since it was causing the cursor to warp to center of screen on older SDL versions (tested with SDL 2.0.22)

Could you please add a comment to the code about this finding? I find it important to have it documented. Thanks!

@RobLoach
Copy link
Contributor

I tested sdl_opengl3 and mouse drag is still looking good 👍

Explains call order of SDL_SetRelativeMouseMode and SDL_SetWindowGrab
@RobLoach RobLoach merged commit deb529f into Immediate-Mode-UI:master Mar 16, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants