{-# LANGUAGE TypeSynonymInstances, MultiParamTypeClasses, PatternGuards #-}------------------------------------------------------------------------------ |-- Module : XMonad.Layout.PositionStoreFloat-- Copyright : (c) Jan Vornberger 2009-- License : BSD3-style (see LICENSE)---- Maintainer : jan.vornberger@informatik.uni-oldenburg.de-- Stability : unstable-- Portability : not portable---- A floating layout which has been designed with a dual-head setup-- in mind. It makes use of "XMonad.Util.PositionStore" as well as-- "XMonad.Hooks.PositionStoreHooks" . Since there is currently no way-- to move or resize windows with the keyboard alone in this layout,-- it is adviced to use it in combination with a decoration such as-- "XMonad.Layout.NoFrillsDecoration" (to move windows) and the-- layout modifier "XMonad.Layout.BorderResize" (to resize windows).-------------------------------------------------------------------------------moduleXMonad.Layout.PositionStoreFloat(-- * Usage-- $usagepositionStoreFloat)whereimportXMonadimportXMonad.Util.PositionStoreimportqualifiedXMonad.StackSetasSimportXMonad.Layout.WindowArrangerimportControl.Monad(when)importData.Maybe(isJust)importData.List(nub)-- $usage-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:---- > import XMonad.Layout.PositionStoreFloat-- > import XMonad.Layout.NoFrillsDecoration-- > import XMonad.Layout.BorderResize---- Then edit your @layoutHook@ by adding the PositionStoreFloat layout.-- Below is a suggestion which uses the mentioned NoFrillsDecoration and-- BorderResize:---- > myLayouts = floatingDeco $ borderResize $ positionStoreFloat ||| etc..-- > where floatingDeco l = noFrillsDeco shrinkText defaultTheme l-- > main = xmonad defaultConfig { layoutHook = myLayouts }---- See the documentation of "XMonad.Hooks.PositionStoreHooks" on how-- to add the support hooks.positionStoreFloat::PositionStoreFloatapositionStoreFloat=PSF(Nothing,[])dataPositionStoreFloata=PSF(MaybeRectangle,[a])deriving(Show,Read)instanceLayoutClassPositionStoreFloatWindowwheredescription_="PSF"doLayout(PSF(maybeChange,paintOrder))sr(S.Stackwlr)=doposStore<-getPosStoreletwrs=map(\w'->(w',pSQposStorew'sr))(reversel++r)letfocused=casemaybeChangeofNothing->(w,pSQposStorewsr)JustchangedRect->(w,changedRect)letwrs'=focused:wrsletpaintOrder'=nub(w:paintOrder)when(isJustmaybeChange)$doupdatePositionStorefocusedsrreturn(reorderwrs'paintOrder',Just$PSF(Nothing,paintOrder'))wherepSQposStorew'sr'=case(posStoreQueryposStorew'sr')ofJustrect->rectNothing->(Rectangle5050200200)-- should usually not happenpureMessage(PSF(_,paintOrder))m|Just(SetGeometryrect)<-fromMessagem=Just$PSF(Justrect,paintOrder)|otherwise=NothingupdatePositionStore::(Window,Rectangle)->Rectangle->X()updatePositionStore(w,rect)sr=modifyPosStore(\ps->posStoreInsertpswrectsr)reorder::(Eqa)=>[(a,b)]->[a]->[(a,b)]reorderwrsorder=letordered=concat$map(pickElemwrs)orderrest=filter(\(w,_)->not(w`elem`order))wrsinordered++restwherepickElemliste=case(lookupelist)ofJustresult->[(e,result)]Nothing->[]