From ed8463fe4365c16003901e0930c3594c4896f4b5 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Thu, 12 Nov 2009 21:13:51 +0100 Subject: 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 --- XMonad/Actions/DynamicWorkspaces.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'XMonad/Actions/DynamicWorkspaces.hs') 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 () -- cgit v1.2.3