aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrent Yorgey <byorgey@cis.upenn.edu>2009-11-12 21:13:51 +0100
committerBrent Yorgey <byorgey@cis.upenn.edu>2009-11-12 21:13:51 +0100
commited8463fe4365c16003901e0930c3594c4896f4b5 (patch)
treee85048ef387f8867d8823ae65acb63a0375b8a1a
parente2ddfd99ab233b95958d4e906740064e8abc0cfb (diff)
downloadXMonadContrib-ed8463fe4365c16003901e0930c3594c4896f4b5.tar.gz
XMonadContrib-ed8463fe4365c16003901e0930c3594c4896f4b5.tar.xz
XMonadContrib-ed8463fe4365c16003901e0930c3594c4896f4b5.zip
X.A.DynamicWorkspaces: fix addWorkspace and friends so they never add another copy of an existing workspace
Ignore-this: 5bfe8129707b038ed04383b7566b2323 darcs-hash:20091112201351-1e371-ed6aeb650d2e9d6a4c131e8f7a36b922b8f1d905.gz
-rw-r--r--XMonad/Actions/DynamicWorkspaces.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/XMonad/Actions/DynamicWorkspaces.hs b/XMonad/Actions/DynamicWorkspaces.hs
index 839d8d2..f963023 100644
--- a/XMonad/Actions/DynamicWorkspaces.hs
+++ b/XMonad/Actions/DynamicWorkspaces.hs
@@ -98,18 +98,24 @@ selectWorkspace conf = workspacePrompt conf $ \w ->
then windows $ greedyView w
else addWorkspace w
--- | Add a new workspace with the given name.
+-- | Add a new workspace with the given name, or do nothing if a
+-- workspace with the given name already exists; then switch to the
+-- newly created workspace.
addWorkspace :: String -> X ()
addWorkspace newtag = addHiddenWorkspace newtag >> windows (greedyView newtag)
--- | Prompt for the name of a new workspace, and add it.
+-- | Prompt for the name of a new workspace, add it if it does not
+-- already exist, and switch to it.
addWorkspacePrompt :: XPConfig -> X ()
addWorkspacePrompt conf = mkXPrompt (Wor "New workspace name: ") conf (const (return [])) addWorkspace
--- | Add a new hidden workspace with the given name.
+-- | Add a new hidden workspace with the given name, or do nothing if
+-- a workspace with the given name already exists.
addHiddenWorkspace :: String -> X ()
-addHiddenWorkspace newtag = do l <- asks (layoutHook . config)
- windows (addHiddenWorkspace' newtag l)
+addHiddenWorkspace newtag =
+ whenX (gets (not . tagMember newtag . windowset)) $ do
+ l <- asks (layoutHook . config)
+ windows (addHiddenWorkspace' newtag l)
-- | Remove the current workspace if it contains no windows.
removeWorkspace :: X ()