aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWirt Wolff <wirtwolff@gmail.com>2011-09-08 01:27:30 +0200
committerWirt Wolff <wirtwolff@gmail.com>2011-09-08 01:27:30 +0200
commit0a47cb0401ff285829b9c5b4277b0016bfe34386 (patch)
tree4a18ae3bdaf87d78f1fcf7fb7606c4eac32d17f5
parentb8fd8eef3e2280dc94396694f01f2098f6012f93 (diff)
downloadXMonadContrib-0a47cb0401ff285829b9c5b4277b0016bfe34386.tar.gz
XMonadContrib-0a47cb0401ff285829b9c5b4277b0016bfe34386.tar.xz
XMonadContrib-0a47cb0401ff285829b9c5b4277b0016bfe34386.zip
X.A.CycleWS Refactor and add toggleWS' that excludes listed tags
Ignore-this: bec03fcb6aa16452d3a0425d156823a4 darcs-hash:20110907232730-18562-2d0bfe6371b5eca76ff65661fce3df67e1d689ee.gz
-rw-r--r--XMonad/Actions/CycleWS.hs28
1 files changed, 19 insertions, 9 deletions
diff --git a/XMonad/Actions/CycleWS.hs b/XMonad/Actions/CycleWS.hs
index 73923f6..53841ac 100644
--- a/XMonad/Actions/CycleWS.hs
+++ b/XMonad/Actions/CycleWS.hs
@@ -46,6 +46,7 @@ module XMonad.Actions.CycleWS (
-- * Toggling the previous workspace
-- $toggling
, toggleWS
+ , toggleWS'
, toggleOrView
-- * Moving between screens (xinerama)
@@ -150,9 +151,16 @@ shiftToPrev = shiftBy (-1)
-- | Toggle to the workspace displayed previously.
toggleWS :: X ()
-toggleWS = do
- hs <- gets (hidden . windowset)
- unless (null hs) (windows . view . tag $ head hs)
+toggleWS = toggleWS' []
+
+-- | Toggle to the previous workspace while excluding some workspaces.
+--
+-- > -- Ignore the scratchpad workspace while toggling:
+-- > ("M-b", toggleWS' ["NSP"])
+toggleWS' :: [WorkspaceId] -> X ()
+toggleWS' skips = do
+ hs' <- cleanHiddens skips
+ unless (null hs') (windows . view . tag $ head hs')
-- | 'XMonad.StackSet.greedyView' a workspace, or if already there, view
-- the previously displayed workspace ala weechat. Change @greedyView@ to
@@ -162,9 +170,8 @@ toggleWS = do
toggleOrView :: WorkspaceId -> X ()
toggleOrView = toggleOrDoSkip [] greedyView
--- | Allows ignoring listed workspace tags (such as scratchpad's \"NSP\") while
--- finding the previously displayed workspace, or choice of different actions,
--- like view, shift, etc. For example:
+-- | Allows ignoring listed workspace tags (such as scratchpad's \"NSP\"), and
+-- running other actions such as view, shift, etc. For example:
--
-- > import qualified XMonad.StackSet as W
-- > import XMonad.Actions.CycleWS
@@ -177,9 +184,9 @@ toggleOrView = toggleOrDoSkip [] greedyView
toggleOrDoSkip :: [WorkspaceId] -> (WorkspaceId -> WindowSet -> WindowSet)
-> WorkspaceId -> X ()
toggleOrDoSkip skips f toWS = do
- ws <- gets windowset
- let hs' = hidden ws `skipTags` skips
- if toWS == (tag . workspace $ current ws)
+ hs' <- cleanHiddens skips
+ cur <- gets (currentTag . windowset)
+ if toWS == cur
then unless (null hs') (windows . f . tag $ head hs')
else windows (f toWS)
@@ -188,6 +195,9 @@ toggleOrDoSkip skips f toWS = do
skipTags :: (Eq i) => [Workspace i l a] -> [i] -> [Workspace i l a]
skipTags wss ids = filter ((`notElem` ids) . tag) wss
+cleanHiddens :: [WorkspaceId] -> X [WindowSpace]
+cleanHiddens skips = gets $ (flip skipTags) skips . hidden . windowset
+
switchWorkspace :: Int -> X ()
switchWorkspace d = wsBy d >>= windows . greedyView