From a45d8d38a6eb49983cd1fb62fe29bdeeacb38351 Mon Sep 17 00:00:00 2001 From: matthewhague Date: Tue, 3 Jul 2012 22:27:26 +0000 Subject: [PATCH] order-unindexed-ws-last Changes the WorkspaceCompare module's comparison by index to put workspaces without an index last (rather than first). --- XMonad/Util/WorkspaceCompare.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/XMonad/Util/WorkspaceCompare.hs b/XMonad/Util/WorkspaceCompare.hs index 66e401ef..88886f5f 100644 --- a/XMonad/Util/WorkspaceCompare.hs +++ b/XMonad/Util/WorkspaceCompare.hs @@ -40,12 +40,20 @@ getWsIndex = do spaces <- asks (workspaces . config) return $ flip elemIndex spaces +-- | Compare Maybe's differently, so Nothing (i.e. workspaces without indexes) +-- come last in the order +indexCompare :: Maybe Int -> Maybe Int -> Ordering +indexCompare Nothing Nothing = EQ +indexCompare Nothing (Just _) = GT +indexCompare (Just _) Nothing = LT +indexCompare a b = compare a b + -- | A comparison function for WorkspaceId, based on the index of the -- tags in the user's config. getWsCompare :: X WorkspaceCompare getWsCompare = do wsIndex <- getWsIndex - return $ mconcat [compare `on` wsIndex, compare] + return $ mconcat [indexCompare `on` wsIndex, compare] -- | A simple comparison function that orders workspaces -- lexicographically by tag.