aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-03-20 17:01:35 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-03-20 17:01:35 +0100
commitc31a1eacc9cc232bc8922dbfab3e7a3baceaf660 (patch)
treeaa91945ef3e323fece09c81732e18e1f6f32c92b
parente8a7dfa022ae31d0d663fb3cd603f666014e7a32 (diff)
downloadxmonad-c31a1eacc9cc232bc8922dbfab3e7a3baceaf660.tar.gz
xmonad-c31a1eacc9cc232bc8922dbfab3e7a3baceaf660.tar.xz
xmonad-c31a1eacc9cc232bc8922dbfab3e7a3baceaf660.zip
Add raiseFocus.
darcs-hash:20070320160135-a5988-01f4a5df331fac6fbf00c209a40105da74b9b88d.gz
-rw-r--r--StackSet.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 3604f3b..8103075 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -162,5 +162,12 @@ delete k w = maybe w tweak (M.lookup k (cache w))
, stacks = M.adjust (L.delete k) i (stacks w)
, focus = M.update (\k' -> if k == k' then elemAfter k (stacks w M.! i) else Just k') i (focus w) }
+-- | /O(log n)/. If the given window is contained in a workspace, make it the
+-- focused window of that workspace.
+raiseFocus :: Ord a => a -> StackSet a -> StackSet a
+raiseFocus k w = case M.lookup k (cache w) of
+ Nothing -> w
+ Just i -> w { focus = M.insert i k (focus w) }
+
elemAfter :: Eq a => a -> [a] -> Maybe a
elemAfter w ws = listToMaybe . filter (/= w) . dropWhile (/= w) $ ws ++ ws