From 5acd4ad8b1edd9cf0953d8347bb64bafd88f743c Mon Sep 17 00:00:00 2001 From: Peter De Wachter Date: Wed, 20 Jun 2007 19:00:20 +0200 Subject: Make Magnifier's master window behavior customizable based on a suggestion by Tim Hobbs darcs-hash:20070620170020-06a25-ee0a03e9814031615e823e6faa12dd9016e68b8d.gz --- Magnifier.hs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'Magnifier.hs') 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' -- cgit v1.2.3