Skip to content

Commit 501fbec

Browse files
committed
Jump forward to next activity
1 parent 29a0e08 commit 501fbec

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Client/State.hs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ import Control.Concurrent.MVar
139139
import Control.Concurrent.STM
140140
import Control.Exception
141141
import Control.Lens
142-
import Control.Monad()
142+
import Control.Monad (mplus)
143143
import Data.Foldable
144144
import Data.HashMap.Strict (HashMap)
145145
import qualified Data.HashMap.Strict as HashMap
@@ -1002,17 +1002,20 @@ clientExtraFocuses st =
10021002
-- considered important and will be jumped to first.
10031003
jumpToActivity :: ClientState -> ClientState
10041004
jumpToActivity 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

Comments
 (0)