mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-04 14:11:54 -07:00
clean up TwoPane to work on Stacks as it ought.
This commit is contained in:
23
TwoPane.hs
23
TwoPane.hs
@@ -21,10 +21,8 @@ module XMonadContrib.TwoPane (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import Operations
|
import Operations ( Resize(..), splitHorizontallyBy )
|
||||||
import qualified StackSet as W
|
import StackSet ( focus, up, down)
|
||||||
import Control.Monad.State (gets)
|
|
||||||
|
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
--
|
--
|
||||||
@@ -37,17 +35,14 @@ import Control.Monad.State (gets)
|
|||||||
-- > twoPane defaultDelta (1%2)
|
-- > twoPane defaultDelta (1%2)
|
||||||
|
|
||||||
twoPane :: Rational -> Rational -> Layout
|
twoPane :: Rational -> Rational -> Layout
|
||||||
twoPane delta split = Layout { doLayout = \r -> arrange r . W.integrate, modifyLayout = message }
|
twoPane delta split = Layout { doLayout = \r s -> return $ arrange r s, modifyLayout = message }
|
||||||
where
|
where
|
||||||
arrange rect ws@(w:x:_) = do
|
arrange rect st = case reverse (up st) of
|
||||||
-- TODO this is buggy, it might peek another workspace
|
(master:_) -> [(master,left),(focus st,right)]
|
||||||
(Just f) <- gets (W.peek . windowset) -- safe because of pattern match above
|
[] -> case down st of
|
||||||
let y = if f == w then x else f
|
(next:_) -> [(focus st,left),(next,right)]
|
||||||
(left, right) = splitHorizontallyBy split rect
|
[] -> [(focus st, rect)]
|
||||||
mapM_ hide . filter (\a -> a /= w && a /= y) $ ws
|
where (left, right) = splitHorizontallyBy split rect
|
||||||
return [(w, left), (y, right)]
|
|
||||||
-- there are one or zero windows
|
|
||||||
arrange rect ws = return . map (\w -> (w, rect)) $ ws
|
|
||||||
|
|
||||||
message x = return $ case fromMessage x of
|
message x = return $ case fromMessage x of
|
||||||
Just Shrink -> Just (twoPane delta (split - delta))
|
Just Shrink -> Just (twoPane delta (split - delta))
|
||||||
|
Reference in New Issue
Block a user