From 8fbdc28858d0fa8c6bcb477d51a7dae8bc61909c Mon Sep 17 00:00:00 2001 From: Dmitri Iouchtchenko Date: Mon, 31 Dec 2012 22:41:48 +0100 Subject: Remove first-hidden restriction from X.A.DynamicWorkspaces.removeWorkspace' Ignore-this: 55fb0859e9a5f476a834ecbdb774aac8 darcs-hash:20121231214148-7d114-78826e0e2f25128ddd79a6360d7c24b72f40b0f6.gz --- XMonad/Actions/DynamicWorkspaces.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'XMonad/Actions/DynamicWorkspaces.hs') diff --git a/XMonad/Actions/DynamicWorkspaces.hs b/XMonad/Actions/DynamicWorkspaces.hs index 4451591..56b5ecc 100644 --- a/XMonad/Actions/DynamicWorkspaces.hs +++ b/XMonad/Actions/DynamicWorkspaces.hs @@ -130,12 +130,11 @@ removeEmptyWorkspace = gets (currentTag . windowset) >>= removeEmptyWorkspaceByT removeWorkspace :: X () removeWorkspace = gets (currentTag . windowset) >>= removeWorkspaceByTag --- | Remove workspace with specific tag if it contains no windows. Only works --- on the current or the last workspace. +-- | Remove workspace with specific tag if it contains no windows. removeEmptyWorkspaceByTag :: String -> X () removeEmptyWorkspaceByTag t = whenX (isEmpty t) $ removeWorkspaceByTag t --- | Remove workspace with specific tag. Only works on the current or the last workspace. +-- | Remove workspace with specific tag. removeWorkspaceByTag :: String -> X () removeWorkspaceByTag torem = do s <- gets windowset @@ -169,13 +168,18 @@ isEmpty t = do wsl <- gets $ workspaces . windowset addHiddenWorkspace' :: i -> l -> StackSet i l a sid sd -> StackSet i l a sid sd addHiddenWorkspace' newtag l s@(StackSet { hidden = ws }) = s { hidden = Workspace newtag l Nothing:ws } +-- | Remove the hidden workspace with the given tag from the StackSet, if +-- it exists. All the windows in that workspace are moved to the current +-- workspace. removeWorkspace' :: (Eq i) => i -> StackSet i l a sid sd -> StackSet i l a sid sd removeWorkspace' torem s@(StackSet { current = scr@(Screen { workspace = wc }) - , hidden = (w:ws) }) - | tag w == torem = s { current = scr { workspace = wc { stack = meld (stack w) (stack wc) } } - , hidden = ws } + , hidden = hs }) + = let (xs, ys) = break ((== torem) . tag) hs + in removeWorkspace'' xs ys where meld Nothing Nothing = Nothing meld x Nothing = x meld Nothing x = x meld (Just x) (Just y) = differentiate (integrate x ++ integrate y) -removeWorkspace' _ s = s + removeWorkspace'' xs (y:ys) = s { current = scr { workspace = wc { stack = meld (stack y) (stack wc) } } + , hidden = xs ++ ys } + removeWorkspace'' _ _ = s -- cgit v1.2.3