aboutsummaryrefslogtreecommitdiffstats
path: root/Magnifier.hs
diff options
context:
space:
mode:
authorPeter De Wachter <pdewacht@gmail.com>2007-06-20 19:00:20 +0200
committerPeter De Wachter <pdewacht@gmail.com>2007-06-20 19:00:20 +0200
commit5acd4ad8b1edd9cf0953d8347bb64bafd88f743c (patch)
tree89beee7972df7843707bcff0ac180f206294c77d /Magnifier.hs
parentb6f09e4ddb51d597c920dde5c8c59b28c301efe4 (diff)
downloadXMonadContrib-5acd4ad8b1edd9cf0953d8347bb64bafd88f743c.tar.gz
XMonadContrib-5acd4ad8b1edd9cf0953d8347bb64bafd88f743c.tar.xz
XMonadContrib-5acd4ad8b1edd9cf0953d8347bb64bafd88f743c.zip
Make Magnifier's master window behavior customizable
based on a suggestion by Tim Hobbs darcs-hash:20070620170020-06a25-ee0a03e9814031615e823e6faa12dd9016e68b8d.gz
Diffstat (limited to 'Magnifier.hs')
-rw-r--r--Magnifier.hs23
1 files changed, 16 insertions, 7 deletions
diff --git a/Magnifier.hs b/Magnifier.hs
index cfe4c12..b836d5a 100644
--- a/Magnifier.hs
+++ b/Magnifier.hs
@@ -11,8 +11,6 @@
-- Screenshot : http://caladan.rave.org/magnifier.png
--
-- This layout hack increases the size of the window that has focus.
--- The master window is left alone. (Maybe that should be an option.)
---
--
-----------------------------------------------------------------------------
@@ -20,7 +18,7 @@
module XMonadContrib.Magnifier (
-- * Usage
-- $usage
- magnifier) where
+ magnifier, magnifier') where
import Graphics.X11.Xlib
import XMonad
@@ -30,13 +28,24 @@ import StackSet
-- > import XMonadContrib.Magnifier
-- > defaultLayouts = [ magnifier tiled , magnifier $ mirror tiled ]
+-- | 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 -> applyMagnifier r s `fmap` doLayout l r s
+magnifier l = l { doLayout = \r s -> unlessMaster applyMagnifier r s `fmap` doLayout l r s
, modifyLayout = \x -> fmap magnifier `fmap` modifyLayout l x }
-applyMagnifier :: Eq a => Rectangle -> Stack a -> [(a, Rectangle)] -> [(a, Rectangle)]
-applyMagnifier r s | null (up s) = id -- don't change the master window
- | otherwise = map $ \(w,wr) -> if w == focus s then (w, shrink r $ magnify wr) else (w, wr)
+-- | 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 }
+
+
+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 = map $ \(w,wr) -> if w == focus s then (w, shrink r $ magnify wr) else (w, wr)
magnify :: Rectangle -> Rectangle
magnify (Rectangle x y w h) = Rectangle x' y' w' h'