[xmonad] Xinerama workspace sorting for dynamicLogWithPP

Juraj Hercek juhe_xmonad at hck.sk
Wed Jan 9 11:05:33 EST 2008


Attached is a darcs patch useful mainly for users using xinerama 
(multiple screens). It adds xinerama sorting algorithm for sorting 
workspace identifiers done in dynamicLogWithPP. After applying the 
patch, you need to modify your PP in xmonad.hs, e.g:

myPP = defaultPP {
                 -- your previous PP settings
                 , ppSort = getSortByXineramaRule

-------------- next part --------------

New patches:

[Extended PP with sorting algorithm specification and added xinerama sorting
Juraj Hercek <juhe_xmonad at hck.sk>**20080109154923
   - idea is to specify sorting algorithm from user's xmonad.hs
   - xinerama sorting algorithm produces same ordering as
   - default ppSort is set to getSortByTag, so the default functionality
     is the same as it was before
] {
hunk ./XMonad/Hooks/DynamicLog.hs 111
-    sort' <- getSortByTag
+    sort' <- ppSort pp
hunk ./XMonad/Hooks/DynamicLog.hs 203
+             , ppSort :: X ([WindowSpace] -> [WindowSpace])
hunk ./XMonad/Hooks/DynamicLog.hs 219
+               , ppSort            = getSortByTag
hunk ./XMonad/Util/WorkspaceCompare.hs 12
-module XMonad.Util.WorkspaceCompare ( getWsIndex, getWsCompare, getSortByTag ) where
+module XMonad.Util.WorkspaceCompare ( getWsIndex
+                                    , getWsCompare
+                                    , getSortByTag
+                                    , getSortByXineramaRule ) where
hunk ./XMonad/Util/WorkspaceCompare.hs 21
+import Data.Ord
+import Data.Maybe
hunk ./XMonad/Util/WorkspaceCompare.hs 36
- where
-   f Nothing Nothing   = EQ
-   f (Just _) Nothing  = LT
-   f Nothing (Just _)  = GT
-   f (Just x) (Just y) = compare x y
+  where
+    f Nothing Nothing   = EQ
+    f (Just _) Nothing  = LT
+    f Nothing (Just _)  = GT
+    f (Just x) (Just y) = compare x y
+-- | A comparison function for Xinerama based on visibility, workspace and
+-- screen id. It produces same ordering as pprWindowSetXinerama does.
+getXineramaWsCompare :: X(WorkspaceId -> WorkspaceId -> Ordering)
+getXineramaWsCompare = do
+    w <- gets windowset
+    return $ \ a b -> case (isOnScreen a w, isOnScreen b w) of
+        (True, True)   -> comparing (tagToSid (onScreen w)) a b
+        (False, False) -> compare a b
+        (True, False)  -> LT
+        (False, True)  -> GT
+  where
+    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
+                 --S.screen $ head $ filter ((== x) . S.tag . S.workspace) s
hunk ./XMonad/Util/WorkspaceCompare.hs 64
+-- | Sort serveral workspaces for xinerama displays
+getSortByXineramaRule :: X ([WindowSpace] -> [WindowSpace])
+getSortByXineramaRule = do
+    cmp <- getXineramaWsCompare
+    return $ sortBy (\a b -> cmp (S.tag a) (S.tag b))


[Correct caps in module header.
Joachim Fasting <joachim.fasting at gmail.com>**20071230061920] 
[Use LANGUAGE pragma.
Joachim Fasting <joachim.fasting at gmail.com>**20071230061817] 
[shiftPrevScreen and shiftNextScreen, to make CycleWS consistent
mail at joachim-breitner.de**20071231171609] 
Don Stewart <dons at galois.com>**20071204174920] 
[PerWorkspace.hs: add an explanatory note
Brent Yorgey <byorgey at gmail.com>**20071231135806] 
[Add ShowWName a layout modifier to show the workspace name
Andrea Rossato <andrea.rossato at unibz.it>**20071231130441
 This module requires dzen
[ManageDocks: some documentation fixes
Andrea Rossato <andrea.rossato at unibz.it>**20071231101820] 
[-Wall police (again)
Spencer Janssen <sjanssen at cse.unl.edu>**20071228061841] 
[-Wall police
Spencer Janssen <sjanssen at cse.unl.edu>**20071228061822] 
[Fulfill the EWMH specification by listing the supported ATOMs, doesnt really make a differene AFAIK
mail at joachim-breitner.de**20071227215607] 
[display all visible windows on the current desktop in the pager
mail at joachim-breitner.de**20071227204349
 This is my best shot at modeling xmonad’s WM behaviour in a way that
 the Extended Window Manager Hints specification allows.
 Unfortunately, we can not tell the panel what size and position it should
 think the apps are.
[Although I do not need the curr variable after all, this is nicer
mail at joachim-breitner.de**20071227190113] 
[Add support for cycling through screens to CycleWS
mail at joachim-breitner.de**20071227182635] 
[Clear _NET_ACTIVE_WINDOW when nothing is focused
mail at joachim-breitner.de**20071228154222] 
[textExtentsXMF doesn't require the display
Andrea Rossato <andrea.rossato at unibz.it>**20071228125913] 
[Don't bother checking executable bits of items in $PATH, yields a significant speed-up
Spencer Janssen <sjanssen at cse.unl.edu>**20071226032412] 
[ResizableTile.hs: fix resizing to work in the presence of floating windows (resolves issue #100)
Brent Yorgey <byorgey at gmail.com>**20071225135839] 
[LayoutScreens: haddock fixes
Andrea Rossato <andrea.rossato at unibz.it>**20071225105316] 
[XMonad.Actions.Search: haddock fix
Andrea Rossato <andrea.rossato at unibz.it>**20071224171115] 
[Fix isssue 105
Andrea Rossato <andrea.rossato at unibz.it>**20071224171020
 issue 105 was due to the fact that tab windows created when
 bootstrapping the windowset after a restart where managed. Setting the
 override_redirect attributes to True fixes the issue.
 Added the possibility to set the override_redirect attribute with
[Prompt.hs: mv .xmonad_history into .xmonad/
gwern0 at gmail.com**20071224054610
 See my email to mailing list. This will slightly break anyone who upgrades while running and expects to see their prompt history, and leave a stray file, I think, but nothing else, and it'll permanently improve tab-completion, and is tidier.
[Search.hs: +docs, and export simpleEngine so users can define their own
gwern0 at gmail.com**20071224043828] 
[Search.hs: mv into Actions/ per IRC suggestion
gwern0 at gmail.com**20071224043735] 
[add XMonad.Actions.NoBorders
Lukas Mai <l.mai at web.de>**20071220203953] 
[AvoidStruts: add support for partial struts
Spencer Janssen <sjanssen at cse.unl.edu>**20071222133425] 
[Search.hs: add hoogle
Brent Yorgey <byorgey at gmail.com>**20071222184912] 
[ManageDocks: ignore desktop windows also
Spencer Janssen <sjanssen at cse.unl.edu>**20071222113808] 
Spencer Janssen <sjanssen at cse.unl.edu>**20071222110641] 
[EwmhDesktops: add _NET_ACTIVE_WINDOW support
Spencer Janssen <sjanssen at cse.unl.edu>**20071222110552] 
[A few short comments for WorkspaceCompare
Spencer Janssen <sjanssen at cse.unl.edu>**20071222105045] 
[EwmhDesktops: drop 'Workspace' from displayed workspace names
Spencer Janssen <sjanssen at cse.unl.edu>**20071222104559] 
[Factor workspace sorting into a separate module
Spencer Janssen <sjanssen at cse.unl.edu>**20071222104114] 
[No more tabs
Spencer Janssen <sjanssen at cse.unl.edu>**20071222050439] 
[Refactor Search.hs
Spencer Janssen <sjanssen at cse.unl.edu>**20071222044714] 
[Generalize XSelection functions to MonadIO
Spencer Janssen <sjanssen at cse.unl.edu>**20071222044514] 
[Search.hs: +imdb & amazon engines for unk_red
gwern0 at gmail.com**20071222035837] 
[Search.hs: cleanup and refactor
gwern0 at gmail.com**20071220174001] 
[Update various restart bindings
Spencer Janssen <sjanssen at cse.unl.edu>**20071219220634] 
[Fix typo.
Roman Cheplyaka <roma at ro-che.info>**20071219073857] 
[Doc/Developing.hs: add some information about Haddock documentation.
Brent Yorgey <byorgey at gmail.com>**20071219215300] 
[require haddock documentation to build successfully in order to record a patch.
Brent Yorgey <byorgey at gmail.com>**20071219215217] 
[Remove inaccurate comment about 'banish'
Spencer Janssen <sjanssen at cse.unl.edu>**20071217231540] 
[Warp.hs: haddock fixes
Brent Yorgey <byorgey at gmail.com>**20071217224712] 
[Warp.hs: +doc
gwern0 at gmail.com**20071216030015
 Describe how to emulate Ratpoison's 'banish' functionality on one's config
[Util/Search.hs: a few updates/fixes
Brent Yorgey <byorgey at gmail.com>**20071217222930
   * fix shadowing warning (ghc 6.8.2 complains)
   * export a few more of the functions
   * re-de-obfuscate generated URLs by not escaping alphanumerics or punct.
[Util.Search: import escapeURIString, and fall back on the ugly const false hack to avoid copy-pasting even more
gwern0 at gmail.com**20071215211638] 
[update Config.Droundy to use a few nice hooks.
David Roundy <droundy at darcs.net>**20071216185653] 
[Add UrgencyHook support to Tabbed
Shachaf Ben-Kiki <shachaf at gmail.com>**20071215171617] 
[DynamicLog.hs: some documentation updates.
Brent Yorgey <byorgey at gmail.com>**20071215143727] 
[DynamicLog.hs: fix shadowing warning
Brent Yorgey <byorgey at gmail.com>**20071215143227] 
[Add UrgencyHook support to DynamicLog
Shachaf Ben-Kiki <shachaf at gmail.com>**20071214043528
 Someone with Xinerama should look at this -- I don't know exactly how that
 should behave.
[Depend on X11-1.4.1, it has crucial bugfixes
Spencer Janssen <sjanssen at cse.unl.edu>**20071215022151] 
[Remove network dependency, potentially breaking XMonad.Util.Search
Spencer Janssen <sjanssen at cse.unl.edu>**20071214231859] 
[Search.hs: fix shadowing warning and haddock errors
Brent Yorgey <byorgey at gmail.com>**20071214163119] 
[+cabal support for XMonad.Util.Search
gwern0 at gmail.com**20071213205654] 
[+XMonad.Util.Search: new module
gwern0 at gmail.com**20071213205159
 This module is intended to provide helpful functions for easily running web searchs; just hit a bound key, enter your query, and up opens a new tab/browser/window with the search results. In theory anyway; the Wikipedia and Google ones work fine for me, but the Internet Archive's docs on how to do don't necessarily seem to be correct. If you were, like me, previously running shell commands to call Surfraw or similar shell scripts to do the same thing, you can now scrap them and replace them.
 There aren't too many search engines defined here; new ones would be good, and they're easy to add!
[Add support for _NET_WM_STRUT_PARTIAL
Spencer Janssen <sjanssen at cse.unl.edu>**20071213021704] 
[ManageDocks: when there are struts on opposing edges, the right/bottom strut
Spencer Janssen <sjanssen at cse.unl.edu>**20071210021030
 was ignored.  TODO: quickchecks
[Run.hs: fix documentation, cleanup whitespace
"Valery V. Vorotyntsev" <valery.vv at gmail.com>**20071212091516] 
[Man.hs: input speedup
"Valery V. Vorotyntsev" <valery.vv at gmail.com>**20071212090256
 Descend manpage directories once -- when `manPrompt' is called.
 (Previous version used to search directories upon each character
[new XMonad.Hooks.ManageHelpers module
Lukas Mai <l.mai at web.de>**20071211183040] 
[Magnifier: custom zoom ratio for magnifier' too
intrigeri at boum.org**20071211015554] 
[Magnifier.hs: minor haddock fixes
Brent Yorgey <byorgey at gmail.com>**20071211011154] 
[fix haddock on Magnifier
tim.thelion at gmail.com**20071210231942] 
[Custom zoom levels for magnifier
tim.thelion at gmail.com**20071208230844] 
[TAG 0.5
Spencer Janssen <sjanssen at cse.unl.edu>**20071209233056] 
Patch bundle hash:

More information about the xmonad mailing list