Building a Window Manager

Nathan Campos picture Nathan Campos · Nov 28, 2009 · Viewed 30.6k times · Source

One of my new home projects will be a simple Window Manager, but before start I need to know some things:

  • Which is the best language to do this?
  • Where to get some resources to learn?

Answer

Josh Lee picture Josh Lee · Nov 28, 2009

One important decision is how you're going to talk to the X server. You can use the Xlib bindings for your language of choice, or you can use the higher-level XCB bindings. (If you're insane, you might open a socket to the X server directly.)

To know how a window manager ought to behave, there are two documents that specify the conventions and policies: EWMH and ICCCM1. Conforming to these means your window manager will behave nicely in GNOME, KDE, XFCE, and any other desktop environment that comes along, although simply ignoring them is certainly easier on your first try.

A window manager needn't be a huge, complicated ball of C — Successful window managers have been written in high-level languages like Lisp, Haskell, and Python, and even some in C have remained small and readable. XMonad, written in Haskell, stayed under 1000 lines for quite some time. StumpWM (Common Lisp) and DWM (C) are both quite minimalist. You might be able to read their source code to get some inspiration as to how to design a WM.


1 Elijah Newren wrote:

DO NOT GO AND READ THOSE THINGS. THEY ARE REALLY, REALLY BORING. If you do, you'll probably end up catching up on your sleep instead of hacking on Metacity. ;-)

Come to think of it, Metacity's documentation has a good bit to say about how it interacts with windows and what sort of extended properties it supports.