summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Creighton <jcreigh@gmail.com>2007-04-03 06:06:58 +0200
committerJason Creighton <jcreigh@gmail.com>2007-04-03 06:06:58 +0200
commitb974e425f84f7e9ff6d930b3d7bc135473d664b7 (patch)
tree13593de485b8780d92d599345b7444dde95bb757
parent25aabd8f720db1b5abf2e9ed1628df7ad2c4651b (diff)
downloadmetatile-b974e425f84f7e9ff6d930b3d7bc135473d664b7.tar
metatile-b974e425f84f7e9ff6d930b3d7bc135473d664b7.zip
vertical (master area on top) tiling
darcs-hash:20070403040658-b9aa7-4bbe82e188fd19de00f8d6f86a3e4d3b4a39bf01
-rw-r--r--Operations.hs12
-rw-r--r--XMonad.hs2
2 files changed, 10 insertions, 4 deletions
diff --git a/Operations.hs b/Operations.hs
index 2558449..046c75b 100644
--- a/Operations.hs
+++ b/Operations.hs
@@ -38,14 +38,12 @@ refresh = do
case layoutType fl of
Full -> fmap (flip (,) sc) $ maybeToList $ W.peekStack n ws
Horz -> tile (tileFraction fl) sc $ W.index n ws
+ Vert -> vtile (tileFraction fl) sc $ W.index n ws
whenJust (W.peekStack n ws) (io . raiseWindow d)
whenJust (W.peek ws) setFocus
-- | tile. Compute the positions for windows in horizontal layout
-- mode.
---
--- TODO generalize this to vertical layout
---
tile :: Rational -> Rectangle -> [Window] -> [(Window, Rectangle)]
tile _ _ [] = []
tile _ d [w] = [(w, d)]
@@ -57,6 +55,14 @@ tile r (Rectangle sx sy sw sh) (w:s)
rh = fromIntegral sh `div` fromIntegral (length s)
f i a = (a, Rectangle (sx + lw) i rw (fromIntegral rh))
+-- | vtile. Tile vertically.
+vtile :: Rational -> Rectangle -> [Window] -> [(Window, Rectangle)]
+vtile r rect ws = map (\(w, wr) -> (w, flipRect wr)) $ tile r (flipRect rect) ws
+
+flipRect :: Rectangle -> Rectangle
+flipRect (Rectangle { rect_x = x, rect_y = y, rect_width = w, rect_height = h })
+ = Rectangle { rect_x = y, rect_y = x, rect_width = h, rect_height = w }
+
-- | switchLayout. Switch to another layout scheme. Switches the
-- current workspace.
switchLayout :: X ()
diff --git a/XMonad.hs b/XMonad.hs
index d74de48..94b0ed1 100644
--- a/XMonad.hs
+++ b/XMonad.hs
@@ -51,7 +51,7 @@ data XState = XState
type WorkSpace = StackSet Window
-- | The different layout modes
-data Layout = Full | Horz deriving (Enum, Bounded)
+data Layout = Full | Horz | Vert deriving (Enum, Bounded)
-- | 'rot' for Layout.
rot :: Layout -> Layout