summaryrefslogtreecommitdiffstats
path: root/StackSet.hs
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
commit006e62b46b3d1026c6048d0a0ccc3bab5abb3465 (patch)
treeaa91945ef3e323fece09c81732e18e1f6f32c92b /StackSet.hs
parent1721e09a67d14a31bd1ddaf637c37bb6e4129c52 (diff)
downloadmetatile-006e62b46b3d1026c6048d0a0ccc3bab5abb3465.tar
metatile-006e62b46b3d1026c6048d0a0ccc3bab5abb3465.zip
Add raiseFocus.
darcs-hash:20070320160135-a5988-01f4a5df331fac6fbf00c209a40105da74b9b88d
Diffstat (limited to 'StackSet.hs')
-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