X.A.CycleRecentWS: Make unView work with greedyView as well

Entirely unnecessary for the current version of `cycleWindowSets`, but
if anyone ever wants to use `greedyView`, this shows that it's not at
all complicated to adapt `unView` to that.
This commit is contained in:
Tomas Janousek 2021-05-14 00:36:32 +01:00 committed by slotThe
parent 1e2e1273b8
commit 86522a27b0
2 changed files with 6 additions and 4 deletions

View File

@ -136,8 +136,9 @@ cycleWindowSets genOptions mods keyNext keyPrev = do
-- new 'WindowSet' may have accumulated. -- new 'WindowSet' may have accumulated.
unView :: forall i l a s sd. (Eq i, Eq s) unView :: forall i l a s sd. (Eq i, Eq s)
=> StackSet i l a s sd -> StackSet i l a s sd -> StackSet i l a s sd => StackSet i l a s sd -> StackSet i l a s sd -> StackSet i l a s sd
unView w0 = fixOrderH . fixOrderV . view (currentTag w0) unView w0 w1 = fixOrderH . fixOrderV . view' (currentTag w0) $ w1
where where
view' = if screen (current w0) == screen (current w1) then greedyView else view
fixOrderV w | v : vs <- visible w = w{ visible = insertAt (pfxV (visible w0) vs) v vs } fixOrderV w | v : vs <- visible w = w{ visible = insertAt (pfxV (visible w0) vs) v vs }
| otherwise = w | otherwise = w
fixOrderH w | h : hs <- hidden w = w{ hidden = insertAt (pfxH (hidden w0) hs) h hs } fixOrderH w | h : hs <- hidden w = w{ hidden = insertAt (pfxH (hidden w0) hs) h hs }

View File

@ -6,7 +6,7 @@ import Test.Hspec.QuickCheck
import Test.QuickCheck import Test.QuickCheck
import XMonad.Actions.CycleRecentWS (unView) import XMonad.Actions.CycleRecentWS (unView)
import XMonad.StackSet (view, mapLayout) import XMonad.StackSet (view, greedyView, mapLayout)
import Instances import Instances
import Utils (tags) import Utils (tags)
@ -17,7 +17,8 @@ spec = do
prop_unView :: T -> Property prop_unView :: T -> Property
prop_unView ss = conjoin prop_unView ss = conjoin
[ counterexample (show t) (unView ss (state (view t ss)) === state ss) [ counterexample desc (unView ss (state (v t ss)) === state ss)
| t <- tags ss ] | t <- tags ss
, (desc, v) <- [("view " <> show t, view), ("greedyView " <> show t, greedyView)] ]
where where
state = mapLayout succ state = mapLayout succ