SDL_SetWindowMouseGrab(3)
π SDL_SetWindowMouseGrab(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_SetWindowMouseGrab β the little function that decides whether your mouse cursor is allowed to escape your window or not. it's giving gatekeeper energy, but for cursors. π¦
β¨ NAME β¨
SDL_SetWindowMouseGrab β set a window's mouse grab mode. that's it, that's the whole job. iconic. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_video.h>
bool SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed);
yes bestie, you get a bool back. we love a return value that tells us how it went. π«Ά
π DESCRIPTION π
so here's the tea: mouse grab confines the mouse cursor to the window. that's literally the entire vibe. cursor stays inside, no sneaking off to another monitor or another app. it's in its lane, fr fr. πβ‘οΈπ«
π FUNCTION PARAMETERS π
windowβ the window for which the mouse grab mode should be set. the main character, basically. πgrabbedβ this istrueto grab mouse, andfalseto release. two moods, one bool. pick your fighter. β¨
π RETURN VALUE π
returns true on success or false on failure β and if it fails, call SDL_GetError() for more information. do not just sit there wondering what went wrong, bestie, the error message is right there. go get it. π
π₯ THREAD SAFETY π₯
This function should only be called on the main thread. no side quests, no background threads, no sneaky little worker thread trying to be cute. main thread only. periodt. π
β AVAILABILITY β
this function is available since SDL 3.2.0. if you're on anything older, sorry bestie, it's not there. π₯Ί
π¦ SEE ALSO π¦
go read those too, they're all in the same friend group. iykyk. π
and that's the whole page, bestie!! mwah. this one came from Simple Directmedia Layer, running SDL 3.4.18, and it's the SDL_SetWindowMouseGrab(3) page β go grab (or release) those cursors responsibly. no cap. πβ¨π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms