From bc4f1660b11f3f3eed4bd7170a30f7c015da026c Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Thu, 1 Nov 2007 09:44:31 +0100 Subject: Port CycleWS darcs-hash:20071101084431-a5988-5a82fc35b25fc43e76bb0bba2a2349775924f153.gz --- CycleWS.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'CycleWS.hs') 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 -- cgit v1.2.3