From 656c004bd143fd354667f8f1d2e8786d5cbb4b96 Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Sat, 22 Dec 2007 11:41:14 +0100 Subject: Factor workspace sorting into a separate module darcs-hash:20071222104114-a5988-bfd9059d0556a526c275b6d0e4a930103bd7d990.gz --- XMonad/Actions/CycleWS.hs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'XMonad/Actions/CycleWS.hs') diff --git a/XMonad/Actions/CycleWS.hs b/XMonad/Actions/CycleWS.hs index f64f2fb..6e4e822 100644 --- a/XMonad/Actions/CycleWS.hs +++ b/XMonad/Actions/CycleWS.hs @@ -24,13 +24,12 @@ module XMonad.Actions.CycleWS ( toggleWS, ) where -import Data.List ( sortBy, findIndex ) +import Data.List ( findIndex ) import Data.Maybe ( fromMaybe ) -import Data.Ord ( comparing ) import XMonad hiding (workspaces) -import qualified XMonad (workspaces) import XMonad.StackSet hiding (filter) +import XMonad.Util.WorkspaceCompare -- $usage -- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: @@ -81,14 +80,11 @@ shiftBy d = wsBy d >>= windows . shift wsBy :: Int -> X (WorkspaceId) wsBy d = do ws <- gets windowset - spaces <- asks (XMonad.workspaces . config) - let orderedWs = sortBy (comparing (wsIndex spaces)) (workspaces ws) + sort' <- getSortByTag + let orderedWs = sort' (workspaces ws) let now = fromMaybe 0 $ findWsIndex (workspace (current ws)) orderedWs let next = orderedWs !! ((now + d) `mod` length orderedWs) return $ tag next -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