From af442ded0759b24906eac4f71a369207020345d7 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Sun, 15 Nov 2009 03:27:51 +0100 Subject: Minor style changes in DynamicWorkspaces Ignore-this: 1a6018ab134e4420a949354575a8a110 darcs-hash:20091115022751-1499c-c2f8ccf3cada9e16a5d35e87e41baa160c74e774.gz --- XMonad/Actions/DynamicWorkspaces.hs | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'XMonad/Actions') diff --git a/XMonad/Actions/DynamicWorkspaces.hs b/XMonad/Actions/DynamicWorkspaces.hs index 032f012..c9409ad 100644 --- a/XMonad/Actions/DynamicWorkspaces.hs +++ b/XMonad/Actions/DynamicWorkspaces.hs @@ -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,13 +137,13 @@ 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 - case s of - StackSet { current = Screen { workspace = cur } - , hidden = (w:_) } - -> do when (torem==tag cur) $ windows $ view $ tag w - windows $ removeWorkspace' torem - _ -> return () +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 + windows $ removeWorkspace' torem + _ -> return () -- | Remove the current workspace after an operation if it is empty and hidden. -- Can be used to remove a workspace if it is empty when leaving it. The @@ -158,16 +155,16 @@ 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 - f - after <- getTag - when (before/=after && before `notElem` sticky) $ removeEmptyWorkspaceByTag before - where getTag = (tag.workspace.current) `fmap` gets windowset +removeEmptyWorkspaceAfterExcept sticky f = do + before <- gets (currentTag . windowset) + f + after <- gets (currentTag . windowset) + when (before/=after && before `notElem` sticky) $ removeEmptyWorkspaceByTag before isEmpty :: String -> X Bool isEmpty t = do wsl <- gets $ workspaces . windowset let mws = find (\ws -> tag ws == t) wsl - return $ maybe True (isNothing.stack) mws + return $ maybe True (isNothing . stack) mws 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 } -- cgit v1.2.3