aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@unibz.it>2008-01-27 15:08:37 +0100
committerAndrea Rossato <andrea.rossato@unibz.it>2008-01-27 15:08:37 +0100
commitf7d7a9150c97c77a9e8c54abb6f3d3febc608c62 (patch)
treedb18434a60d80123370eb18cbdb94ebc6832ba12
parentabc827b6ff90cc4f4fc4b4831383203e6c7acee2 (diff)
downloadXMonadContrib-f7d7a9150c97c77a9e8c54abb6f3d3febc608c62.tar.gz
XMonadContrib-f7d7a9150c97c77a9e8c54abb6f3d3febc608c62.tar.xz
XMonadContrib-f7d7a9150c97c77a9e8c54abb6f3d3febc608c62.zip
ResizeScreen has been rewritten as a layout modifier
darcs-hash:20080127140837-32816-174838d39b6808123270d6b6e83853dfb49faf4a.gz
-rw-r--r--XMonad/Layout/ResizeScreen.hs52
1 files changed, 17 insertions, 35 deletions
diff --git a/XMonad/Layout/ResizeScreen.hs b/XMonad/Layout/ResizeScreen.hs
index 4b56e96..7eeff90 100644
--- a/XMonad/Layout/ResizeScreen.hs
+++ b/XMonad/Layout/ResizeScreen.hs
@@ -22,11 +22,9 @@ module XMonad.Layout.ResizeScreen
, ResizeScreen (..)
) where
-import Control.Arrow (second)
-import Control.Applicative ((<$>))
-
import XMonad
import XMonad.Util.XUtils (fi)
+import XMonad.Layout.LayoutModifier
-- $usage
-- You can use this module by importing it into your
@@ -42,40 +40,24 @@ import XMonad.Util.XUtils (fi)
--
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
-resizeHorizontal :: Int -> l a -> ResizeScreen l a
-resizeHorizontal = ResizeScreen H
+resizeHorizontal :: Int -> l a -> ModifiedLayout ResizeScreen l a
+resizeHorizontal i = ModifiedLayout (ResizeScreen H i)
-resizeVertical :: Int -> l a -> ResizeScreen l a
-resizeVertical = ResizeScreen V
+resizeVertical :: Int -> l a -> ModifiedLayout ResizeScreen l a
+resizeVertical i = ModifiedLayout (ResizeScreen V i)
-withNewRectangle :: Rectangle -> l a -> ResizeScreen l a
-withNewRectangle = WithNewScreen
+withNewRectangle :: Rectangle -> l a -> ModifiedLayout ResizeScreen l a
+withNewRectangle r = ModifiedLayout (WithNewScreen r)
-data ResizeScreen l a = ResizeScreen ResizeMode Int (l a)
- | WithNewScreen Rectangle (l a)
- deriving (Read, Show)
+data ResizeScreen a = ResizeScreen ResizeMode Int
+ | WithNewScreen Rectangle
+ deriving (Read, Show)
data ResizeMode = H | V deriving (Read, Show)
-instance (LayoutClass l a) => LayoutClass (ResizeScreen l) a where
- doLayout m (Rectangle x y w h ) s
- | ResizeScreen H i l <- m = resize (ResizeScreen V i) l (Rectangle (x + fi i) y (w - fi i) h)
- | ResizeScreen V i l <- m = resize (ResizeScreen H i) l (Rectangle x (y + fi i) w (h - fi i))
- | WithNewScreen r l <- m = resize (WithNewScreen r) l r
- | otherwise = return ([],Nothing)
- where resize t l' nr = second (fmap t) <$> doLayout l' nr s
-
- handleMessage rs m
- | ResizeScreen t i l <- rs = go (ResizeScreen t i) l
- | WithNewScreen r l <- rs = go (WithNewScreen r) l
- | otherwise = return Nothing
- where go tp lay = do ml' <- handleMessage lay m
- return (tp `fmap` ml')
-
- emptyLayout rs re
- | ResizeScreen t i l <- rs = go (ResizeScreen t i) l
- | WithNewScreen r l <- rs = go (WithNewScreen r) l
- | otherwise = return ([],Nothing)
- where go tp lay = do (wrs,ml) <- emptyLayout lay re
- return (wrs, tp `fmap` ml)
-
- description _ = []
+instance LayoutModifier ResizeScreen a where
+ modifyLayout m l re@(Rectangle x y w h) s
+ | ResizeScreen H i <- m = resize (Rectangle (x + fi i) y (w - fi i) h)
+ | ResizeScreen V i <- m = resize (Rectangle x (y + fi i) w (h - fi i))
+ | WithNewScreen r <- m = resize r
+ | otherwise = resize re
+ where resize nr = doLayout l nr s