contrib: fixing raiseNext stuck between 2 workspaces
I'm a big fan of raiseNext(Maybe) action from xmonad-contrib.
However, there is a quite annoying bug, reported some years ago still active:
raiseNext cycles only between 2 workspaces, making impossible to cycle through
the entire list of windows (for a full description, not by me, see
The reason is that raiseNext calls allWindows from xmonad StackSet, which
relies on a list of workspaces built as follows: the current workspace is put
first, followed by visible then hidden workspaces.
Thus the ordering of workspaces is not absolute, which is why raiseNext will
cycle only between the current and another workspace.
I found the following fix:
- create a allWindowsSorted function in Xmonad.StackSet which relies on a list
of workspaces sorted by their tags
- call W.allWindowsSorted instead of W.allWindows in raiseNext.
The patch is given below for 0.12.
Let me know if it is an appropriate way to fix the bug. If so, I can create
pull requests for xmonad and xmonad-contrib that apply on current master.
Otherwise, let me know what solution you would prefer.
It would be nice that 0.13 contains a fix.
import Prelude hiding (filter)
import Data.Maybe (listToMaybe,isJust,fromMaybe)
-import qualified Data.List as L (deleteBy,find,splitAt,filter,nub)
+import qualified Data.List as L (deleteBy,find,splitAt,filter,nub,sortBy)
import Data.List ( (\\) )
import qualified Data.Map as M (Map,insert,delete,empty)
@@ -385,6 +385,15 @@
allWindows :: Eq a => StackSet i l a s sd -> [a]
allWindows = L.nub . concatMap (integrate' . stack) . workspaces
+workspacesSorted :: Ord i => StackSet i l a s sd -> [Workspace i l a]
+workspacesSorted s = L.sortBy (\u t -> tag u `compare` tag t) $
+ workspaces s
+-- | Get a list of all windows in the 'StackSet' with an absolute ordering of
+allWindowsSorted :: Ord i => Eq a => StackSet i l a s sd -> [a]
+allWindowsSorted = L.nub . concatMap (integrate' . stack) . workspacesSorted
-- | Get the tag of the currently focused workspace.
currentTag :: StackSet i l a s sd -> i
currentTag = tag . workspace . current
diff -ur xmonad-contrib-0.12/XMonad/Actions/WindowGo.hs xmonad-
--- xmonad-contrib-0.12/XMonad/Actions/WindowGo.hs 2015-12-21
+++ xmonad-contrib-0.12.new/XMonad/Actions/WindowGo.hs 2016-11-10
@@ -43,7 +43,7 @@
import XMonad.Operations (windows)
import XMonad.Prompt.Shell (getBrowser, getEditor)
-import qualified XMonad.StackSet as W (allWindows, peek, swapMaster,
+import qualified XMonad.StackSet as W (allWindowsSorted, peek, swapMaster,
import XMonad.Util.Run (safeSpawnProg)
@@ -70,7 +70,7 @@
-- second parameter.
ifWindows :: Query Bool -> ([Window] -> X ()) -> X () -> X ()
ifWindows qry f el = withWindowSet $ \wins -> do
- matches <- filterM (runQuery qry) $ W.allWindows wins
+ matches <- filterM (runQuery qry) $ W.allWindowsSorted wins
case matches of
 -> el
ws -> f ws