mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
Add TwoPane
This commit is contained in:
parent
a23d995050
commit
aef12e19e6
25
TwoPane.hs
Normal file
25
TwoPane.hs
Normal file
@ -0,0 +1,25 @@
|
||||
-- A layout that splits the screen horizontally and shows two windows. The
|
||||
-- left window is always the master window, and the right is either the
|
||||
-- currently focused window or the second window in layout order.
|
||||
|
||||
module XMonadContrib.TwoPane where
|
||||
|
||||
import XMonad
|
||||
import Operations
|
||||
import qualified StackSet as W
|
||||
import Control.Monad.State (gets)
|
||||
|
||||
twoPane :: Rational -> Rational -> Layout
|
||||
twoPane delta split = Layout { doLayout = arrange, modifyLayout = message }
|
||||
where
|
||||
arrange rect (w:x:_) = do
|
||||
(Just f) <- gets (W.peek . workspace) -- safe because of pattern match above
|
||||
let (left, right) = splitHorizontallyBy split rect
|
||||
return [(w, left), (if f == w then x else f, right)]
|
||||
-- there are one or zero windows
|
||||
arrange rect ws = return . map (\w -> (w, rect)) $ ws
|
||||
|
||||
message x = case fromMessage x of
|
||||
Just Shrink -> Just (twoPane delta (split - delta))
|
||||
Just Expand -> Just (twoPane delta (split + delta))
|
||||
_ -> Nothing
|
Loading…
x
Reference in New Issue
Block a user