[xmonad] How to get floating focused window on top?

Justin Bogner mail at justinbogner.com
Tue Mar 8 04:57:36 CET 2011

Juan Pedro Bolivar Puente <raskolnikov at gnu.org>
> When dealing with focused windows like dialogs quite often a popup
> window appears *behind* the main window, stealing the focus. To get
> access to that window one has to move the main window to get to
> it. This is quite annoying and it could be easily solved if the
> focused window where kept on top of the floating windows stack. Is
> there any way to set this behaviour?

It's a bit complicated, but here's what I have:
    floating = (ask >>= liftX . willFloat)
                -- panel applets make everything shift around when
                -- shifted to master.
                <&&> (liftM (not . isSuffixOf "-panel")) resource
                <&&> (liftM (not . isSuffixOf "-applet")) resource
    -- This is logic copied from XMonad.Operations.manage, since
    -- manageHook is called before windows are floated
    -- | Determine if @w@ will be floated when it becomes managed.
    willFloat w = withDisplay $ \d -> do
                    sh <- io $ getWMNormalHints d w
                    let isFixedSize = sh_min_size sh /= Nothing
                                      && sh_min_size sh == sh_max_size sh
                    isTransient <- isJust <$> io (getTransientForHint d w)
                    f <- isFloat w
                    return (isFixedSize || isTransient || f)

and then I have "floating --> doF W.shiftMaster" in my managehook. There
might be a simpler way, but this has worked since xmonad 0.5 or 0.6, so
why change now?

More information about the xmonad mailing list