mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
This modifies all the contrib modules to work (so far as I know) with the new contrib layout. The exception is the LayoutHooks module, which isn't used. It exports an API that is inherently unsafe, so far as I can tell (and always has been).
51 lines
1.8 KiB
Haskell
51 lines
1.8 KiB
Haskell
-----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : XMonadContrib.TwoPane
|
|
-- Copyright : (c) Spencer Janssen <sjanssen@cse.unl.edu>
|
|
-- License : BSD3-style (see LICENSE)
|
|
--
|
|
-- Maintainer : Spencer Janssen <sjanssen@cse.unl.edu>
|
|
-- Stability : unstable
|
|
-- Portability : unportable
|
|
--
|
|
-- 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 (
|
|
-- * Usage
|
|
-- $usage
|
|
twoPane
|
|
) where
|
|
|
|
import XMonad
|
|
import Operations ( Resize(..), splitHorizontallyBy )
|
|
import StackSet ( focus, up, down)
|
|
|
|
-- $usage
|
|
--
|
|
-- You can use this module with the following in your Config.hs file:
|
|
--
|
|
-- > import XMonadContrib.TwoPane
|
|
--
|
|
-- and add, to the list of layouts:
|
|
--
|
|
-- > twoPane defaultDelta (1%2)
|
|
|
|
twoPane :: Rational -> Rational -> Layout a
|
|
twoPane delta split = Layout { doLayout = \r s -> return (arrange r s,Nothing), modifyLayout = message }
|
|
where
|
|
arrange rect st = case reverse (up st) of
|
|
(master:_) -> [(master,left),(focus st,right)]
|
|
[] -> case down st of
|
|
(next:_) -> [(focus st,left),(next,right)]
|
|
[] -> [(focus st, rect)]
|
|
where (left, right) = splitHorizontallyBy split rect
|
|
|
|
message x = return $ case fromMessage x of
|
|
Just Shrink -> Just (twoPane delta (split - delta))
|
|
Just Expand -> Just (twoPane delta (split + delta))
|
|
_ -> Nothing
|