I want to create a simple stacking window manager (in C
) for private use, mainly for the purpose of learning and challenging myself.
I\'ve looked throug
metacity uses gtk for certain UI elements. See its HACKING and README.
see also Where are some good Xlib programming guides?
Xmonad might be a good place to start.
http://code.google.com/p/partiwm/ is an attempt to write a window manager (tiling, not stacking) from scratch, it might be useful to you to read through the code.
I've written an in-depth tutorial series that shows you how to write an X11 window manager in C++:
In addition, you can check out a simple example window manager, basic_wm, at
It's heavily commented for pedagogical purposes.
On Xlib vs XCB - I would recommend Xlib over XCB if you're first starting out. XCB is more efficient, but it's much more low-level and much more verbose (think assembly language for the GUI). You don't want to burden yourself with premature optimization until you already have a prototype working.
Have a look at the code for dwm. The codebase is beautiful and easy to understand. The entire thing is about 2000 lines.
Whatever you do, use XCB and not Xlib. It' modern, asynchronous, simpler and gives you direct access to the X11 protocol.