@@ -139,7 +139,7 @@ import Control.Concurrent.MVar
139139import Control.Concurrent.STM
140140import Control.Exception
141141import Control.Lens
142- import Control.Monad ( )
142+ import Control.Monad ( mplus )
143143import Data.Foldable
144144import Data.HashMap.Strict (HashMap )
145145import qualified Data.HashMap.Strict as HashMap
@@ -1002,17 +1002,20 @@ clientExtraFocuses st =
10021002-- considered important and will be jumped to first.
10031003jumpToActivity :: ClientState -> ClientState
10041004jumpToActivity st =
1005- case locate (Nothing , minimumRank) windowList of
1005+ case locate (Nothing , minimumRank) windowList `mplus` view clientActivityReturn st of
10061006 Just focus -> changeFocus focus st
1007- Nothing ->
1008- case view clientActivityReturn st of
1009- Just focus -> changeFocus focus st
1010- Nothing -> st
1007+ Nothing -> st
10111008 where
10121009 minimumRank = (WLBoring , True ) -- windows have to be more interesting than this to qualify
10131010 maximumRank = (WLImportant , True ) -- the most interesting a window can be
10141011
1015- windowList = views clientWindows Map. toAscList st
1012+ -- Order the search such that in the case of a tie we prefer the lexicographically
1013+ -- next element in the list. This helps ensure that lexicographically small but
1014+ -- active channels don't continue to dominate the result
1015+ windowList =
1016+ case Map. split (view clientFocus st) (view clientWindows st) of
1017+ (l, r) -> Map. toAscList r <> Map. toAscList l
1018+
10161019 locate (v, _) [] = v
10171020 locate vp@ (_, vRank) ((f,w): wins)
10181021 | fRank == maximumRank = Just f -- Short circuit
0 commit comments