Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
8.86k stars 535 forks source link

Fix missed grab state changes in SDL demos #609

Closed paccerdk closed 3 months ago

paccerdk commented 5 months ago

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 https://github.com/Immediate-Mode-UI/Nuklear/issues/608

paccerdk commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

I tested sdl_opengl3 and mouse drag is still looking good :+1: