[Xcb] window manager?

Jon Mayo jon.mayo at gmail.com
Sat Jul 25 12:29:54 PDT 2009


On Wed, Jul 22, 2009 at 12:31 PM, Marco Carmosino<mogunus at gmail.com> wrote:
> Hello all.
>
> I would like to build a window manager using XCB. I have never
> programmer for X before, I have no experience using Xlib, and I am
> completely ignorant of the X11 protocol. I am having trouble finding
> documentation to bring myself up to speed.
>
> I interested in really understanding what is going on with X.org and
> the X11 protocol, so I can craft a decent wm. Please point me at the
> best resources for generating a complete understanding.
>
> Thanks,
>
> --Mog

Nobody can craft a decent WM on their first try. Usually you have to
write a couple and throw them away before they are any good.
I would highly recommend you dig into a few simple WMs first to
understand how they work. Read some of the documentation on ICCCM and
libICE and libSM.
There isn't any good beginner documentation for XCB, you'll have to
start with one of the many excellent books on Xlib. You will want to
write a few simple demo applications in Xlib using what you learn
about Xlib before you take on a WM. It will be easier to get events
and windows figured out in a simple application (can be a Hello World
app) than it will be to figure out that stuff while doing a WM.

Once you have done a couple of simple apps in Xlib, and have a feel
for how an Xlib program is put together. Then you can start the
process of learning XCB and perhaps convert your simple apps (or
rewrite them) into XCB apps. You can either write your WM in Xlib or
XCB at this point. Then port it to XCB when you are happy with your
rough framework of a WM. (pre-Alpha software).

I would not recommend you write a WM if your only interest is to make
a better one, that is best done by improving one of the dozen popular
ones actively maintained. You should only do a WM in this day an age
if you have some burning desire to dig into the guts of the X world
and learn a few esoteric skills. But if you decide to move forward
with this, here are a couple of tips on getting started:

One of the best ways to learn about WMs is to try a lot of them and
read the source. Starting with the many Xlib based WMs; tinywm and if
you have an interest in C++ taking a peek at wm2 or wmx or ion2. From
there start going into things like icewm and openbox and possibly
metacity. I would avoid things like fvwm and windowmaker. They do a
lot more than manage windows, so there is a lot of extra code to wade
through.

For something practical and XCB-based, check out a window manager
called "awesome". It might not have a user interface you like, but it
does include Lua scripting that seems to have lots of window manager
bindings in it. It can be a useful way to experiment with ideas.

I personally believe a key difficulty in doing a good WM is getting
events right and getting Atoms right. Making a user interface that you
want is not technically hard, it just takes time to evolve. Another
difficulty is that many widget kits don't work that well at the root
window level, so you usually end up constructing your own window
decorations. There isn't any great reason the widget libraries don't
also support some of the hooks necessary for window manager
functionality. It's probably not an impossible problem to solve
through extensions of gtk or Qt, I just don't see WM authors going
that route because it seems like a lot of extra work compared to doing
the Xlib/XCB code yourself.

-- 
Jon Mayo
<jon.mayo at gmail.com>


More information about the Xcb mailing list