New patches: [[SPIRAL] add spiral tiling layout joe.thornber@gmail.com**20070522062537] { addfile ./Spiral.hs hunk ./Spiral.hs 1 +module Spiral (spiral) where + +import Graphics.X11.Xlib +import Operations +import Data.Ratio +import XMonad + +-- +-- Spiral layout +-- +-- eg, +-- defaultLayouts :: [Layout] +-- defaultLayouts = [ full, +-- tall defaultWindowsInMaster defaultDelta (1%2), +-- wide defaultWindowsInMaster defaultDelta (1%2), +-- spiral (1000 % 1618) ] +-- +spiral :: Rational -> Layout +spiral rat = Layout { doLayout = \sc ws -> return $ zip ws (divideRects rat (length ws) East $ sc), + modifyLayout = \m -> fmap resize (fromMessage m)} + + where resize Expand = let newRat = ((numerator rat + 10) % (denominator rat)) + normRat = if numerator newRat > denominator newRat then rat else newRat in + spiral normRat + resize Shrink = let newRat = ((numerator rat - 10) % (denominator rat)) + normRat = if numerator newRat < 0 then rat else newRat in + spiral normRat + +data Direction = East | South | West | North + +nextDir :: Direction -> Direction +nextDir East = South +nextDir South = West +nextDir West = North +nextDir North = East + +divideRects :: Rational -> Int -> Direction -> Rectangle -> [Rectangle] +divideRects r n dir rect | n <= 1 = [rect] + | otherwise = case divideRect r dir rect of + (r1, r2) -> r1 : (divideRects r (n - 1) (nextDir dir) r2) + +divideRect :: Rational -> Direction -> Rectangle -> (Rectangle, Rectangle) +divideRect ratio East (Rectangle x y w h) = let (w1, w2) = chop ratio (fromIntegral w) in + (Rectangle x y (fromIntegral w1) h, + Rectangle (x + (fromIntegral w1)) y (fromIntegral w2) h) +divideRect ratio South (Rectangle x y w h) = let (h1, h2) = chop ratio (fromIntegral h) in + (Rectangle x y w (fromIntegral h1), + Rectangle x (y + (fromIntegral h1)) w (fromIntegral h2)) +divideRect ratio West (Rectangle x y w h) = let (w1, w2) = chop (1 - ratio) (fromIntegral w) in + (Rectangle (x + (fromIntegral w1)) y (fromIntegral w2) h, + Rectangle x y (fromIntegral w1) h) +divideRect ratio North (Rectangle x y w h) = let (h1, h2) = chop (1 - ratio) (fromIntegral h) in + (Rectangle x (y + (fromIntegral h1)) w (fromIntegral h2), + Rectangle x y w (fromIntegral h1)) + +chop :: Rational -> Integer -> (Integer, Integer) +chop rat n = let f = ((fromIntegral n) * (numerator rat)) `div` (denominator rat) in + (f, n - f) } Context: [Make RotView compile. Miikka Koskinen **20070522075338 As I'm not a Xinerama user, I'm not sure if rotView should consider only hidden workspaces or also visible but not focused workspaces. I thought hidden workspaces only would be more logical. ] [bug fix in DwmPromote. whoops. Miikka Koskinen **20070522062118] [make FindEmptyWorkspace compile Miikka Koskinen **20070521123239] [make DwmPromote compile Miikka Koskinen **20070521123140] [updated Dmenu.hs to work with zipper StackSet Jason Creighton **20070521233947] [Add GreedyView Spencer Janssen **20070521220048] [Rescreen: collects new screen information Spencer Janssen **20070521164808] [Fixes for windowset -> workspace rename Spencer Janssen **20070521042118] [TwoPane: hide windows that aren't in view Spencer Janssen **20070518224240] [make Mosaic even less picky by default. David Roundy **20070516175554] [add clear window message in Mosaic. David Roundy **20070516175518] [Comment only Spencer Janssen **20070517211003] [Add instructions for TwoPane Spencer Janssen **20070517210206] [Add TwoPane Spencer Janssen **20070517195618] [throttle the exponential expense when many windows are present. David Roundy **20070516022123] [make mosaic configure windows by name rather than by Window. David Roundy **20070512215644 Note that this is still pretty flawed. Often window names change, and the layout then stagnates a bit. Gimp, for example, opens most its windows with the same name before renaming them, so you have to hit mod-return or something to force a doLayout. Also, gimp still overrides xmonad regarding the size of its main window. :( ] [XMonadContrib.FindEmptyWorkspace Miikka Koskinen **20070513184338 With this module you can find empty workspaces, view them and tag windows to them. ] [make DwmPromote compile Miikka Koskinen **20070513184254] [make DwmPromote compile again Miikka Koskinen **20070510154158] [make DwmPromote compile Miikka Koskinen **20070503105236] [add SwapFocus. David Roundy **20070512191315] [make rotView only consider non-visible workspaces (Xinerama) Jason Creighton **20070510012059] [fix commend in RotView. David Roundy **20070505185654] [switch to Message type for layout messages Don Stewart **20070505014332] [Fix instructions in Mosaic. Chris Mears **20070503222345] [add Mosaic layout. David Roundy **20070503151024] [-Wall police Spencer Janssen **20070503211700] [Make RotView build, and add a brief description. Chris Mears **20070503104234] [comment: Gave URL to xinerama-enabled dmenu patch Jason Creighton **20070503053133] [Put dmenu in X too Spencer Janssen **20070503053727] [Add dmenu (thanks jcreigh) Spencer Janssen **20070503052225] [add RotView module. David Roundy **20070421233838] [XMonadContrib.DwmPromote: dwm-like promote Miikka Koskinen **20070501082031 I like the way dwm's equivalent to xmonad's promote works, so I implemented dwmpromote. ] [add simple date example Don Stewart **20070429064013] [more details Don Stewart **20070429061426] [add readme Don Stewart **20070429061329] [Initial import of xmonad contributions Don Stewart **20070429061150] Patch bundle hash: 3f288cac98cc25241126b1712ad053629485d22d