xmonad-contrib/SimpleStacking.hs
David Roundy d3048ed615 make everything work with new doLayout.
This modifies all the contrib modules to work (so far as I know) with the
new contrib layout.  The exception is the LayoutHooks module, which isn't
used.  It exports an API that is inherently unsafe, so far as I can tell
(and always has been).
2007-06-23 21:09:52 +00:00

49 lines
1.7 KiB
Haskell

{-# OPTIONS -fglasgow-exts #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonadContrib.SimpleStacking
-- Copyright : (c) David Roundy <droundy@darcs.net>
-- License : BSD-style (see LICENSE)
--
-- Maintainer : David Roundy <droundy@darcs.net>
-- Stability : unstable
-- Portability : unportable
--
-- A module to be used to obtain a simple "memory" of stacking order.
--
-- WARNING: This module is incompatible with Xinerama!
--
-----------------------------------------------------------------------------
module XMonadContrib.SimpleStacking (
-- * Usage
-- $usage
simpleStacking
) where
import Control.Monad.State ( get )
import qualified Data.Map as M
import Data.Maybe ( catMaybes )
import Data.List ( nub, lookup, delete )
import StackSet ( focus, tag, workspace, current, up, down )
import Graphics.X11.Xlib ( Window )
import XMonad
import XMonadContrib.LayoutHelpers
-- $usage
-- You can use this module for
-- See, for instance, "XMonadContrib.Tabbed"
simpleStacking :: Layout Window -> Layout Window
simpleStacking = simpleStacking' []
simpleStacking' :: [Window] -> Layout Window -> Layout Window
simpleStacking' st = layoutModify dl idModMod
where dl r s wrs = let m = map (\ (w,rr) -> (w,(w,rr))) wrs
wrs' = catMaybes $ map ((flip lookup) m) $
nub (focus s : st ++ map fst wrs)
st' = focus s:filter (`elem` (up s++down s)) st
in return (wrs', Just (simpleStacking' st'))