aboutsummaryrefslogtreecommitdiffstats
path: root/Circle.hs
diff options
context:
space:
mode:
authorPeter De Wachter <pdewacht@gmail.com>2007-06-06 08:41:53 +0200
committerPeter De Wachter <pdewacht@gmail.com>2007-06-06 08:41:53 +0200
commit9cb24a21ecf62bb977c222cbc6a4fcb5beba9357 (patch)
treee86732ef3839649f2b842eaab4ba2f0ddb3c71b1 /Circle.hs
parentc136d4baf7f2f417efc6316db9967257807cbc5b (diff)
downloadXMonadContrib-9cb24a21ecf62bb977c222cbc6a4fcb5beba9357.tar.gz
XMonadContrib-9cb24a21ecf62bb977c222cbc6a4fcb5beba9357.tar.xz
XMonadContrib-9cb24a21ecf62bb977c222cbc6a4fcb5beba9357.zip
Circle layout
Windows are arranged in a circle around the master window. Rather nice to use with a mouse, if you got many windows open. Screenshot: http://caladan.rave.org/circle.png darcs-hash:20070606064153-06a25-32570fd1fd9457ff1f5ffe9b32e5f586c9549ba7.gz
Diffstat (limited to 'Circle.hs')
-rw-r--r--Circle.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Circle.hs b/Circle.hs
new file mode 100644
index 0000000..cf0bcb8
--- /dev/null
+++ b/Circle.hs
@@ -0,0 +1,30 @@
+module XMonadContrib.Circle (circle) where -- actually it's an ellipse
+
+import Graphics.X11.Xlib
+import XMonad
+
+circle :: Layout
+circle = Layout { doLayout = circleLayout,
+ modifyLayout = const Nothing }
+
+circleLayout :: Rectangle -> [Window] -> X [(Window, Rectangle)]
+circleLayout _ [] = return []
+circleLayout r (w:ws) = return $ (w, center r) : (zip ws sats)
+ where sats = map (satellite r) $ take (length ws) [0, pi * 2 / fromIntegral (length ws) ..]
+
+center :: Rectangle -> Rectangle
+center (Rectangle sx sy sw sh) = Rectangle x y w h
+ where w = round ((fromIntegral sw / sqrt 2) :: Double)
+ h = round ((fromIntegral sh / sqrt 2) :: Double)
+ x = sx + fromIntegral (sw - w) `div` 2
+ y = sy + fromIntegral (sh - h) `div` 2
+
+satellite :: Rectangle -> Double -> Rectangle
+satellite (Rectangle sx sy sw sh) a = Rectangle (sx + round (rx + rx * cos a))
+ (sy + round (ry + ry * sin a))
+ w h
+ where rx = fromIntegral (sw - w) / 2
+ ry = fromIntegral (sh - h) / 2
+ w = sw * 10 `div` 25
+ h = sh * 10 `div` 25
+