fix Circle/floats interaction

This commit is contained in:
Peter De Wachter 2007-08-16 18:51:44 +00:00
parent 588c5917ed
commit 405a7c6307

View File

@ -18,9 +18,10 @@ module XMonadContrib.Circle (
circle circle
) where -- actually it's an ellipse ) where -- actually it's an ellipse
import Data.List
import Graphics.X11.Xlib import Graphics.X11.Xlib
import XMonad import XMonad
import StackSet (integrate, Stack(..)) import StackSet (integrate, peek)
import XMonadContrib.LayoutHelpers ( idModify ) import XMonadContrib.LayoutHelpers ( idModify )
@ -29,9 +30,10 @@ import XMonadContrib.LayoutHelpers ( idModify )
-- --
-- > import XMonadContrib.Circle -- > import XMonadContrib.Circle
circle :: Layout a circle :: Layout Window
circle = Layout { doLayout = \r s -> return (raise (length (up s)) . circleLayout r $ integrate s, Nothing), circle = Layout { doLayout = \r s -> do { layout <- raiseFocus $ circleLayout r $ integrate s
modifyLayout = idModify } ; return (layout, Nothing) }
, modifyLayout = idModify }
circleLayout :: Rectangle -> [a] -> [(a, Rectangle)] circleLayout :: Rectangle -> [a] -> [(a, Rectangle)]
circleLayout _ [] = [] circleLayout _ [] = []
@ -39,8 +41,11 @@ circleLayout r (w:ws) = master : rest
where master = (w, center r) where master = (w, center r)
rest = zip ws $ map (satellite r) [0, pi * 2 / fromIntegral (length ws) ..] rest = zip ws $ map (satellite r) [0, pi * 2 / fromIntegral (length ws) ..]
raise :: Int -> [a] -> [a] raiseFocus :: [(Window, Rectangle)] -> X [(Window, Rectangle)]
raise n xs = xs !! n : take n xs ++ drop (n + 1) xs raiseFocus xs = do focused <- withWindowSet (return . peek)
return $ case find ((== focused) . Just . fst) xs of
Just x -> x : delete x xs
Nothing -> xs
center :: Rectangle -> Rectangle center :: Rectangle -> Rectangle
center (Rectangle sx sy sw sh) = Rectangle x y w h center (Rectangle sx sy sw sh) = Rectangle x y w h