summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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