[xmonad] Slowly, slowly getting calls to getWindowAttributes in XMonad to handle exceptions

Adam Sjøgren asjo at koldfront.dk
Thu Dec 31 22:53:13 UTC 2015


While fixing the "borders of RGBA-windows are weirdly coloured"-bug¹,
having changed X11's getWindowAttributes to throw an exception on error,
I am trying to work my way through the various calls to
getWindowAttributes in the XMonad source, and handle the exceptions.

With my (lacking) knowledge, it's proving somewhat difficult. Let me
show you the latest call I have been trying to tackle:

  -- manage a new window
  handle (MapRequestEvent    {ev_window = w}) = withDisplay $ \dpy -> do
      wa <- io $ getWindowAttributes dpy w -- ignore override windows
      -- need to ignore mapping requests by managed windows not on the current workspace
      managed <- isClient w
      when (not (wa_override_redirect wa) && not managed) $ do manage w

What needs to happen is that I need to wrap this, so if
getWindowAttributes throws an exception, something reasonable happens.

Right.

As the code does nothing if wa_override_redirect is set, maybe it makes
sense to assume that if wa isn't available, wa_o_r probably isn't
set(?), so we then need to go on and "do manage w" if "not managed" in
that case.

Ok. But how?

I've tried a number of combinations of wrapping C.handle around this,
similar to what I have found before², but I certainly need (to read a
lot more, or, some) help - I keep getting IO () when I need X (), or the
opposite, and stuff like that.


  Best regards,

    Adam


¹ https://github.com/xmonad/xmonad/pull/9 depending on https://github.com/xmonad/X11/pull/35
² An attempt at one of the other calls to getWindowAttributes: https://github.com/asjo/xmonad/commit/8c2b6047a9adf5689b6082c806dc20bb6501f6d9
  (compiles and works, but really created by guess, trial and error).

-- 
 "Sprecken Sie deutsch, baby"                                 Adam Sjøgren
                                                         asjo at koldfront.dk



More information about the xmonad mailing list