October 20, 2010

XMonad - Java focus issues

The awesome xmonad window manager has a couple of issues with java. The most common issue is being presented with a blank grey screen instead of your traditional ugly swing app. This is a java problem and is fixable in a couple of ways (see the xmonad faq).

A more subtle and persistent issue is focus in and around java application: dialogs not getting focus; switching away from then back to a window causes it to lose the cursor.

These are all symptoms of a bug where xmonad violates the window manager communication protocol. For some reason this has been an outstanding issue for over two years even though there is a workable patch available. Up until now I had been building xmonad from darcs with this patch. However, this is a bit annoying come upgrade time, and at work when you want to leave the yaks alone.

So with a nod to Nils Decker who came up with the log hook and Tony Morris for tidying up the haskell the following is a config workaround to address the symptoms (it fixes most of the java issues, but xmonad still does not abide by the protocol).

The hacky focus functions

Note that this depends on import Control.Monad

Wiring it into xmonad.hs