aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-06-10 17:39:26 +0200
committerDavid Roundy <droundy@darcs.net>2007-06-10 17:39:26 +0200
commita8f7c93fc3e706a0858222cb55a97dbfb4aa4927 (patch)
treecfd8055f744affabe7aacbc3dde4b028b643f30a
parent6d381a05c31f488bfaf4e7049eacd39e5dbcada6 (diff)
downloadXMonadContrib-a8f7c93fc3e706a0858222cb55a97dbfb4aa4927.tar.gz
XMonadContrib-a8f7c93fc3e706a0858222cb55a97dbfb4aa4927.tar.xz
XMonadContrib-a8f7c93fc3e706a0858222cb55a97dbfb4aa4927.zip
add sketch of tabbed layout.
darcs-hash:20070610153926-72aca-9c08c36025522b50a3f2df1eed8f09c3bbb30495.gz
Diffstat (limited to '')
-rw-r--r--Tabbed.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Tabbed.hs b/Tabbed.hs
new file mode 100644
index 0000000..5710bf8
--- /dev/null
+++ b/Tabbed.hs
@@ -0,0 +1,41 @@
+module XMonadContrib.Tabbed ( tabbed ) where
+
+-- This module defines a tabbed layout.
+
+-- You can use this module with the following in your config file:
+
+-- import XMonadContrib.Tabbed
+
+-- defaultLayouts :: [Layout]
+-- defaultLayouts = [ tabbed
+-- , ... ]
+
+import Control.Monad ( forM )
+
+import Graphics.X11.Xlib
+import XMonad
+import XMonadContrib.Decoration
+import Operations ( focus )
+
+tabbed :: Layout
+tabbed = Layout { doLayout = dolay, modifyLayout = const (return Nothing) }
+
+dolay :: Rectangle -> [Window] -> X [(Window, Rectangle)]
+dolay sc [w] = return [(w,sc)]
+dolay sc@(Rectangle x _ wid _) ws =
+ do let ts = gentabs x wid (length ws)
+ tws = zip ts ws
+ forM tws $ \(t,w) -> newDecoration t 1 0xFF0000 0x00FFFF (trace "draw") (focus w)
+ return [ (w,shrink sc) | w <- ws ]
+
+shrink :: Rectangle -> Rectangle
+shrink (Rectangle x y w h) = Rectangle x (y+tabsize) w (h-tabsize)
+
+gentabs :: Position -> Dimension -> Int -> [Rectangle]
+gentabs _ _ 0 = []
+gentabs x1 w num = Rectangle x1 0 (wid - 2) (tabsize - 2)
+ : gentabs (x1 + fromIntegral wid) (w - wid) (num - 1)
+ where wid = w `div` (fromIntegral num)
+
+tabsize :: Integral a => a
+tabsize = 30