SDL_GetWindowBordersSize(3)

πŸ’… SDL_GetWindowBordersSize(3) β€” SDL3 FUNCTIONS, bestie edition πŸŽ€

okay so this is a page from the SDL3 manual, and today we're talking about SDL_GetWindowBordersSize β€” the function that tells you how chunky your window's decorations are. πŸͺŸβœ¨


✨ NAME ✨

SDL_GetWindowBordersSize β€” get the size of a window's borders (decorations) around the client area.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_video.h>

bool SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);

πŸ¦‹ DESCRIPTION πŸ¦‹

So basically, you hand it a window and four pointers, and it fills in the sizes of the decorations around the client area. Easy. But listen, there's lore. πŸ‘‘

Note: if this function fails (returns false), the size values get initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the window in question was borderless. So like… zero vibes. No decorations. Nothing. πŸ™ˆ
Note: this function may fail on systems where the window has not yet been decorated by the display server β€” for example, immediately after calling SDL_CreateWindow. It is recommended that you wait at least until the window has been presented and composited, so that the window system has a chance to decorate the window and provide the border dimensions to SDL. fr fr, give the display server a sec to do its little outfit change. πŸ’…

This function also returns false if getting the information is not supported. not every system wants to spill the tea, and that's just how it is. 😭


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • window β€” the window to query the size values of the border (decorations) from. the main character of this whole operation, obviously.
  • top β€” pointer to variable for storing the size of the top border; NULL is permitted. yeah you can just. not care about the top. valid.
  • left β€” pointer to variable for storing the size of the left border; NULL is permitted.
  • bottom β€” pointer to variable for storing the size of the bottom border; NULL is permitted.
  • right β€” pointer to variable for storing the size of the right border; NULL is permitted.

like, all four of them are optional-optional. pass NULL for whichever ones you don't want and it won't even be mad at you. 🫢


⭐ RETURN VALUE ⭐

Returns true on success or false on failure β€” and if it's giving failure, call SDL_GetError() for more information. that's your group chat message telling you what actually went wrong. πŸ“±


πŸ’œ THREAD SAFETY πŸ’œ

This function should only be called on the main thread. only. the main thread. no side-quests, no background threads, no "but I thought it would be fine" β€” main thread only, periodt. 🚫🧡


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. so if you're on something older, it's simply not there and no amount of manifesting will summon it. πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

the sibling. the other one. go read it too, iykyk. πŸ”₯


and that's the whole page bestie!! this one came from Simple Directmedia Layer, version SDL 3.4.18 β€” and the date slot at the bottom is just vibing empty, so we're not even gonna pretend. mwah, go get those border sizes. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from