[xmonad] Newbie questions (wrt floating windows)

Matthew Hague matthewhague at zoho.com
Sun Jul 8 03:18:14 CEST 2012


>     2) The floating windows are always in front of tiled windows.  This is
>     annoying: i would like to be able to script something so that the floating
>     layer is hidden if a tiled window is focused.  Is there some command along
>     the lines of "hide all floats"?

I have a solution to this as follows.  Apologies for the newbie haskell...

First some functions for hiding the floating windows when you're viewing a
tiled one:

   doIfFloat :: (Window -> X()) -> M.Map Window W.RationalRect -> Window -> X ()
   doIfFloat f floats w = if (M.member w floats) then f w else return ()
   
   withWindows :: (Window -> X ()) -> X ()
   withWindows f = do
       wins <- gets (W.allWindows . windowset)
       mapM f wins
       return ()
   
   
   showHideFloats :: X ()
   showHideFloats = do
       (mw, floats) <- gets (liftM2 (,) W.peek W.floating . windowset)
       maybe (return ()) (\w -> if (M.member w floats)
                                then return () -- XMonad unhides automatically
                                else withWindows (doIfFloat hide floats)) mw
  
Then one for making sure the focused window is on top (as floats can hide
other floats):

   raiseFocused :: X ()
   raiseFocused = do
       XConf { display = disp } <- ask
       mw <- gets (W.peek . windowset)
       maybe (return ()) (io . (raiseWindow disp)) mw
   

Finally, my log hook:

    logHook = raiseFocused <+> showHideFloats

If you don't like all the tiled windows appearing when you focus just one of
them, you can simply set 

    logHook = raiseFocused

If anyone likes this, perhaps i could make a contrib module?  Criticisms &c.
encouraged :)

Matt



More information about the xmonad mailing list