aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Actions/DynamicWorkspaces.hs
diff options
context:
space:
mode:
authorDmitri Iouchtchenko <johnnyspoon@gmail.com>2012-12-31 22:41:48 +0100
committerDmitri Iouchtchenko <johnnyspoon@gmail.com>2012-12-31 22:41:48 +0100
commit8fbdc28858d0fa8c6bcb477d51a7dae8bc61909c (patch)
treece0c1b04c28fb228ad33f13425e43be2acf0bf84 /XMonad/Actions/DynamicWorkspaces.hs
parent0ede61b0834ce50846d9a73a98e8a2726cfa41b1 (diff)
downloadXMonadContrib-8fbdc28858d0fa8c6bcb477d51a7dae8bc61909c.tar.gz
XMonadContrib-8fbdc28858d0fa8c6bcb477d51a7dae8bc61909c.tar.xz
XMonadContrib-8fbdc28858d0fa8c6bcb477d51a7dae8bc61909c.zip
Remove first-hidden restriction from X.A.DynamicWorkspaces.removeWorkspace'
Ignore-this: 55fb0859e9a5f476a834ecbdb774aac8 darcs-hash:20121231214148-7d114-78826e0e2f25128ddd79a6360d7c24b72f40b0f6.gz
Diffstat (limited to 'XMonad/Actions/DynamicWorkspaces.hs')
-rw-r--r--XMonad/Actions/DynamicWorkspaces.hs18
1 files changed, 11 insertions, 7 deletions
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