{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}------------------------------------------------------------------------------- |-- Module : XMonad.Layout.ThreeColumns-- Copyright : (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. With 2560x1600 pixels this-- layout can be used for a huge main window and up to six reasonable sized-- slave windows.-----------------------------------------------------------------------------moduleXMonad.Layout.ThreeColumns(-- * Usage-- $usage-- * Screenshots-- $screenshotThreeCol(..))whereimportXMonadimportqualifiedXMonad.StackSetasWimportData.RatioimportControl.Monad-- $usage-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:---- > import XMonad.Layout.ThreeColumns---- Then edit your @layoutHook@ by adding the ThreeCol layout:---- > myLayout = ThreeCol 1 (3/100) (1/2) ||| ThreeColMid 1 (3/100) (1/2) ||| etc..-- > main = xmonad def { layoutHook = myLayout }---- The first argument specifies how many windows initially appear in the main-- window. The second argument argument specifies the amount to resize while-- resizing and the third 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.---- The ThreeColMid variant places the main window between the slave columns.---- For more detailed instructions on editing the layoutHook see:---- "XMonad.Doc.Extending#Editing_the_layout_hook"-- $screenshot-- <<http://server.c-otto.de/xmonad/ThreeColumnsMiddle.png>>-- | Arguments are nmaster, delta, fractiondataThreeCola=ThreeColMid{threeColNMaster::!Int,threeColDelta::!Rational,threeColFrac::!Rational}|ThreeCol{threeColNMaster::!Int,threeColDelta::!Rational,threeColFrac::!Rational}deriving(Show,Read)instanceLayoutClassThreeColawherepureLayout(ThreeColn_f)r=doLFalsenfrpureLayout(ThreeColMidn_f)r=doLTruenfrhandleMessagelm=return$msum[fmapresize(fromMessagem),fmapincmastern(fromMessagem)]whereresizeShrink=l{threeColFrac=max(-0.5)$f-d}resizeExpand=l{threeColFrac=min1$f+d}incmastern(IncMasterNx)=l{threeColNMaster=max0(n+x)}n=threeColNMasterld=threeColDeltalf=threeColFracldescription_="ThreeCol"doL::Bool->Int->Rational->Rectangle->W.Stacka->[(a,Rectangle)]doLmnfr=apzip(tile3mfrn.length).W.integrate-- | tile3. Compute window positions using 3 panestile3::Bool->Rational->Rectangle->Int->Int->[Rectangle]tile3middlefrnmastern|n<=nmaster||nmaster==0=splitVerticallynr|n<=nmaster+1=splitVerticallynmasters1++splitVertically(n-nmaster)s2|otherwise=splitVerticallynmasterr1++splitVerticallynslave1r2++splitVerticallynslave2r3where(r1,r2,r3)=split3HorizontallyBymiddle(iff<0then1+2*felsef)r(s1,s2)=splitHorizontallyBy(iff<0then1+felsef)rnslave=(n-nmaster)nslave1=ceiling(nslave%2)nslave2=(n-nmaster-nslave1)split3HorizontallyBy::Bool->Rational->Rectangle->(Rectangle,Rectangle,Rectangle)split3HorizontallyBymiddlef(Rectanglesxsyswsh)=ifmiddlethen(Rectangle(sx+fromIntegralr3w)syr1wsh,Rectangle(sx+fromIntegralr3w+fromIntegralr1w)syr2wsh,Rectanglesxsyr3wsh)else(Rectanglesxsyr1wsh,Rectangle(sx+fromIntegralr1w)syr2wsh,Rectangle(sx+fromIntegralr1w+fromIntegralr2w)syr3wsh)wherer1w=ceiling$fromIntegralsw*fr2w=ceiling((sw-r1w)%2)r3w=sw-r1w-r2w