Magnifier.hs: update so it at least compiles

Code modified on advice of Wachter; note I make absolutely no claims that the code runs correctly or doesn't eat your pets or does anything besides compile without any warnings.
This commit is contained in:
gwern0
2007-11-08 01:25:22 +00:00
parent a5799ec85f
commit 0e016a6fa5

View File

@@ -20,12 +20,14 @@
module XMonad.Layout.Magnifier (
-- * Usage
-- $usage
magnifier, magnifier') where
magnifier,
Magnifier(..),
Magnifier'(..)) where
import Graphics.X11.Xlib (Window, Rectangle(..))
import XMonad
import XMonad.StackSet
-- import XMonad.Layout.LayoutHelpers
import XMonad.Layout.LayoutModifier
-- $usage
-- > import XMonad.Layout.Magnifier
@@ -36,18 +38,25 @@ import XMonad.StackSet
-- %layout , magnifier $ mirror tiled
-- | Increase the size of the window that has focus, unless it is the master window.
magnifier :: Layout Window -> Layout Window
magnifier = layoutModify (unlessMaster applyMagnifier) idModMod
data Magnifier a = Magnifier deriving (Read, Show)
instance LayoutModifier Magnifier Window where
modifierDescription _ = "Magnifier"
redoLayout _ = unlessMaster applyMagnifier
-- | Increase the size of the window that has focus, even if it is the master window.
magnifier' :: Layout Window -> Layout Window
magnifier' = layoutModify applyMagnifier idModMod
data Magnifier' a = Magnifier' deriving (Read, Show)
instance LayoutModifier Magnifier' Window where
modifierDescription _ = "Magnifier'"
redoLayout _ = applyMagnifier
unlessMaster :: ModDo Window -> ModDo Window
magnifier :: l a -> ModifiedLayout Magnifier l a
magnifier = ModifiedLayout Magnifier
unlessMaster :: forall t t1 a a1 (m :: * -> *). (Monad m) => (t -> Stack a -> t1 -> m (t1, Maybe a1)) -> t -> Stack a -> t1 -> m (t1, Maybe a1)
unlessMaster mainmod r s wrs = if null (up s) then return (wrs, Nothing)
else mainmod r s wrs
applyMagnifier :: ModDo Window
applyMagnifier :: Rectangle -> t -> [(Window, Rectangle)] -> X ([(Window, Rectangle)], Maybe a)
applyMagnifier r _ wrs = do focused <- withWindowSet (return . peek)
let mag (w,wr) ws | focused == Just w = ws ++ [(w, shrink r $ magnify wr)]
| otherwise = (w,wr) : ws