From 2cdf36f4d4629e2cea75c4f333951c69c76d5b24 Mon Sep 17 00:00:00 2001 From: Rob Date: Fri, 25 May 2007 04:41:18 +0200 Subject: Deleting a window should not affect focus This fixes a bug whereby deleting a window will first move focus to that window before deleting it without moving focus back afterwards. The fix generalises the remove inner function to delete a window from the stack whether it's in focus or not. If the window is in focus, behaviour remains as it was. darcs-hash:20070525024118-64d90-a9f70b49186be59e62af4b11671099996c5e294f --- StackSet.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'StackSet.hs') diff --git a/StackSet.hs b/StackSet.hs index fe9d20c..b00c67e 100644 --- a/StackSet.hs +++ b/StackSet.hs @@ -345,13 +345,16 @@ delete w s | Just w == peek s = remove s -- common case. | otherwise = maybe s (removeWindow.tag.workspace.current $ s) (findIndex w s) where -- find and remove window script - removeWindow o n = foldr ($) s [view o,remove ,until ((Just w ==) . peek) focusLeft,view n] + removeWindow o n = foldr ($) s [view o,remove,view n] -- actual removal logic, and focus/master logic: - remove = modify Empty $ \c -> case c of + remove = modify Empty $ \c -> + if focus c == w + then case c of Node _ ls (r:rs) -> Node r ls rs -- try right first Node _ (l:ls) [] -> Node l ls [] -- else left. Node _ [] [] -> Empty + else c { left = w `L.delete` left c, right = w `L.delete` right c } ------------------------------------------------------------------------ -- Setting the master window -- cgit v1.2.3