[Xmonad] help with layout modifiers

David Roundy daveroundy at gmail.com
Wed Aug 29 10:27:48 EDT 2007


On Wed, Aug 29, 2007 at 12:48:15PM +0200, Andrea Rossato wrote:
> And this is the example code. You use it like this, in your Config.hs:
> 
> defaultLayouts = [ mouseFocus $ dragUpDownPane "dd" 0.1 0.5
> 		 , mouseFocus $ tabbed shrinkText defaultTConf
> 		 , mouseFocus tiled ]
> 
> mouseFocus :: Layout a -> Layout a
> mouseFocus  cl@(Layout {doLayout = dl , modifyLayout = ml}) = 
>     Layout {doLayout = doLay , modifyLayout = modLay}
>     where doLay r s = dl r s
>           modLay sm | Just e <- fromMessage sm = do
>                                  handle_event e
>                                  ml sm -- right??
>                     | otherwise = ml sm
> 
>           handle_event e@(CrossingEvent {ev_window = w, ev_event_type = t})
>               | t == enterNotify && ev_mode   e == notifyNormal
>                                  && ev_detail e /= notifyInferior = do
>                                    focus w -- what should I do to XState after this?
>                                    return ()
>           handle_event _ = return ()

Your doLay is buggy:  when dl returns a modified layout, your mouseFocus
"falls off".  Similarly with ml.  I would use LayoutHelpers:

mouseFocus = layoutModifer idModDo modLay
  where modLay sm | Just e <- fromMessage sm = handle_event e >> return Nothing
        handle_event e@(CrossingEvent {ev_window = w, ev_event_type = t})
               | t == enterNotify && ev_mode   e == notifyNormal
                                  && ev_detail e /= notifyInferior
                   = focus w -- what should I do to XState after this?
        handle_event _ = return ()


-- 
David Roundy
http://www.darcs.net


More information about the Xmonad mailing list