XDestroyWindow(3)
💥 XDestroyWindow(3) — destroy windows
okay so this page comes from the XLIB FUNCTIONS manual, and it’s all about XDestroyWindow and XDestroySubwindows — aka the “bye-bye window” girlies 💅. No cap, they destroy windows, and there are some important little rules you need to know so you don’t end up referencing a dead window like a clown.
🌸 NAME
XDestroyWindow, XDestroySubwindows — destroy windows
✨ SYNTAX
int XDestroyWindow(Display *display, Window w);
int XDestroySubwindows(Display *display, Window w);
🎀 ARGUMENTS
display— specifies the connection to the X server, bestie. That’s the whole vibe.w— specifies the window. The one we’re about to lovingly obliterate 🫶.
💅 DESCRIPTION
So XDestroyWindow destroys the window you specified and all of its subwindows, and it makes the X server generate a DestroyNotify event for each window. That part is important, okay?
The window should never be referenced again. Like, ever. It’s gone, bestie. Do not text it back. 😭
If the window specified by the w argument is mapped, it gets unmapped automatically — the X server handles that for you, slay.
The ordering of the DestroyNotify events is such that, for any given window being destroyed, DestroyNotify is generated on any inferiors of the window before being generated on the window itself. The ordering among siblings and across subhierarchies is not otherwise constrained. So yeah: inferiors first, then the window itself; siblings and subhierarchies don’t get any extra ordering rules beyond that.
If the window you specified is a root window, no windows are destroyed. Root window said “not today,” periodt.
Destroying a mapped window will generate Expose events on other windows that were obscured by the window being destroyed. That’s just the X server doing its dramatic little reveal ✨.
XDestroyWindow can generate a BadWindow error.
Now for XDestroySubwindows — she’s the efficient one 👑
XDestroySubwindows destroys all inferior windows of the specified window, in bottom-to-top stacking order. It causes the X server to generate a DestroyNotify event for each window.
If any mapped subwindows were actually destroyed, XDestroySubwindows causes the X server to generate Expose events on the specified window. Cute.
This is much more efficient than deleting many windows one at a time because much of the work need be performed only once for all of the windows, rather than for each window. Like, why do the same chore over and over when you can batch it? Exactly. 🔥
The subwindows should never be referenced again either. Once they’re destroyed, they’re destroyed. Don’t be weird about it.
XDestroySubwindows can generate a BadWindow error.
🚨 DIAGNOSTICS
BadWindow— a value for aWindowargument does not name a definedWindow. Basically, you gave it a window that isn’t a real defined window, and it said “ma’am, who?” 💀
👀 SEE ALSO
XChangeWindowAttributes(3)XConfigureWindow(3)XCreateWindow(3)XMapWindow(3)XRaiseWindow(3)XUnmapWindow(3)Xlib - C Language X Interface
mwah 💋 this cute little destruction manual is from X Version 11, libX11 1.8.14, and yes, it’s the XDestroyWindow(3) page — now go forth and destroy windows responsibly, bestie 🎀✨
📦 where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 · X11
- arch rolling: libx11 1.8.14-1 · MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms