aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Layout/Dishes.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 21:10:59 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 21:10:59 +0100
commit4866f2e367dfcf22a9591231ba40948826a1b438 (patch)
tree7a245caee3f146826b267d773b7eaa80386a818e /XMonad/Layout/Dishes.hs
parent47589e1913fb9530481caedb543978a30d4323ea (diff)
downloadXMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.tar.gz
XMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.tar.xz
XMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.zip
Hierarchify
darcs-hash:20071101201059-a5988-fc1f1262bec1b69e13ba18ae7cefeafc8c4471d4.gz
Diffstat (limited to 'XMonad/Layout/Dishes.hs')
-rw-r--r--XMonad/Layout/Dishes.hs57
1 files changed, 57 insertions, 0 deletions
diff --git a/XMonad/Layout/Dishes.hs b/XMonad/Layout/Dishes.hs
new file mode 100644
index 0000000..ecc27db
--- /dev/null
+++ b/XMonad/Layout/Dishes.hs
@@ -0,0 +1,57 @@
+{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonad.Layout.Dishes
+-- Copyright : (c) Jeremy Apthorp
+-- License : BSD-style (see LICENSE)
+--
+-- Maintainer : Jeremy Apthorp <nornagon@gmail.com>
+-- Stability : unstable
+-- Portability : portable
+--
+-- Dishes is a layout that stacks extra windows underneath the master
+-- windows.
+--
+-----------------------------------------------------------------------------
+
+module XMonad.Layout.Dishes (
+ -- * Usage
+ -- $usage
+ Dishes (..)
+ ) where
+
+import Data.List
+import XMonad
+import XMonad.Layouts
+import XMonad.StackSet (integrate)
+import Control.Monad (ap)
+import Graphics.X11.Xlib
+
+-- $usage
+-- You can use this module with the following in your Config.hs file:
+--
+-- > import XMonad.Layout.Dishes
+--
+-- and add the following line to your 'layouts'
+--
+-- > , Layout $ Dishes 2 (1%6)
+
+-- %import XMonad.Layout.Dishes
+-- %layout , Layout $ Dishes 2 (1%6)
+
+data Dishes a = Dishes Int Rational deriving (Show, Read)
+instance LayoutClass Dishes a where
+ doLayout (Dishes nmaster h) r =
+ return . (\x->(x,Nothing)) .
+ ap zip (dishes h r nmaster . length) . integrate
+ pureMessage (Dishes nmaster h) m = fmap incmastern (fromMessage m)
+ where incmastern (IncMasterN d) = Dishes (max 0 (nmaster+d)) h
+
+dishes :: Rational -> Rectangle -> Int -> Int -> [Rectangle]
+dishes h s nmaster n = if n <= nmaster
+ then splitHorizontally n s
+ else ws
+ where
+ (m,rest) = splitVerticallyBy (1 - (fromIntegral $ n - nmaster) * h) s
+ ws = splitHorizontally nmaster m ++ splitVertically (n - nmaster) rest