streamline cursor clipping logic on windows (#11237)

This commit does the following:
- add logic in the `WM_MOUSEMOVE` case of the Window to conditionally call `WIN_UpdateClipCursor` upon receiving cursor motion if SDL is expecting the mouse to be clipped in some way (Fixes #7890)
- remove Windows-specific periodic refresh of cursor clipping and its `SDL_HINT_MOUSE_RELATIVE_CLIP_INTERVAL` hint (superceded by the above bullet point)
- streamline the processing logic within `WIN_UpdateClipCursor` for better readability of each branch, and avoid calling the Platform API until it is absolutely necessary.
- move `relative_mouse_center` field from Windows-specific per-window `SDL_WindowData` to the global `SDL_Mouse` struct, and the corresponding hint callbacks to `SDL_mouse.c` instead of `SDL_windowswindow.c`
This commit is contained in:
expikr
2024-12-19 09:25:06 +08:00
committed by GitHub
parent 35a9d156a6
commit 345cab1e36
6 changed files with 144 additions and 166 deletions

View File

@@ -2614,23 +2614,6 @@ extern "C" {
*/
#define SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE "SDL_MOUSE_RELATIVE_CURSOR_VISIBLE"
/**
* Controls how often SDL issues cursor confinement commands to the operating
* system while relative mode is active, in case the desired confinement state
* became out-of-sync due to interference from other running programs.
*
* The variable can be integers representing milliseconds between each
* refresh. A value of zero means SDL will not automatically refresh the
* confinement. The default value varies depending on the operating system,
* this variable might not have any effects on inapplicable platforms such as
* those without a cursor.
*
* This hint can be set anytime.
*
* \since This hint is available since SDL 3.1.3.
*/
#define SDL_HINT_MOUSE_RELATIVE_CLIP_INTERVAL "SDL_MOUSE_RELATIVE_CLIP_INTERVAL"
/**
* A variable controlling whether mouse events should generate synthetic touch
* events.