aboutsummaryrefslogtreecommitdiffstats
path: root/Accordion.hs
diff options
context:
space:
mode:
authorglasser <glasser@mit.edu>2007-06-18 17:39:43 +0200
committerglasser <glasser@mit.edu>2007-06-18 17:39:43 +0200
commit4a4c7ab38f7e176132192ccca4722a53e13e6c98 (patch)
tree1d8ce226677efc52477b7d572291ed8c0f0b17fc /Accordion.hs
parentad1bc316d9ce3a7dfd756d779b0203dc0f952286 (diff)
downloadXMonadContrib-4a4c7ab38f7e176132192ccca4722a53e13e6c98.tar.gz
XMonadContrib-4a4c7ab38f7e176132192ccca4722a53e13e6c98.tar.xz
XMonadContrib-4a4c7ab38f7e176132192ccca4722a53e13e6c98.zip
Add an "accordion" layout which puts non-focused windows in ribbons at the top and bottom of the screen.
darcs-hash:20070618153943-64353-5dca151e7031e825c66b82c2232fc97177ef48c9.gz
Diffstat (limited to 'Accordion.hs')
-rw-r--r--Accordion.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Accordion.hs b/Accordion.hs
new file mode 100644
index 0000000..c4214f1
--- /dev/null
+++ b/Accordion.hs
@@ -0,0 +1,27 @@
+module XMonadContrib.Accordion (accordion) where
+
+import XMonad
+import Operations
+import qualified StackSet as W
+import Graphics.X11.Xlib
+import Data.Ratio
+
+accordion :: Layout
+accordion = Layout { doLayout = accordionLayout
+ , modifyLayout = const $ return Nothing }
+
+accordionLayout :: Rectangle -> W.Stack Window -> X [(Window, Rectangle)]
+accordionLayout sc ws = return $ (zip ups tops) ++
+ [(W.focus ws, mainPane)] ++
+ (zip dns bottoms)
+ where ups = W.up ws
+ dns = W.down ws
+ (top, allButTop) = splitVerticallyBy (1%8) sc
+ (center, bottom) = splitVerticallyBy (6%7) allButTop
+ (allButBottom, _) = splitVerticallyBy (7%8) sc
+ mainPane | ups /= [] && dns /= [] = center
+ | ups /= [] = allButTop
+ | dns /= [] = allButBottom
+ | otherwise = sc
+ tops = if ups /= [] then splitVertically (length ups) top else []
+ bottoms= if dns /= [] then splitVertically (length dns) bottom else []