aboutsummaryrefslogtreecommitdiffstats
path: root/Magnifier.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-06-23 23:09:52 +0200
committerDavid Roundy <droundy@darcs.net>2007-06-23 23:09:52 +0200
commit5f1312128d87961231d5431af0885711a01cd120 (patch)
tree5b785ff7779d1d842bc17ac554ccbe759ea4c35d /Magnifier.hs
parentb40d0f8237f4140decbf4edc7366b900cf82428b (diff)
downloadXMonadContrib-5f1312128d87961231d5431af0885711a01cd120.tar.gz
XMonadContrib-5f1312128d87961231d5431af0885711a01cd120.tar.xz
XMonadContrib-5f1312128d87961231d5431af0885711a01cd120.zip
make everything work with new doLayout.
This modifies all the contrib modules to work (so far as I know) with the new contrib layout. The exception is the LayoutHooks module, which isn't used. It exports an API that is inherently unsafe, so far as I can tell (and always has been). darcs-hash:20070623210952-72aca-1993ca13dc6996b59fedacc271c03fbaf87eabaa.gz
Diffstat (limited to 'Magnifier.hs')
-rw-r--r--Magnifier.hs23
1 files changed, 10 insertions, 13 deletions
diff --git a/Magnifier.hs b/Magnifier.hs
index e2d0c80..da18c2e 100644
--- a/Magnifier.hs
+++ b/Magnifier.hs
@@ -24,6 +24,7 @@ module XMonadContrib.Magnifier (
import Graphics.X11.Xlib
import XMonad
import StackSet
+import XMonadContrib.LayoutHelpers
-- $usage
-- > import XMonadContrib.Magnifier
@@ -31,24 +32,20 @@ import StackSet
-- | Increase the size of the window that has focus, unless it is the master window.
magnifier :: Eq a => Layout a -> Layout a
-magnifier l = l { doLayout = \r s -> unlessMaster applyMagnifier r s `fmap` doLayout l r s
- , modifyLayout = \x -> fmap magnifier `fmap` modifyLayout l x }
+magnifier = layoutModify (unlessMaster applyMagnifier) idModMod
-- | Increase the size of the window that has focus, even if it is the master window.
magnifier' :: Eq a => Layout a -> Layout a
-magnifier' l = l { doLayout = \r s -> applyMagnifier r s `fmap` doLayout l r s
- , modifyLayout = \x -> fmap magnifier' `fmap` modifyLayout l x }
+magnifier' = layoutModify applyMagnifier idModMod
+unlessMaster :: ModDo a -> ModDo a
+unlessMaster mainmod r s wrs = if null (up s) then return (wrs, Nothing)
+ else mainmod r s wrs
-type DoLayout = Eq a => Rectangle -> Stack a -> [(a, Rectangle)] -> [(a, Rectangle)]
-
-unlessMaster :: DoLayout -> DoLayout
-unlessMaster f r s = if null (up s) then id else f r s
-
-applyMagnifier :: DoLayout
-applyMagnifier r s = reverse . foldr accumulate []
- where accumulate (w,wr) ws | w == focus s = ws ++ [(w, shrink r $ magnify wr)]
- | otherwise = (w,wr) : ws
+applyMagnifier :: Eq a => ModDo a
+applyMagnifier r s wrs = return (map mag wrs, Nothing)
+ where mag (w,wr) | w == focus s = (w, shrink r $ magnify wr)
+ | otherwise = (w,wr)
magnify :: Rectangle -> Rectangle
magnify (Rectangle x y w h) = Rectangle x' y' w' h'