Hacking Windowlab

This post looks at some fun ways to mess with windowlab, the clean and fast window manager featured in an earlier blog post which is now lost to time.

We'll be targeting an ubuntu system, and updating the window manager to focus on newly created windows. The amiga style window focusing mechanism is great and this modification is intended for use with application launchers such as gnome-do.

Download Source

wget http://nickgravgaard.com/windowlab/windowlab-1.40.tar
tar -xf windowlab-1.40.tar

Install Dependencies

sudo apt-get libxext-dev libx11-dev windowlab

Modify Build Params

Update Makefile parameter for the conf dir
CONFDIR = /etc/X11/windowlab
Update @windowlab.h@ def to be a font currently installed. Use xlsfonts to pick a nice one.
#define DEF_FONT "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1"

Update Source

Look for a code block in @new.c@ like the following and add the comments as below.
// if no client has focus give focus to the new client
//if (focused_client == NULL)
  focused_client = c;

Build and Replace Binary

mv /usr/bin/windowlab /usr/bin/windowlab_sys
cp ./windowlab /usr/bin/windowlab

Restart your session.

Adding Tiling

A tiling feature resizes and moves windows such that no two windows are overlapping and all windows are visible. This gives you a high level view of what is open. Of course many of the feature rich window managers have this feature in spades with animations, but let's consider adding a simple implementation to window lab for now.

The problem is known as bin packing, and I've read it is NP-Hard. There are a whole bunch of algorithms and interesting approaches to the problem out there and it's a fun one to think about.

The key considerations for the approach implemented:

* Sublinear time.
* Easy to Implement.

The approach which meets these needs are the class of solutions called Shelving algorithms. In this case it is a shelving algorithm which has a roughly geometrically window size change as a shelf approaches the right boundary.

Implementation is here and of course feel free to download an use this version of window lab for the features above. Currently the tiling function is triggered by "Alt-tab."