set_display_switch_callback(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– set_display_switch_callback(3) πŸ’–

okay bestie, so this one is from the Allegro manual β€” the game programming library β€” and it's lowkey one of those tiny functions that does something kinda iconic. it's called set_display_switch_callback, and yeah, it does exactly what the name says: it installs a callback so you get notified when display switching happens. let's get into it 🫢


✨ SYNOPSIS ✨

#include <allegro.h>

int set_display_switch_callback(int dir, void (*cb)());

🌸 DESCRIPTION 🌸

so here's the vibe. this function installs a notification callback for whichever switching mode you already picked earlier by calling set_display_switch_mode(). so like β€” you don't choose the mode here, you're just saying "hey, tell me when this happens." periodt.

the dir parameter is giving two options, and it can be either:

  • SWITCH_IN β€” you want to be notified about switches back to your program πŸ₯³
  • SWITCH_OUT β€” you want to be notified about switches away from your program 😭

and sometimes?? you can install callbacks for both directions at the same time β€” but bestie, not every platform supports that, so don't count on it. it's giving "platform dependent," iykyk.

you can also install several switch callbacks if you want, but there's a cap: no more than eight on any platform. so that's your limit, queen. πŸ‘‘


⭐ RETURN VALUE ⭐

  • returns zero on success πŸ’… (and heads up: every success decreases the number of empty callback slots by one)
  • returns -1 if the request is just straight up impossible for the current platform, or if you've already hit the maximum number of allowed callbacks πŸ’€
ngl, -1 here basically means "no room at the inn, or this platform said no."

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie! this one's from Allegro, version 4.4.3 β€” the date didn't come along for the ride, so just picture me blowing a lil kiss to whichever fine day it was written. mwah. πŸŽ€πŸ’œ

πŸ“¦ where this page comes from