aboutsummaryrefslogtreecommitdiffstats
path: root/CycleWS.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 09:44:31 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 09:44:31 +0100
commitbc4f1660b11f3f3eed4bd7170a30f7c015da026c (patch)
tree7cffda729c41d6e1ffccd4d5ababab04f5766928 /CycleWS.hs
parentec681dcb8e6b5ff5d120cee8d9f1574e4dc09eea (diff)
downloadXMonadContrib-bc4f1660b11f3f3eed4bd7170a30f7c015da026c.tar.gz
XMonadContrib-bc4f1660b11f3f3eed4bd7170a30f7c015da026c.tar.xz
XMonadContrib-bc4f1660b11f3f3eed4bd7170a30f7c015da026c.zip
Port CycleWS
darcs-hash:20071101084431-a5988-5a82fc35b25fc43e76bb0bba2a2349775924f153.gz
Diffstat (limited to 'CycleWS.hs')
-rw-r--r--CycleWS.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/CycleWS.hs b/CycleWS.hs
index dab5b04..2f57f91 100644
--- a/CycleWS.hs
+++ b/CycleWS.hs
@@ -24,15 +24,16 @@ module XMonadContrib.CycleWS (
toggleWS,
) where
+import Control.Monad.Reader ( asks )
import Control.Monad.State ( gets )
import Data.List ( sortBy, findIndex )
import Data.Maybe ( fromMaybe )
import Data.Ord ( comparing )
-import XMonad
+import XMonad hiding (workspaces)
+import qualified XMonad (workspaces)
import StackSet hiding (filter)
import Operations
-import {-# SOURCE #-} qualified Config (workspaces)
-- $usage
-- You can use this module with the following in your Config.hs file:
@@ -88,13 +89,14 @@ shiftBy d = wsBy d >>= windows . shift
wsBy :: Int -> X (WorkspaceId)
wsBy d = do
ws <- gets windowset
- let orderedWs = sortBy (comparing wsIndex) (workspaces ws)
+ spaces <- asks (XMonad.workspaces . config)
+ let orderedWs = sortBy (comparing (wsIndex spaces)) (workspaces ws)
let now = fromMaybe 0 $ findWsIndex (workspace (current ws)) orderedWs
let next = orderedWs !! ((now + d) `mod` length orderedWs)
return $ tag next
-wsIndex :: WindowSpace -> Maybe Int
-wsIndex ws = findIndex (== tag ws) Config.workspaces
+wsIndex :: [WorkspaceId] -> WindowSpace -> Maybe Int
+wsIndex spaces ws = findIndex (== tag ws) spaces
findWsIndex :: WindowSpace -> [WindowSpace] -> Maybe Int
findWsIndex ws wss = findIndex ((== tag ws) . tag) wss