surfaceNext, surfacePrev exclude floating windows

I was naively passing the workspace to runLayout without filtering out
floating windows from its stack, like XMonad.Operations.windows does.
The fact that 'windows' does this filtering explains how layouts like
those in LimitWindows continue to behave correctly in the presence of
floating windows.

This fixes some incorrect behavior where the presence of a floating
windows caused visible windows (other than the focused one) to be
included in the surfaceRing.
This commit is contained in:
ivanbrennan 2020-09-19 11:29:30 -04:00
parent e88e7ee1f0
commit 957f4518b9
No known key found for this signature in database
GPG Key ID: 79C3C47DC652EA54

View File

@ -24,8 +24,9 @@ module XMonad.Actions.RotateSome (
import Control.Arrow ((***))
import Data.List (partition, sortOn, (\\))
import XMonad (Window, X, gets, runLayout, screenRect, windows, windowset)
import XMonad.StackSet (Screen (Screen), Stack (Stack), current, modify', stack)
import qualified Data.Map as M
import XMonad (Window, X, runLayout, screenRect, windows, withWindowSet)
import XMonad.StackSet (Screen (Screen), Stack (Stack), current, floating, modify', stack)
-- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
@ -53,13 +54,21 @@ surfacePrev = do
windows . modify' $ reverseStack . rotateSome (`elem` ring) . reverseStack
surfaceRing :: X [Window]
surfaceRing = gets (current . windowset) >>= \(Screen wkspc _ sd) ->
case stack wkspc of
surfaceRing = withWindowSet $ \wset -> do
let Screen wsp _ sd = current wset
case stack wsp >>= filter' (`M.notMember` floating wset) of
Nothing -> pure []
Just st -> go st . fst <$> runLayout wkspc (screenRect sd)
Just st -> go st . fst <$> runLayout wsp {stack = Just st} (screenRect sd)
where
go (Stack t ls rs) recs = t : ((ls ++ rs) \\ map fst recs)
-- | Like "XMonad.StackSet.filter" but won't move focus.
filter' :: (a -> Bool) -> Stack a -> Maybe (Stack a)
filter' p (Stack f ls rs)
| p f = Just $ Stack f (filter p ls) (filter p rs)
| otherwise = Nothing
-- |
-- @'rotateSome' p stack@ treats the elements of @stack@ that satisfy predicate
-- @p@ as a ring that can be rotated, while all other elements remain anchored