Building a Window Manager

LinuxX11Window Managers

Linux Problem Overview


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?

Linux Solutions


Solution 1 - Linux

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.

Solution 2 - Linux

the tinywm in C may be helpful for getting started.

Solution 3 - Linux

While another language and set of libraries are technically possible, I think the best language choice would be C, and the Xlib or XCB libraries. Most window managers for X use that, and there is already lots of momentum here and maturity for these particular libraries.

Some documents of interest:

Solution 4 - Linux

  • Which is the best language to do this?

    Whichever you are most comfortable with. There are lots of examples of successful window managers in many different languages out there. http://www.qtile.org/">Qtile</a> and http://www.xmonad.org/">xmonad</a> are good examples, written in Python and Haskell respectively.

  • Where to get some resources to learn?

    I would go look at some of the existing window managers. There are lots of them, so at least some of them has to have readable code. Here is the http://www.gilesorr.com/wm/table.html">Comprehensive List of Window Managers for Unix.

Solution 5 - Linux

I know this topic is a bit old, but I was wondering the same thing. This window manager called i3 seems like a good one to learn from too.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNathan CamposView Question on Stackoverflow
Solution 1 - LinuxJosh LeeView Answer on Stackoverflow
Solution 2 - LinuxmtveeView Answer on Stackoverflow
Solution 3 - LinuxasveikauView Answer on Stackoverflow
Solution 4 - LinuxMikael AunoView Answer on Stackoverflow
Solution 5 - LinuxAlex OzerView Answer on Stackoverflow