{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeSynonymInstances, FlexibleContexts, PatternGuards #-}------------------------------------------------------------------------------- |-- Module : XMonad.Layout.Master-- Copyright : (c) Ismael Carnales, Lukas Mai-- License : BSD-style (see LICENSE)---- Maintainer : Ismael Carnales <icarnales@gmail.com>-- Stability : unstable-- Portability : unportable---- Layout modfier that adds a master window to another layout.-----------------------------------------------------------------------------moduleXMonad.Layout.Master(-- * Usage-- $usagemastered)whereimportXMonadimportqualifiedXMonad.StackSetasSimportXMonad.Layout.LayoutModifier-- $usage-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:---- > import XMonad.Layout.Master---- Then edit your @layoutHook@ and add the Master modifier to the layout that-- you prefer.---- > mastered (1/100) (1/2) $ Grid---- This will use the left half of your screen for a master window and let-- Grid manage the right half.---- For more detailed instructions on editing the layoutHook see-- "XMonad.Doc.Extending#Editing_the_layout_hook".---- Like 'XMonad.Layout.Tall', 'withMaster' supports the-- 'XMonad.Layout.Shrink' and XMonad.Layout.Expand' messages.-- | Data type for LayoutModifier which converts given layout to a mastered-- layoutdataAddMastera=AddMasterRationalRationalderiving(Show,Read)-- | Modifier which converts given layout to a mastered onemastered::(LayoutClassla)=>Rational-- ^ @delta@, the ratio of the screen to resize by->Rational-- ^ @frac@, what portion of the screen to use for the master window->la-- ^ the layout to be modified->ModifiedLayoutAddMasterlamastereddeltafrac=ModifiedLayout$AddMasterdeltafracinstanceLayoutModifierAddMasterWindowwheremodifyLayout(AddMasterdeltafrac)=applyMasterdeltafracmodifierDescription_="Mastered"pureMess(AddMasterdeltafrac)m|JustShrink<-fromMessagem=Just$AddMasterdelta(frac-delta)|JustExpand<-fromMessagem=Just$AddMasterdelta(frac+delta)pureMess__=Nothing-- | Internal function for adding a master window and let the modified-- layout handle the rest of the windowsapplyMaster::(LayoutClasslWindow)=>Rational->Rational->S.WorkspaceWorkspaceId(lWindow)Window->Rectangle->X([(Window,Rectangle)],Maybe(lWindow))applyMaster_fracwksprect=doletst=S.stackwkspletws=S.integrate'$stiflengthws>1thendoletm=headwslet(mr,sr)=splitHorizontallyByfracrectletnst=st>>=S.filter(m/=)wrs<-runLayout(wksp{S.stack=nst})srreturn((m,mr):fstwrs,sndwrs)elserunLayoutwksprect