mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
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:
parent
e88e7ee1f0
commit
957f4518b9
@ -24,8 +24,9 @@ module XMonad.Actions.RotateSome (
|
|||||||
|
|
||||||
import Control.Arrow ((***))
|
import Control.Arrow ((***))
|
||||||
import Data.List (partition, sortOn, (\\))
|
import Data.List (partition, sortOn, (\\))
|
||||||
import XMonad (Window, X, gets, runLayout, screenRect, windows, windowset)
|
import qualified Data.Map as M
|
||||||
import XMonad.StackSet (Screen (Screen), Stack (Stack), current, modify', stack)
|
import XMonad (Window, X, runLayout, screenRect, windows, withWindowSet)
|
||||||
|
import XMonad.StackSet (Screen (Screen), Stack (Stack), current, floating, modify', stack)
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
-- 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
|
windows . modify' $ reverseStack . rotateSome (`elem` ring) . reverseStack
|
||||||
|
|
||||||
surfaceRing :: X [Window]
|
surfaceRing :: X [Window]
|
||||||
surfaceRing = gets (current . windowset) >>= \(Screen wkspc _ sd) ->
|
surfaceRing = withWindowSet $ \wset -> do
|
||||||
case stack wkspc of
|
let Screen wsp _ sd = current wset
|
||||||
|
|
||||||
|
case stack wsp >>= filter' (`M.notMember` floating wset) of
|
||||||
Nothing -> pure []
|
Nothing -> pure []
|
||||||
Just st -> go st . fst <$> runLayout wkspc (screenRect sd)
|
Just st -> go st . fst <$> runLayout wsp {stack = Just st} (screenRect sd)
|
||||||
where
|
where
|
||||||
go (Stack t ls rs) recs = t : ((ls ++ rs) \\ map fst recs)
|
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
|
-- @'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
|
-- @p@ as a ring that can be rotated, while all other elements remain anchored
|
||||||
|
Loading…
x
Reference in New Issue
Block a user