mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Minor style changes in DynamicWorkspaces
This commit is contained in:
parent
b3329397c0
commit
4f97bc02ce
@ -124,14 +124,11 @@ addHiddenWorkspace newtag =
|
|||||||
|
|
||||||
-- | Remove the current workspace if it contains no windows.
|
-- | Remove the current workspace if it contains no windows.
|
||||||
removeEmptyWorkspace :: X ()
|
removeEmptyWorkspace :: X ()
|
||||||
removeEmptyWorkspace = do t <- (tag.workspace.current) `fmap` gets windowset
|
removeEmptyWorkspace = gets (currentTag . windowset) >>= removeEmptyWorkspaceByTag
|
||||||
removeEmptyWorkspaceByTag t
|
|
||||||
|
|
||||||
-- | Remove the current workspace.
|
-- | Remove the current workspace.
|
||||||
removeWorkspace :: X ()
|
removeWorkspace :: X ()
|
||||||
removeWorkspace = do t <- (tag.workspace.current) `fmap` gets windowset
|
removeWorkspace = gets (currentTag . windowset) >>= removeWorkspaceByTag
|
||||||
removeWorkspaceByTag t
|
|
||||||
|
|
||||||
|
|
||||||
-- | Remove workspace with specific tag if it contains no windows. Only works
|
-- | Remove workspace with specific tag if it contains no windows. Only works
|
||||||
-- on the current or the last workspace.
|
-- 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.
|
-- | Remove workspace with specific tag. Only works on the current or the last workspace.
|
||||||
removeWorkspaceByTag :: String -> X ()
|
removeWorkspaceByTag :: String -> X ()
|
||||||
removeWorkspaceByTag torem = do s <- gets windowset
|
removeWorkspaceByTag torem = do
|
||||||
case s of
|
s <- gets windowset
|
||||||
StackSet { current = Screen { workspace = cur }
|
case s of
|
||||||
, hidden = (w:_) }
|
StackSet { current = Screen { workspace = cur }, hidden = (w:_) } -> do
|
||||||
-> do when (torem==tag cur) $ windows $ view $ tag w
|
when (torem==tag cur) $ windows $ view $ tag w
|
||||||
windows $ removeWorkspace' torem
|
windows $ removeWorkspace' torem
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
-- | Remove the current workspace after an operation if it is empty and hidden.
|
-- | 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
|
-- 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,
|
-- | Like 'removeEmptyWorkspaceAfter' but use a list of sticky workspaces,
|
||||||
-- whose entries will never be removed.
|
-- whose entries will never be removed.
|
||||||
removeEmptyWorkspaceAfterExcept :: [String] -> X () -> X ()
|
removeEmptyWorkspaceAfterExcept :: [String] -> X () -> X ()
|
||||||
removeEmptyWorkspaceAfterExcept sticky f = do before <- getTag
|
removeEmptyWorkspaceAfterExcept sticky f = do
|
||||||
f
|
before <- gets (currentTag . windowset)
|
||||||
after <- getTag
|
f
|
||||||
when (before/=after && before `notElem` sticky) $ removeEmptyWorkspaceByTag before
|
after <- gets (currentTag . windowset)
|
||||||
where getTag = (tag.workspace.current) `fmap` gets windowset
|
when (before/=after && before `notElem` sticky) $ removeEmptyWorkspaceByTag before
|
||||||
|
|
||||||
isEmpty :: String -> X Bool
|
isEmpty :: String -> X Bool
|
||||||
isEmpty t = do wsl <- gets $ workspaces . windowset
|
isEmpty t = do wsl <- gets $ workspaces . windowset
|
||||||
let mws = find (\ws -> tag ws == t) wsl
|
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' :: 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 }
|
addHiddenWorkspace' newtag l s@(StackSet { hidden = ws }) = s { hidden = Workspace newtag l Nothing:ws }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user