SDL_SetWindowMouseRect(3)
π SDL_SetWindowMouseRect(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual β this one's SDL_SetWindowMouseRect, and it's literally the function that tells your cursor where it's allowed to vibe. π¦
β¨ NAME β¨
SDL_SetWindowMouseRect β Confines the cursor to the specified area of a window.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_video.h>
bool SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect);
π DESCRIPTION π
okay so here's the tea, and it's important: this does NOT grab the cursor. It only defines the area a cursor is restricted to when the window has mouse focus. That's it. That's the whole job. No grabbing, no capturing, just drawing a lil invisible fence and saying "stay in here pls." π
π«Ά FUNCTION PARAMETERS π«Ά
windowβ the window that will be associated with the barrier. it's the one getting the fence, basically. πrectβ a rectangle area in window-relative coordinates. IfNULL, the barrier for the specified window will be destroyed. gone. poof. π
β RETURN VALUE β
Returns true on success or false on failure β and if it fails, bestie, call SDL_GetError() for more information. it will tell you what went wrong, no cap. π
π§ THREAD SAFETY π§
This function should only be called on the main thread. do not try to be cute and call it from a worker thread. it's giving main character energy only. π
π AVAILABILITY π
This function is available since SDL 3.2.0. so if you're on something older... it's not there. sorry bestie. π
π SEE ALSO π
and that's the whole page, bestie!! π this lil writeup came to you straight from the Simple Directmedia Layer crew β specifically the SDL 3.4.18 era of SDL_SetWindowMouseRect(3). go forth and confine those cursors responsibly. mwah. π
β¨
π¦ 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