From a8f7c93fc3e706a0858222cb55a97dbfb4aa4927 Mon Sep 17 00:00:00 2001 From: David Roundy Date: Sun, 10 Jun 2007 17:39:26 +0200 Subject: add sketch of tabbed layout. darcs-hash:20070610153926-72aca-9c08c36025522b50a3f2df1eed8f09c3bbb30495.gz --- Tabbed.hs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Tabbed.hs (limited to 'Tabbed.hs') 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 -- cgit v1.2.3