From 8ee7b23dc23a0daab428619833992f11af3c2c0b Mon Sep 17 00:00:00 2001 From: joamaki Date: Fri, 25 Apr 2008 00:09:57 +0200 Subject: new contrib layout: XMonad.Layout.SimplestFloat - A floating layout like SimpleFloat, but without decoration darcs-hash:20080424220957-2bec7-8dfa615dfd80ffeee4a464ea2713074938d768d0.gz --- XMonad/Layout/SimplestFloat.hs | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 XMonad/Layout/SimplestFloat.hs (limited to 'XMonad/Layout/SimplestFloat.hs') diff --git a/XMonad/Layout/SimplestFloat.hs b/XMonad/Layout/SimplestFloat.hs new file mode 100644 index 0000000..61a3c0d --- /dev/null +++ b/XMonad/Layout/SimplestFloat.hs @@ -0,0 +1,64 @@ +{-# LANGUAGE TypeSynonymInstances, MultiParamTypeClasses #-} +----------------------------------------------------------------------------- +-- | +-- Module : XMonad.Layout.SimplestFloat +-- Copyright : (c) 2008 Jussi Mäki +-- License : BSD-style (see xmonad/LICENSE) +-- +-- Maintainer : joamaki@gmail.com +-- Stability : unstable +-- Portability : unportable +-- +-- A basic floating layout like SimpleFloat but without the decoration. +----------------------------------------------------------------------------- + +module XMonad.Layout.SimplestFloat + ( -- * Usage: + -- $usage + simplestFloat + , SimplestFloat + ) where + +import XMonad +import qualified XMonad.StackSet as S +import XMonad.Layout.WindowArranger +import XMonad.Layout.LayoutModifier + +-- $usage +-- You can use this module with the following in your +-- @~\/.xmonad\/xmonad.hs@: +-- +-- > import XMonad.Layout.SimplestFloat +-- +-- Then edit your @layoutHook@ by adding the SimplestFloat layout: +-- +-- > myLayouts = simplestFloat ||| Full ||| etc.. +-- > main = xmonad defaultConfig { layoutHook = myLayouts } +-- +-- For more detailed instructions on editing the layoutHook see: +-- +-- "XMonad.Doc.Extending#Editing_the_layout_hook" + +-- | A simple floating layout where every window is placed according +-- to the window's initial attributes. +simplestFloat :: Eq a => (ModifiedLayout WindowArranger SimplestFloat) a +simplestFloat = (windowArrangeAll $ SF) + +data SimplestFloat a = SF deriving (Show, Read) +instance LayoutClass SimplestFloat Window where + doLayout SF sc (S.Stack w l r) = do wrs <- mapM (getSize sc) (w : reverse l ++ r) + return (wrs, Nothing) + description _ = "SimplestFloat" + +getSize :: Rectangle -> Window -> X (Window,Rectangle) +getSize (Rectangle rx ry _ _) w = do + d <- asks display + bw <- asks (borderWidth . config) + wa <- io $ getWindowAttributes d w + let x = max rx $ fi $ wa_x wa + y = max ry $ fi $ wa_y wa + wh = (fi $ wa_width wa) + (bw * 2) + ht = (fi $ wa_height wa) + (bw * 2) + return (w, Rectangle x y wh ht) + where + fi x = fromIntegral x \ No newline at end of file -- cgit v1.2.3