Minor style changes in DynamicWorkspaces

This commit is contained in:
Adam Vogt 2009-11-15 02:27:51 +00:00
parent b3329397c0
commit 4f97bc02ce

View File

@ -124,14 +124,11 @@ addHiddenWorkspace newtag =
-- | Remove the current workspace if it contains no windows.
removeEmptyWorkspace :: X ()
removeEmptyWorkspace = do t <- (tag.workspace.current) `fmap` gets windowset
removeEmptyWorkspaceByTag t
removeEmptyWorkspace = gets (currentTag . windowset) >>= removeEmptyWorkspaceByTag
-- | Remove the current workspace.
removeWorkspace :: X ()
removeWorkspace = do t <- (tag.workspace.current) `fmap` gets windowset
removeWorkspaceByTag t
removeWorkspace = gets (currentTag . windowset) >>= removeWorkspaceByTag
-- | Remove workspace with specific tag if it contains no windows. Only works
-- on the current or the last workspace.
@ -140,11 +137,11 @@ removeEmptyWorkspaceByTag t = whenX (isEmpty t) $ removeWorkspaceByTag t
-- | Remove workspace with specific tag. Only works on the current or the last workspace.
removeWorkspaceByTag :: String -> X ()
removeWorkspaceByTag torem = do s <- gets windowset
removeWorkspaceByTag torem = do
s <- gets windowset
case s of
StackSet { current = Screen { workspace = cur }
, hidden = (w:_) }
-> do when (torem==tag cur) $ windows $ view $ tag w
StackSet { current = Screen { workspace = cur }, hidden = (w:_) } -> do
when (torem==tag cur) $ windows $ view $ tag w
windows $ removeWorkspace' torem
_ -> return ()
@ -158,11 +155,11 @@ removeEmptyWorkspaceAfter = removeEmptyWorkspaceAfterExcept []
-- | Like 'removeEmptyWorkspaceAfter' but use a list of sticky workspaces,
-- whose entries will never be removed.
removeEmptyWorkspaceAfterExcept :: [String] -> X () -> X ()
removeEmptyWorkspaceAfterExcept sticky f = do before <- getTag
removeEmptyWorkspaceAfterExcept sticky f = do
before <- gets (currentTag . windowset)
f
after <- getTag
after <- gets (currentTag . windowset)
when (before/=after && before `notElem` sticky) $ removeEmptyWorkspaceByTag before
where getTag = (tag.workspace.current) `fmap` gets windowset
isEmpty :: String -> X Bool
isEmpty t = do wsl <- gets $ workspaces . windowset