
Hi, this is something I'm not able to solve without some help, I think. Suppose I want to implement the mouse focus with a layout modifier: now XMobar changes the focused window when you enter it with the pointer, and this is done in Main.handle. It would be nice to do that at the layout level, with modifyLayout returning a new layout when a crossing event is generated. In order not to bother layout writers, it should be possible to implement the mouse focus as a layout modifier, which add a hook to a specific layout event handler. While this approach (code below) works in general, it doesn't work with layouts that add other X event hooks, like Tabbed, or DragPane. The problem is that, when I modify the windows stack in the event handler below, I don't have a clear idea of how the XState should be modified. I think I just need some direction...;-) To test the code below you need to comment out from Main.hs this function: handle e@(CrossingEvent {ev_window = w, ev_event_type = t}) | t == enterNotify && ev_mode e == notifyNormal && ev_detail e /= notifyInferior = focus w 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 () Thanks for your kind attention. Andrea