XdbeSwapBuffers(3)

πŸ’– XdbeSwapBuffers β€” the manual, but make it make sense πŸ’–

okay bestie, so you know how this whole page is from the X FUNCTIONS part of the X library? yeah. and the function itself is called XdbeSwapBuffers, and it lives in manpage section 3 (that's the "C library functions" section, iykyk). let's get into it 🫢


✨ NAME ✨

XdbeSwapBuffers β€” swaps front and back DBE buffers. that's it, that's the whole job. she flips them. iconic behavior honestly πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <X11/extensions/Xdbe.h>

Status XdbeSwapBuffers(
    Display      *dpy,
    XdbeSwapInfo *swap_info,
    int          num_windows)

three args, no notes. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so what she DOES: this function swaps the front and back buffers for a whole list of windows. not just one. a list. she's a multitasker, she ate πŸ”₯

  • num_windows tells you how many windows are getting their buffers swapped β€” literally, it's the number of elements in the swap_info array. no more, no less.
  • swap_info is the tea 🍡 β€” it's the per-window info the function needs to actually do each swap.

and the XdbeSwapInfo structure? she has these two fields:

     Window            swap_window
     XdbeSwapAction    swap_action
  • swap_window β€” which window we're swapping buffers for.
  • swap_action β€” which swap action to use for that swap_window. (they're a matched pair, a duo, a little unit 🫢)

now, swap_action is the interesting part, because it decides what happens to the new back buffer of the swap_window it's paired with β€” on top of making the old back buffer visible. the defined actions are:

  • XdbeUndefined β€” the contents of the new back buffer become undefined. sounds scary but it's actually the efficient one: it lets the implementation just yeet the buffer contents if it wants to. fastest glow-up available πŸ’€βœ¨
  • XdbeBackground β€” the unobscured region of the new back buffer gets tiled with the window background. this one lets devices use a fast clear capability during a swap, which is a slay.
  • XdbeUntouched β€” the unobscured region of the new back buffer is left unmodified by the swap. she simply did not touch her.
  • XdbeCopied β€” the unobscured region of the new back buffer becomes the contents of the old back buffer. copy-paste core πŸŽ€

🌸 ERRORS 🌸

she can throw hands (errors). here's the list, no skipping:

  • BadMatch β€” you specified a window that isn't double-buffered, OR you specified the same window twice. rude. pick a lane bestie 😭
  • BadWindow β€” you specified a window that's just... invalid. doesn't exist. ghosted.
  • BadValue β€” you specified an invalid swap action. not a real one. made up. πŸ’€
lowkey important: these are actual errors that get raised, not vibes. check your windows and your actions before you call her, fr fr.

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, bestie, they're all part of the same friend group:

  • DBE
  • XdbeAllocateBackBufferName()
  • XdbeBeginIdiom()
  • XdbeDeallocateBackBufferName()
  • XdbeEndIdiom()
  • XdbeFreeVisualInfo()
  • XdbeGetBackBufferAttributes()
  • XdbeGetVisualInfo()
  • XdbeQueryExtension()

and that's the whole page 🫢 this came to you courtesy of X Version 11 and libXext 1.3.6, and yes, this is XdbeSwapBuffers(3) β€” section 3, exactly where she belongs. go swap some buffers, you've got this πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from