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

streamline cursor clipping logic on windows #11237

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

expikr
Copy link
Contributor

@expikr expikr commented Oct 16, 2024

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 Cursor not constrained to window when using SDL_SetRelativeMouseMode and another game is running #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

relevant commits:

e56f05b (apr 2024)
6c96217 (mar 2024)
ab5351f (mar 2024)
50203d5 (dec 2020)
44f50c6 (jun 2020)
55b24b9 (sep 2018)

@expikr expikr changed the title Update SDL_windowsevents.c fix ClipCursor contention from background programs Oct 16, 2024
@expikr expikr changed the title fix ClipCursor contention from background programs fix ClipCursor contention from background programs by replacing polling based clipping with callback based approach, and remove SDL_HINT_MOUSE_RELATIVE_CLIP_INTERVAL Oct 19, 2024
@expikr expikr changed the title fix ClipCursor contention from background programs by replacing polling based clipping with callback based approach, and remove SDL_HINT_MOUSE_RELATIVE_CLIP_INTERVAL Fix ClipCursor contention from background programs by refreshing on event instead of on poll, and remove SDL_HINT_MOUSE_RELATIVE_CLIP_INTERVAL Oct 19, 2024
@expikr expikr requested review from slouken and sezero November 2, 2024 10:16
@sezero sezero removed their request for review November 2, 2024 12:02
@expikr expikr marked this pull request as draft November 20, 2024 10:21
@expikr expikr force-pushed the patch-2 branch 4 times, most recently from 2c8c77b to e494782 Compare November 20, 2024 14:43
@expikr expikr changed the title Fix ClipCursor contention from background programs by refreshing on event instead of on poll, and remove SDL_HINT_MOUSE_RELATIVE_CLIP_INTERVAL streamline cursor clipping logic on windows Nov 20, 2024
@expikr expikr marked this pull request as ready for review November 20, 2024 19:52
@expikr expikr force-pushed the patch-2 branch 10 times, most recently from 138fea6 to 7e2d048 Compare November 23, 2024 10:32
@expikr expikr force-pushed the patch-2 branch 2 times, most recently from c66107c to 0fbe530 Compare November 23, 2024 13:15
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.

Cursor not constrained to window when using SDL_SetRelativeMouseMode and another game is running
3 participants