mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-06 15:01:53 -07:00
X.L.ThreeColumnsMiddle merged into X.L.ThreeColumns with some new features
This commit is contained in:
@@ -10,7 +10,11 @@
|
|||||||
-- Stability : unstable
|
-- Stability : unstable
|
||||||
-- Portability : unportable
|
-- Portability : unportable
|
||||||
--
|
--
|
||||||
-- A layout similar to tall but with three columns.
|
-- A layout similar to tall but with three columns. With 2560x1600 pixels this
|
||||||
|
-- layout can be used for a huge main window and up to six reasonable sized
|
||||||
|
-- slave windows.
|
||||||
|
--
|
||||||
|
-- Screenshot: <http://server.c-otto.de/xmonad/ThreeColumnsMiddle.png>
|
||||||
--
|
--
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -34,44 +38,57 @@ import Control.Monad
|
|||||||
--
|
--
|
||||||
-- Then edit your @layoutHook@ by adding the ThreeCol layout:
|
-- Then edit your @layoutHook@ by adding the ThreeCol layout:
|
||||||
--
|
--
|
||||||
-- > myLayouts = ThreeCol 1 (3/100) (1/2) ||| etc..
|
-- > myLayouts = ThreeCol False 1 (3/100) (1/2) ||| etc..
|
||||||
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
|
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
|
||||||
--
|
--
|
||||||
|
-- If the first argument is true, the main window is placed in the center
|
||||||
|
-- column. The second argument specifies hom many windows initially appear in
|
||||||
|
-- the main window. The third argument argument specifies the amount to resize
|
||||||
|
-- while resizing and the fourth argument specifies the initial size of the
|
||||||
|
-- columns. A positive size designates the fraction of the screen that the main
|
||||||
|
-- window should occupy, but if the size is negative the absolute value
|
||||||
|
-- designates the fraction a slave column should occupy. If both slave columns
|
||||||
|
-- are visible, they always occupy the same amount of space.
|
||||||
|
--
|
||||||
-- For more detailed instructions on editing the layoutHook see:
|
-- For more detailed instructions on editing the layoutHook see:
|
||||||
--
|
--
|
||||||
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
|
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
|
||||||
|
|
||||||
data ThreeCol a = ThreeCol !Int !Rational !Rational deriving (Show,Read)
|
data ThreeCol a = ThreeCol !Bool !Int !Rational !Rational deriving (Show,Read)
|
||||||
|
|
||||||
instance LayoutClass ThreeCol a where
|
instance LayoutClass ThreeCol a where
|
||||||
doLayout (ThreeCol nmaster _ frac) r =
|
doLayout (ThreeCol middle nmaster _ frac) r =
|
||||||
return . (\x->(x,Nothing)) .
|
return . (\x->(x,Nothing)) .
|
||||||
ap zip (tile3 frac r nmaster . length) . W.integrate
|
ap zip (tile3 middle frac r nmaster . length) . W.integrate
|
||||||
handleMessage (ThreeCol nmaster delta frac) m =
|
handleMessage (ThreeCol middle nmaster delta frac) m =
|
||||||
return $ msum [fmap resize (fromMessage m)
|
return $ msum [fmap resize (fromMessage m)
|
||||||
,fmap incmastern (fromMessage m)]
|
,fmap incmastern (fromMessage m)]
|
||||||
where resize Shrink = ThreeCol nmaster delta (max 0 $ frac-delta)
|
where resize Shrink = ThreeCol middle nmaster delta (max (-0.5) $ frac-delta)
|
||||||
resize Expand = ThreeCol nmaster delta (min 1 $ frac+delta)
|
resize Expand = ThreeCol middle nmaster delta (min 1 $ frac+delta)
|
||||||
incmastern (IncMasterN d) = ThreeCol (max 0 (nmaster+d)) delta frac
|
incmastern (IncMasterN d) = ThreeCol middle (max 0 (nmaster+d)) delta frac
|
||||||
description _ = "ThreeCol"
|
description _ = "ThreeCol"
|
||||||
|
|
||||||
-- | tile3. Compute window positions using 3 panes
|
-- | tile3. Compute window positions using 3 panes
|
||||||
tile3 :: Rational -> Rectangle -> Int -> Int -> [Rectangle]
|
tile3 :: Bool -> Rational -> Rectangle -> Int -> Int -> [Rectangle]
|
||||||
tile3 f r nmaster n
|
tile3 middle f r nmaster n
|
||||||
| n <= nmaster || nmaster == 0 = splitVertically n r
|
| n <= nmaster || nmaster == 0 = splitVertically n r
|
||||||
| n <= nmaster+1 = splitVertically nmaster s1 ++ splitVertically (n-nmaster) s2
|
| n <= nmaster+1 = splitVertically nmaster s1 ++ splitVertically (n-nmaster) s2
|
||||||
| otherwise = splitVertically nmaster r1 ++ splitVertically nmid r2 ++ splitVertically nright r3
|
| otherwise = splitVertically nmaster r1 ++ splitVertically nslave1 r2 ++ splitVertically nslave2 r3
|
||||||
where (r1, r2, r3) = split3HorizontallyBy f r
|
where (r1, r2, r3) = split3HorizontallyBy middle (if f<0 then 1+2*f else f) r
|
||||||
(s1, s2) = splitHorizontallyBy f r
|
(s1, s2) = splitHorizontallyBy (if f<0 then 1+f else f) r
|
||||||
nslave = (n - nmaster)
|
nslave = (n - nmaster)
|
||||||
nmid = ceiling (nslave % 2)
|
nslave1 = ceiling (nslave % 2)
|
||||||
nright = (n - nmaster - nmid)
|
nslave2 = (n - nmaster - nslave1)
|
||||||
|
|
||||||
split3HorizontallyBy :: Rational -> Rectangle -> (Rectangle, Rectangle, Rectangle)
|
split3HorizontallyBy :: Bool -> Rational -> Rectangle -> (Rectangle, Rectangle, Rectangle)
|
||||||
split3HorizontallyBy f (Rectangle sx sy sw sh) =
|
split3HorizontallyBy middle f (Rectangle sx sy sw sh) =
|
||||||
( Rectangle sx sy leftw sh
|
if middle
|
||||||
, Rectangle (sx + fromIntegral leftw) sy midw sh
|
then ( Rectangle (sx + fromIntegral r2w) sy r1w sh
|
||||||
, Rectangle (sx + fromIntegral leftw + fromIntegral midw) sy rightw sh )
|
, Rectangle sx sy r2w sh
|
||||||
where leftw = ceiling $ fromIntegral sw * (2/3) * f
|
, Rectangle (sx + fromIntegral r2w + fromIntegral r1w) sy r3w sh )
|
||||||
midw = ceiling ( (sw - leftw) % 2 )
|
else ( Rectangle sx sy r1w sh
|
||||||
rightw = sw - leftw - midw
|
, Rectangle (sx + fromIntegral r1w) sy r2w sh
|
||||||
|
, Rectangle (sx + fromIntegral r1w + fromIntegral r2w) sy r3w sh )
|
||||||
|
where r1w = ceiling $ fromIntegral sw * f
|
||||||
|
r2w = ceiling ( (sw - r1w) % 2 )
|
||||||
|
r3w = sw - r1w - r2w
|
||||||
|
@@ -1,92 +0,0 @@
|
|||||||
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
-- |
|
|
||||||
-- Module : XMonad.Layout.ThreeColumnsMiddle
|
|
||||||
-- Copyright : (c) Carsten Otto <xmonad@c-otto.de>,
|
|
||||||
-- based on ThreeColumns (c) Kai Grossjohann <kai@emptydomain.de>
|
|
||||||
-- License : BSD3-style (see LICENSE)
|
|
||||||
--
|
|
||||||
-- Maintainer : ?
|
|
||||||
-- Stability : unstable
|
|
||||||
-- Portability : unportable
|
|
||||||
--
|
|
||||||
-- A layout similar to tall but with three columns, where the main window is
|
|
||||||
-- in the middle. With 2560x1600 pixels this layout can be used for a huge
|
|
||||||
-- main window and up to six reasonable sized slave windows.
|
|
||||||
--
|
|
||||||
-- > Screenshot: http://server.c-otto.de/xmonad/ThreeColumnsMiddle.png
|
|
||||||
--
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
module XMonad.Layout.ThreeColumnsMiddle (
|
|
||||||
-- * Usage
|
|
||||||
-- $usage
|
|
||||||
ThreeColMid(..)
|
|
||||||
) where
|
|
||||||
|
|
||||||
import XMonad
|
|
||||||
import qualified XMonad.StackSet as W
|
|
||||||
|
|
||||||
import Data.Ratio
|
|
||||||
|
|
||||||
import Control.Monad
|
|
||||||
|
|
||||||
-- $usage
|
|
||||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
|
||||||
--
|
|
||||||
-- > import XMonad.Layout.ThreeColumnsMiddle
|
|
||||||
--
|
|
||||||
-- Then edit your @layoutHook@ by adding the ThreeColMid layout:
|
|
||||||
--
|
|
||||||
-- > myLayouts = ThreeColMid 1 (3/100) (1/2) ||| etc..
|
|
||||||
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
|
|
||||||
--
|
|
||||||
-- The first argument specifies how many windows appear in the main window.
|
|
||||||
-- The second argument specifies how much the main window size changes when resizing.
|
|
||||||
-- The third argument specifies the initial size of the main window as a fraction of
|
|
||||||
-- total screen size.
|
|
||||||
--
|
|
||||||
-- For more detailed instructions on editing the layoutHook see:
|
|
||||||
--
|
|
||||||
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
|
|
||||||
|
|
||||||
data ThreeColMid a = ThreeColMid !Int !Rational !Rational deriving (Show,Read)
|
|
||||||
|
|
||||||
instance LayoutClass ThreeColMid a where
|
|
||||||
doLayout (ThreeColMid nmaster _ frac) r =
|
|
||||||
return . (\x->(x,Nothing)) .
|
|
||||||
ap zip (tile3 frac r nmaster . length) . W.integrate
|
|
||||||
handleMessage (ThreeColMid nmaster delta frac) m =
|
|
||||||
return $ msum [fmap resize (fromMessage m)
|
|
||||||
,fmap incmastern (fromMessage m)]
|
|
||||||
where resize Shrink = ThreeColMid nmaster delta (max 0 $ frac-delta)
|
|
||||||
resize Expand = ThreeColMid nmaster delta (min 1 $ frac+delta)
|
|
||||||
incmastern (IncMasterN d) = ThreeColMid (max 0 (nmaster+d)) delta frac
|
|
||||||
description _ = "ThreeColMid"
|
|
||||||
|
|
||||||
-- | tile3. Compute window positions using 3 panes
|
|
||||||
tile3 :: Rational -> Rectangle -> Int -> Int -> [Rectangle]
|
|
||||||
tile3 f r nmaster n
|
|
||||||
-- split horizontally, if there are very few windows (only the main screen is used)
|
|
||||||
| n <= nmaster || nmaster == 0 = splitHorizontally n r
|
|
||||||
|
|
||||||
-- one window more than the master window can hold (the additional window is shown right of the main screen)
|
|
||||||
| n == nmaster+1 = splitVertically nmaster s1 ++ splitVertically (n-nmaster) s2
|
|
||||||
|
|
||||||
-- many windows (the main windows are shown in the center, all other windows are shown left and right of it)
|
|
||||||
| otherwise = splitVertically nmaster r1 ++ splitVertically nleft r2 ++ splitVertically nright r3
|
|
||||||
where (r1, r2, r3) = split3HorizontallyBy f r
|
|
||||||
(s1, s2) = splitHorizontallyBy f r
|
|
||||||
nslave = (n - nmaster)
|
|
||||||
nleft = ceiling (nslave % 2)
|
|
||||||
nright = (n - nmaster - nleft)
|
|
||||||
|
|
||||||
split3HorizontallyBy :: Rational -> Rectangle -> (Rectangle, Rectangle, Rectangle)
|
|
||||||
split3HorizontallyBy f (Rectangle sx sy sw sh) =
|
|
||||||
( Rectangle (sx + fromIntegral leftw) sy midw sh
|
|
||||||
, Rectangle sx sy leftw sh
|
|
||||||
, Rectangle (sx + fromIntegral leftw + fromIntegral midw) sy rightw sh )
|
|
||||||
where midw = ceiling $ fromIntegral sw * f
|
|
||||||
leftw = ceiling ( (sw - midw) % 2 )
|
|
||||||
rightw = sw - leftw - midw
|
|
@@ -179,7 +179,6 @@ library
|
|||||||
XMonad.Layout.Tabbed
|
XMonad.Layout.Tabbed
|
||||||
XMonad.Layout.TabBarDecoration
|
XMonad.Layout.TabBarDecoration
|
||||||
XMonad.Layout.ThreeColumns
|
XMonad.Layout.ThreeColumns
|
||||||
XMonad.Layout.ThreeColumnsMiddle
|
|
||||||
XMonad.Layout.ToggleLayouts
|
XMonad.Layout.ToggleLayouts
|
||||||
XMonad.Layout.TwoPane
|
XMonad.Layout.TwoPane
|
||||||
XMonad.Layout.WindowArranger
|
XMonad.Layout.WindowArranger
|
||||||
|
Reference in New Issue
Block a user