SDL_GetDisplayUsableBounds(3)

πŸ’– SDL_GetDisplayUsableBounds(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we talk about usable desktop space, not just the whole screen. this one's a certified bop, let's go ✨


🌸 NAME 🌸

SDL_GetDisplayUsableBounds β€” get the usable desktop area represented by a display, in screen coordinates. yes, the usable one, not the "the whole thing including the bits your OS stole" one 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_video.h>

bool SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);

✨ DESCRIPTION ✨

so this is literally the same area that SDL_GetDisplayBounds() reports, except we've yeeted out all the portions that the system reserved for itself. subtracted, gone, not yours πŸ’…

for example β€” and this is the iconic one β€” on Apple's macOS, this subtracts the area occupied by the menu bar and the dock. so like, the space that's technically on your screen but is 100% claimed by the OS and will never ever be yours.

and here's the tea: setting a window to be fullscreen generally bypasses these unusable areas, so these numbers are good guidelines for the maximum space available to a non-fullscreen window. iykyk 🌈

lowkey important: these are guidelines for non-fullscreen windows. fullscreen does its own thing and doesn't care about your menu bar.

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • displayID β€” the instance ID of the display you want to query. which one? that one. πŸ‘‘
  • rect β€” the SDL_Rect structure that gets filled in with the display bounds. you hand it the empty container, it hands you back the numbers. slay.

⭐ RETURN VALUE ⭐

returns true on success or false on failure. if it fails, call SDL_GetError() for more information β€” she will tell you what went wrong, fr fr 😭


🧚 THREAD SAFETY 🧚

this function should only be called on the main thread. no side quests, no background threads, main thread only bestie πŸ’€

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. vintage? no. iconic? yes. ✨


πŸ’œ SEE ALSO πŸ’œ


and that's the whole vibe check, bestie πŸ₯° go forth and respect the menu bar's territory.

Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_GetDisplayUsableBounds(3) β€” mwah, take care of your usable bounds πŸ’…πŸ«Ά

πŸ“¦ where this page comes from