aboutsummaryrefslogtreecommitdiffstats
path: root/DwmPromote.hs
diff options
context:
space:
mode:
authorMiikka Koskinen <arcatan@kapsi.fi>2007-05-21 14:31:40 +0200
committerMiikka Koskinen <arcatan@kapsi.fi>2007-05-21 14:31:40 +0200
commit9bb0bc291344fc093f9bba4d5c38ebcc166a8726 (patch)
tree51e0279b2f707ca11985bb6a3a49bea3f0a8f722 /DwmPromote.hs
parent5aedd73cbcce6fbd41592eae0f5a29a31ec83316 (diff)
downloadXMonadContrib-9bb0bc291344fc093f9bba4d5c38ebcc166a8726.tar.gz
XMonadContrib-9bb0bc291344fc093f9bba4d5c38ebcc166a8726.tar.xz
XMonadContrib-9bb0bc291344fc093f9bba4d5c38ebcc166a8726.zip
make DwmPromote compile
darcs-hash:20070521123140-0ff8e-758cc8308a98d7639077383f6d95b53050cac8cf.gz
Diffstat (limited to '')
-rw-r--r--DwmPromote.hs21
1 files changed, 7 insertions, 14 deletions
diff --git a/DwmPromote.hs b/DwmPromote.hs
index b3434f6..10cbafe 100644
--- a/DwmPromote.hs
+++ b/DwmPromote.hs
@@ -8,7 +8,7 @@
--
-----------------------------------------------------------------------------
--
--- Dwm-like promote function for xmonad.
+-- Dwm-like swap function for xmonad.
--
-- Swaps focused window with the master window. If focus is in the
-- master, swap it with the next window in the stack. Focus stays in the
@@ -27,20 +27,13 @@ module XMonadContrib.DwmPromote (dwmpromote) where
import XMonad
import Operations (windows)
-import StackSet hiding (promote)
+import StackSet hiding (swap)
import qualified Data.Map as M
dwmpromote :: X ()
-dwmpromote = windows promote
+dwmpromote = windows swap
-promote :: (Integral i, Integral j, Ord a) => StackSet i j a -> StackSet i j a
-promote w = maybe w id $ do
- a <- peek w -- fail if null
- stack <- index (current w) w
- let newstack = swap a (next stack a) stack
- return . raiseFocus (head newstack) $
- w { stacks = M.adjust (\(f,_) -> (f, newstack)) (current w) (stacks w) }
- where
- next s a | head s /= a = head s -- focused is not master
- | length s > 1 = s !! 1
- | otherwise = a
+swap :: StackSet i a s -> StackSet i a s
+swap = modify Empty $ \c -> case c of
+ Node t [] (x:rs) -> Node x [] (t:rs)
+ Node t ls rs -> Node t [] (ys ++ x : rs) where (x:ys) = reverse ls