[xmonad] Debugging xmonad (also issue 225)

Adam Vogt vogt.adam at gmail.com
Sun Jan 1 21:02:32 CET 2012

* On Thursday, December 29 2011, Ivan S. Freitas wrote:

>Hello all,
>I'm trying to improve the proposed patch for issue 225, by adding a
>configuration option to toggle its behavior.
>So far, I applied the old patch, added the variable to control the
>behavior, and tried to use the setting to
>decide which behavior to use (see the attached patch, sorry if it's
>wrongly formatted but I'm not used to
>darcs yet).
>The problem: with clickToFocus (the option I've added) turned to False
>(i.e., the click changes the focus
>but still goes to the application), everything works as expected. But
>setting it to True (i.e., keeps the default
>xmonad's behavior) xmonad just freezes after I click on any window
>(setting before calling startx or recompiling
>inside xmonad doesn't solve that, either). So, how do I debug xmonad
>to find where I made a mistake?
>Also, note that I'm somewhat new to haskell, so imperative programming
>still cripples my thought.

Hi Ivan,

It seems that the pointer grab mode was changed in the original patch, so 
it works if you also adjust that depending on the config. I've added a 
patch doing that to issue 225.

While the changes to 'handle' could be done in contrib since you could ask 
the user to add a function to their handleEventHook, I don't think the 
changes to setButtonGrab could be done that way.

For other problems such as this one, you can run xmonad interpreted in ghci 
which lets you set some breakpoints and inspect values (check the ghc manual).
One thing to watch out for is that when you mix compiled code in with
interpreted code the type errors can be confusing since it isn't
explicit that one XConfig is interpreted and the other is compiled:

   Couldn't match expected type `XMonad.Core.XConfig l0'
               with actual type `XConfig a0'
   Expected type: XConfig a0 -> XMonad.Core.XConfig l0
     Actual type: XConfig a0 -> XConfig a0
   In the first argument of `(.)', namely `ewmh'
   In the second argument of `(.)', namely `ewmh . urgency . myConfig'

So to avoid that you can do the following:

hsc2hs Main.hsc # in the xmonad repo
ghci -hide-package xmonad -i$HOME/path/to/xmonad -i$HOME/path/to/XMonadContrib $HOME/.xmonad/xmonad.hs

More information about the xmonad mailing list