SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE(3)

πŸ’… SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE πŸ’…

okay bestie, so this is a page from the SDL3 functions manual, and it's about one specific little hint β€” a variable that decides whether SDL throws an SDL_EVENT_QUIT at you when you close your very last window. yeah. that one. sit down, hydrate, let's go 🫢


✨ NAME ✨

SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE β€” a variable that decides whether to send SDL_EVENT_QUIT when closing the last window.

like, literally that's its whole job. it's the "should closing my final window mean I'm done done?" switch. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_hints.h>

#define SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE "SDL_QUIT_ON_LAST_WINDOW_CLOSE"

so you include the hints header, and the hint's actual string name is "SDL_QUIT_ON_LAST_WINDOW_CLOSE". that's the string you'd pass around when you're setting hints, iykyk. ✨


πŸŽ€ DESCRIPTION πŸŽ€

The variable can be set to the following values, and bestie there are literally two, it's not that deep:

  • "0" β€” SDL will not send an SDL_EVENT_QUIT event when the last window is requesting to close. but okay, hold on, don't get it twisted: in this case there are still other totally legitimate reasons you might get an SDL_EVENT_QUIT event anyway. like:
    • choosing "Quit" from the macOS menu bar πŸ‘€
    • sending a SIGINT (ctrl-c) on Unix πŸ’€
    • etc. (yes, the manpage literally says etc., the vibes are immaculate and vague)
  • "1" β€” SDL will send a quit event when the last window is requesting to close. and this one is the (default), so if you never touch this hint at all, congrats, you already have it. πŸ‘‘

plot twist time: if there is at least one active system tray icon, SDL_EVENT_QUIT will instead be sent when both the last window will be closed and the last tray icon will be destroyed. so it's a two-for-two situation. no cap. πŸ“


πŸ’– and the best part? this hint can be set anytime. no weird init-order drama, no "you had to do it before SDL_Init", none of that. set it whenever. slay.

🌈 AVAILABILITY 🌈

this hint is available since SDL 3.2.0. so if you're on something older, it's giving "not yet, babe". 🧚


okay and that's the whole page!! every option, every value, every default, every caveat β€” all accounted for, nothing dropped, periodt. πŸ’…

now go forth and quit (or don't quit) on your own terms, main character. ✨

Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_HINT_QUIT..._WINDOW_CLOSE(3) β€” mwah, ty for reading, ily, see u in the next manpage πŸŽ€πŸ’œ

πŸ“¦ where this page comes from