diff options
author | Anders Engstrom <ankaan@gmail.com> | 2010-03-08 12:54:02 +0100 |
---|---|---|
committer | Anders Engstrom <ankaan@gmail.com> | 2010-03-08 12:54:02 +0100 |
commit | 5ddd58ba8b4c19f6afc06ec609ead461bf27596e (patch) | |
tree | d56fcc64bec065e42f65766d79b1d7428e51f462 /XMonad | |
parent | af5971bb82e71409b02ebe8bffeec2707b6bbf4b (diff) | |
download | XMonadContrib-5ddd58ba8b4c19f6afc06ec609ead461bf27596e.tar.gz XMonadContrib-5ddd58ba8b4c19f6afc06ec609ead461bf27596e.tar.xz XMonadContrib-5ddd58ba8b4c19f6afc06ec609ead461bf27596e.zip |
X.U.WorkspaceCompare xinerama compare with physical order
Ignore-this: 49296fb6e09717f38db28beb66bc2c80
Like the old xinerama workspace comparison, but order by physical location just like X.A.PhysicalScreens. Useful if using xinerama sort for statusbar together with physicalscreens.
darcs-hash:20100308115402-8978f-8f7dda57b5dbe898f9b23a8eb1b6b27c184648f3.gz
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Util/WorkspaceCompare.hs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/XMonad/Util/WorkspaceCompare.hs b/XMonad/Util/WorkspaceCompare.hs index b26868b..6b4ba54 100644 --- a/XMonad/Util/WorkspaceCompare.hs +++ b/XMonad/Util/WorkspaceCompare.hs @@ -8,15 +8,18 @@ -- Stability : unstable -- Portability : unportable -- +----------------------------------------------------------------------------- module XMonad.Util.WorkspaceCompare ( WorkspaceCompare, WorkspaceSort , getWsIndex , getWsCompare , getWsCompareByTag + , getXineramaPhysicalWsCompare , getXineramaWsCompare , mkWsSort , getSortByIndex , getSortByTag + , getSortByXineramaPhysicalRule , getSortByXineramaRule ) where import XMonad @@ -57,10 +60,17 @@ getWsCompareByTag = return compare -- and screen id. It produces the same ordering as -- 'XMonad.Hooks.DynamicLog.pprWindowSetXinerama'. getXineramaWsCompare :: X WorkspaceCompare -getXineramaWsCompare = do +getXineramaWsCompare = getXineramaWsCompare' False + +-- | A comparison function like 'getXineramaWsCompare', but uses physical locations for screens. +getXineramaPhysicalWsCompare :: X WorkspaceCompare +getXineramaPhysicalWsCompare = getXineramaWsCompare' True + +getXineramaWsCompare' :: Bool -> X WorkspaceCompare +getXineramaWsCompare' phy = do w <- gets windowset return $ \ a b -> case (isOnScreen a w, isOnScreen b w) of - (True, True) -> comparing (tagToSid (onScreen w)) a b + (True, True) -> cmpPosition phy w a b (False, False) -> compare a b (True, False) -> LT (False, True) -> GT @@ -68,6 +78,10 @@ getXineramaWsCompare = do onScreen w = S.current w : S.visible w isOnScreen a w = a `elem` map (S.tag . S.workspace) (onScreen w) tagToSid s x = S.screen $ fromJust $ find ((== x) . S.tag . S.workspace) s + cmpPosition False w a b = comparing (tagToSid $ onScreen w) a b + cmpPosition True w a b = comparing (rect.(tagToSid $ onScreen w)) a b + where rect i = let (Rectangle x y _ _) = screens !! fromIntegral i in (y,x) + screens = map (screenRect . S.screenDetail) $ sortBy (comparing S.screen) $ S.current w : S.visible w -- | Create a workspace sorting function from a workspace comparison -- function. @@ -92,3 +106,7 @@ getSortByTag = mkWsSort getWsCompareByTag getSortByXineramaRule :: X WorkspaceSort getSortByXineramaRule = mkWsSort getXineramaWsCompare +-- | Like 'getSortByXineramaRule', but uses physical locations for screens. +getSortByXineramaPhysicalRule :: X WorkspaceSort +getSortByXineramaPhysicalRule = mkWsSort getXineramaPhysicalWsCompare + |