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. If NULL, 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