    {-# LANGUAGE DeriveDataTypeable, MultiParamTypeClasses, TypeSynonymInstances, PatternGuards #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  XMonad.Layout.Magnifier
    -- Copyright   :  (c) Peter De Wachter and Andrea Rossato 2007
    -- License     :  BSD-style (see xmonad/LICENSE)
    --
    -- Maintainer  :  andrea.rossato@unibz.it
    -- Stability   :  unstable
    -- Portability :  unportable
    --
    -- Screenshot  :  <http://caladan.rave.org/magnifier.png>
    --
    -- This is a layout modifier that will make a layout increase the size
    -- of the window that has focus.
    --
    -----------------------------------------------------------------------------

    module XMonad.Layout.Magnifier
        ( -- * Usage
          -- $usage
          magnifier,
          magnifier',
          magnifierOff,
          magnifiercz,
          magnifiercz',
          maximizeVertical,
          MagnifyMsg (..),
          Magnifier,
        ) where

    import XMonad
    import XMonad.StackSet
    import XMonad.Layout.LayoutModifier
    import XMonad.Util.XUtils

    -- $usage
    -- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
    --
    -- > import XMonad.Layout.Magnifier
    --
    -- Then edit your @layoutHook@ by adding the 'magnifier' layout modifier
    -- to some layout:
    --
    -- > myLayout = magnifier (Tall 1 (3/100) (1/2))  ||| Full ||| etc..
    -- > main = xmonad def { layoutHook = myLayout }
    --
    -- By default magnifier increases the focused window's size by 1.5.
    -- You can also use:
    --
    -- > magnifiercz 1.2
    --
    -- to use a custom level of magnification.  You can even make the focused
    -- window smaller for a pop in effect.
    --
    -- For more detailed instructions on editing the layoutHook see:
    --
    -- "XMonad.Doc.Extending#Editing_the_layout_hook"
    --
    -- Magnifier supports some commands. To use them add something like
    -- this to your key bindings:
    --
    -- >    , ((modm .|. controlMask              , xK_plus ), sendMessage MagnifyMore)
    -- >    , ((modm .|. controlMask              , xK_minus), sendMessage MagnifyLess)
    -- >    , ((modm .|. controlMask              , xK_o    ), sendMessage ToggleOff  )
    -- >    , ((modm .|. controlMask .|. shiftMask, xK_o    ), sendMessage ToggleOn   )
    -- >    , ((modm .|. controlMask              , xK_m    ), sendMessage Toggle     )
    --
    -- Note that a few other extension modules, such as
    -- "XMonad.Layout.MultiToggle" and "XMonad.Layout.ToggleLayouts", also
    -- define a message named 'Toggle'.  To avoid conflicts when using
    -- these modules together, you can import Magnifier qualified, like
    -- this:
    --
    -- > import qualified XMonad.Layout.Magnifier as Mag
    --
    -- and then prefix @Mag@ to the front of everything from this module,
    -- like @Mag.Toggle@, @Mag.magnifier@, and so on.
    --
    -- For detailed instruction on editing the key binding see
    -- "XMonad.Doc.Extending#Editing_key_bindings".

    -- | Increase the size of the window that has focus
    magnifier :: l a -> ModifiedLayout Magnifier l a
    magnifier :: l a -> ModifiedLayout Magnifier l a
    magnifier = Magnifier a -> l a -> ModifiedLayout Magnifier l a
    forall (m :: * -> *) (l :: * -> *) a.
    m a -> l a -> ModifiedLayout m l a
    ModifiedLayout (Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag 1 (1.5,1.5) Toggle
    On MagnifyMaster
    All)

    -- | Change the size of the window that has focus by a custom zoom
    magnifiercz :: Rational -> l a -> ModifiedLayout Magnifier l a
    magnifiercz :: Rational -> l a -> ModifiedLayout Magnifier l a
    magnifiercz cz :: Rational
    cz = Magnifier a -> l a -> ModifiedLayout Magnifier l a
    forall (m :: * -> *) (l :: * -> *) a.
    m a -> l a -> ModifiedLayout m l a
    ModifiedLayout (Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag 1 (Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational Rational
    cz, Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational Rational
    cz) Toggle
    On MagnifyMaster
    All)

    -- | Increase the size of the window that has focus, unless if it is one of the
    -- master windows.
    magnifier' :: l a -> ModifiedLayout Magnifier l a
    magnifier' :: l a -> ModifiedLayout Magnifier l a
    magnifier' = Magnifier a -> l a -> ModifiedLayout Magnifier l a
    forall (m :: * -> *) (l :: * -> *) a.
    m a -> l a -> ModifiedLayout m l a
    ModifiedLayout (Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag 1 (1.5,1.5) Toggle
    On MagnifyMaster
    NoMaster)

    -- | Magnifier that defaults to Off
    magnifierOff :: l a -> ModifiedLayout Magnifier l a
    magnifierOff :: l a -> ModifiedLayout Magnifier l a
    magnifierOff = Magnifier a -> l a -> ModifiedLayout Magnifier l a
    forall (m :: * -> *) (l :: * -> *) a.
    m a -> l a -> ModifiedLayout m l a
    ModifiedLayout (Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag 1 (1.5,1.5) Toggle
    Off MagnifyMaster
    All)

    -- | Increase the size of the window that has focus by a custom zoom,
    -- unless if it is one of the the master windows.
    magnifiercz' :: Rational -> l a -> ModifiedLayout Magnifier l a
    magnifiercz' :: Rational -> l a -> ModifiedLayout Magnifier l a
    magnifiercz' cz :: Rational
    cz = Magnifier a -> l a -> ModifiedLayout Magnifier l a
    forall (m :: * -> *) (l :: * -> *) a.
    m a -> l a -> ModifiedLayout m l a
    ModifiedLayout (Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag 1 (Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational Rational
    cz, Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational Rational
    cz) Toggle
    On MagnifyMaster
    NoMaster)

    -- | A magnifier that greatly magnifies just the vertical direction
    maximizeVertical :: l a -> ModifiedLayout Magnifier l a
    maximizeVertical :: l a -> ModifiedLayout Magnifier l a
    maximizeVertical = Magnifier a -> l a -> ModifiedLayout Magnifier l a
    forall (m :: * -> *) (l :: * -> *) a.
    m a -> l a -> ModifiedLayout m l a
    ModifiedLayout (Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag 1 (1,1000) Toggle
    Off MagnifyMaster
    All)

    data MagnifyMsg = MagnifyMore | MagnifyLess | ToggleOn | ToggleOff | Toggle deriving ( Typeable )
    instance Message MagnifyMsg

    data Magnifier a = Mag !Int (Double,Double) Toggle MagnifyMaster deriving (ReadPrec [Magnifier a]
    ReadPrec (Magnifier a)
    Int -> ReadS (Magnifier a)
    ReadS [Magnifier a]
    (Int -> ReadS (Magnifier a))
    -> ReadS [Magnifier a]
    -> ReadPrec (Magnifier a)
    -> ReadPrec [Magnifier a]
    -> Read (Magnifier a)
    forall a. ReadPrec [Magnifier a]
    forall a. ReadPrec (Magnifier a)
    forall a. Int -> ReadS (Magnifier a)
    forall a. ReadS [Magnifier a]
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    readListPrec :: ReadPrec [Magnifier a]
    $creadListPrec :: forall a. ReadPrec [Magnifier a]
    readPrec :: ReadPrec (Magnifier a)
    $creadPrec :: forall a. ReadPrec (Magnifier a)
    readList :: ReadS [Magnifier a]
    $creadList :: forall a. ReadS [Magnifier a]
    readsPrec :: Int -> ReadS (Magnifier a)
    $creadsPrec :: forall a. Int -> ReadS (Magnifier a)
    Read, Int -> Magnifier a -> ShowS
    [Magnifier a] -> ShowS
    Magnifier a -> String
    (Int -> Magnifier a -> ShowS)
    -> (Magnifier a -> String)
    -> ([Magnifier a] -> ShowS)
    -> Show (Magnifier a)
    forall a. Int -> Magnifier a -> ShowS
    forall a. [Magnifier a] -> ShowS
    forall a. Magnifier a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Magnifier a] -> ShowS
    $cshowList :: forall a. [Magnifier a] -> ShowS
    show :: Magnifier a -> String
    $cshow :: forall a. Magnifier a -> String
    showsPrec :: Int -> Magnifier a -> ShowS
    $cshowsPrec :: forall a. Int -> Magnifier a -> ShowS
    Show)

    data Toggle        = On  | Off      deriving  (ReadPrec [Toggle]
    ReadPrec Toggle
    Int -> ReadS Toggle
    ReadS [Toggle]
    (Int -> ReadS Toggle)
    -> ReadS [Toggle]
    -> ReadPrec Toggle
    -> ReadPrec [Toggle]
    -> Read Toggle
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    readListPrec :: ReadPrec [Toggle]
    $creadListPrec :: ReadPrec [Toggle]
    readPrec :: ReadPrec Toggle
    $creadPrec :: ReadPrec Toggle
    readList :: ReadS [Toggle]
    $creadList :: ReadS [Toggle]
    readsPrec :: Int -> ReadS Toggle
    $creadsPrec :: Int -> ReadS Toggle
    Read, Int -> Toggle -> ShowS
    [Toggle] -> ShowS
    Toggle -> String
    (Int -> Toggle -> ShowS)
    -> (Toggle -> String) -> ([Toggle] -> ShowS) -> Show Toggle
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Toggle] -> ShowS
    $cshowList :: [Toggle] -> ShowS
    show :: Toggle -> String
    $cshow :: Toggle -> String
    showsPrec :: Int -> Toggle -> ShowS
    $cshowsPrec :: Int -> Toggle -> ShowS
    Show)
    data MagnifyMaster = All | NoMaster deriving  (ReadPrec [MagnifyMaster]
    ReadPrec MagnifyMaster
    Int -> ReadS MagnifyMaster
    ReadS [MagnifyMaster]
    (Int -> ReadS MagnifyMaster)
    -> ReadS [MagnifyMaster]
    -> ReadPrec MagnifyMaster
    -> ReadPrec [MagnifyMaster]
    -> Read MagnifyMaster
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    readListPrec :: ReadPrec [MagnifyMaster]
    $creadListPrec :: ReadPrec [MagnifyMaster]
    readPrec :: ReadPrec MagnifyMaster
    $creadPrec :: ReadPrec MagnifyMaster
    readList :: ReadS [MagnifyMaster]
    $creadList :: ReadS [MagnifyMaster]
    readsPrec :: Int -> ReadS MagnifyMaster
    $creadsPrec :: Int -> ReadS MagnifyMaster
    Read, Int -> MagnifyMaster -> ShowS
    [MagnifyMaster] -> ShowS
    MagnifyMaster -> String
    (Int -> MagnifyMaster -> ShowS)
    -> (MagnifyMaster -> String)
    -> ([MagnifyMaster] -> ShowS)
    -> Show MagnifyMaster
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [MagnifyMaster] -> ShowS
    $cshowList :: [MagnifyMaster] -> ShowS
    show :: MagnifyMaster -> String
    $cshow :: MagnifyMaster -> String
    showsPrec :: Int -> MagnifyMaster -> ShowS
    $cshowsPrec :: Int -> MagnifyMaster -> ShowS
    Show)

    instance LayoutModifier Magnifier Window where
        redoLayout :: Magnifier Window
    -> Rectangle
    -> Maybe (Stack Window)
    -> [(Window, Rectangle)]
    -> X ([(Window, Rectangle)], Maybe (Magnifier Window))
    redoLayout  (Mag _ z :: (Double, Double)
    z On All     ) r :: Rectangle
    r (Just s :: Stack Window
    s) wrs :: [(Window, Rectangle)]
    wrs = (Double, Double)
    -> Rectangle
    -> Stack Window
    -> [(Window, Rectangle)]
    -> X ([(Window, Rectangle)], Maybe (Magnifier Window))
    forall t a.
    (Double, Double)
    -> Rectangle
    -> t
    -> [(Window, Rectangle)]
    -> X ([(Window, Rectangle)], Maybe a)
    applyMagnifier (Double, Double)
    z Rectangle
    r Stack Window
    s [(Window, Rectangle)]
    wrs
        redoLayout  (Mag n :: Int
    n z :: (Double, Double)
    z On NoMaster) r :: Rectangle
    r (Just s :: Stack Window
    s) wrs :: [(Window, Rectangle)]
    wrs = Int
    -> (Rectangle
        -> Stack Window
        -> [(Window, Rectangle)]
        -> X ([(Window, Rectangle)], Maybe (Magnifier Window)))
    -> Rectangle
    -> Stack Window
    -> [(Window, Rectangle)]
    -> X ([(Window, Rectangle)], Maybe (Magnifier Window))
    forall a. Int -> NewLayout a -> NewLayout a
    unlessMaster Int
    n ((Double, Double)
    -> Rectangle
    -> Stack Window
    -> [(Window, Rectangle)]
    -> X ([(Window, Rectangle)], Maybe (Magnifier Window))
    forall t a.
    (Double, Double)
    -> Rectangle
    -> t
    -> [(Window, Rectangle)]
    -> X ([(Window, Rectangle)], Maybe a)
    applyMagnifier (Double, Double)
    z) Rectangle
    r Stack Window
    s [(Window, Rectangle)]
    wrs
        redoLayout  _                   _ _        wrs :: [(Window, Rectangle)]
    wrs = ([(Window, Rectangle)], Maybe (Magnifier Window))
    -> X ([(Window, Rectangle)], Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([(Window, Rectangle)]
    wrs, Maybe (Magnifier Window)
    forall a. Maybe a
    Nothing)

        handleMess :: Magnifier Window -> SomeMessage -> X (Maybe (Magnifier Window))
    handleMess (Mag n :: Int
    n z :: (Double, Double)
    z On  t :: MagnifyMaster
    t) m :: SomeMessage
    m
                        | Just MagnifyMore    <- SomeMessage -> Maybe MagnifyMsg
    forall m. Message m => SomeMessage -> Maybe m
    fromMessage SomeMessage
    m = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Magnifier Window) -> X (Maybe (Magnifier Window)))
    -> (Magnifier Window -> Maybe (Magnifier Window))
    -> Magnifier Window
    -> X (Maybe (Magnifier Window))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Magnifier Window -> Maybe (Magnifier Window)
    forall a. a -> Maybe a
    Just (Magnifier Window -> X (Maybe (Magnifier Window)))
    -> Magnifier Window -> X (Maybe (Magnifier Window))
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier Window
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag Int
    n             ((Double, Double)
    z (Double, Double) -> Double -> (Double, Double)
    forall b. Num b => (b, b) -> b -> (b, b)
    `addto`   0.1 ) Toggle
    On  MagnifyMaster
    t
                        | Just MagnifyLess    <- SomeMessage -> Maybe MagnifyMsg
    forall m. Message m => SomeMessage -> Maybe m
    fromMessage SomeMessage
    m = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Magnifier Window) -> X (Maybe (Magnifier Window)))
    -> (Magnifier Window -> Maybe (Magnifier Window))
    -> Magnifier Window
    -> X (Maybe (Magnifier Window))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Magnifier Window -> Maybe (Magnifier Window)
    forall a. a -> Maybe a
    Just (Magnifier Window -> X (Maybe (Magnifier Window)))
    -> Magnifier Window -> X (Maybe (Magnifier Window))
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier Window
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag Int
    n             ((Double, Double)
    z (Double, Double) -> Double -> (Double, Double)
    forall b. Num b => (b, b) -> b -> (b, b)
    `addto` (-0.1)) Toggle
    On  MagnifyMaster
    t
                        | Just ToggleOff      <- SomeMessage -> Maybe MagnifyMsg
    forall m. Message m => SomeMessage -> Maybe m
    fromMessage SomeMessage
    m = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Magnifier Window) -> X (Maybe (Magnifier Window)))
    -> (Magnifier Window -> Maybe (Magnifier Window))
    -> Magnifier Window
    -> X (Maybe (Magnifier Window))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Magnifier Window -> Maybe (Magnifier Window)
    forall a. a -> Maybe a
    Just (Magnifier Window -> X (Maybe (Magnifier Window)))
    -> Magnifier Window -> X (Maybe (Magnifier Window))
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier Window
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag Int
    n             (Double, Double)
    z                  Toggle
    Off MagnifyMaster
    t
                        | Just Toggle         <- SomeMessage -> Maybe MagnifyMsg
    forall m. Message m => SomeMessage -> Maybe m
    fromMessage SomeMessage
    m = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Magnifier Window) -> X (Maybe (Magnifier Window)))
    -> (Magnifier Window -> Maybe (Magnifier Window))
    -> Magnifier Window
    -> X (Maybe (Magnifier Window))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Magnifier Window -> Maybe (Magnifier Window)
    forall a. a -> Maybe a
    Just (Magnifier Window -> X (Maybe (Magnifier Window)))
    -> Magnifier Window -> X (Maybe (Magnifier Window))
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier Window
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag Int
    n             (Double, Double)
    z                  Toggle
    Off MagnifyMaster
    t
                        | Just (IncMasterN d :: Int
    d) <- SomeMessage -> Maybe IncMasterN
    forall m. Message m => SomeMessage -> Maybe m
    fromMessage SomeMessage
    m = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Magnifier Window) -> X (Maybe (Magnifier Window)))
    -> (Magnifier Window -> Maybe (Magnifier Window))
    -> Magnifier Window
    -> X (Maybe (Magnifier Window))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Magnifier Window -> Maybe (Magnifier Window)
    forall a. a -> Maybe a
    Just (Magnifier Window -> X (Maybe (Magnifier Window)))
    -> Magnifier Window -> X (Maybe (Magnifier Window))
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier Window
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag (Int -> Int -> Int
    forall a. Ord a => a -> a -> a
    max 0 (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    +Int
    d)) (Double, Double)
    z                  Toggle
    On  MagnifyMaster
    t
                        where addto :: (b, b) -> b -> (b, b)
    addto (x :: b
    x,y :: b
    y) i :: b
    i = (b
    xb -> b -> b
    forall a. Num a => a -> a -> a
    +b
    i,b
    yb -> b -> b
    forall a. Num a => a -> a -> a
    +b
    i)
        handleMess (Mag n :: Int
    n z :: (Double, Double)
    z Off t :: MagnifyMaster
    t) m :: SomeMessage
    m
                        | Just ToggleOn       <- SomeMessage -> Maybe MagnifyMsg
    forall m. Message m => SomeMessage -> Maybe m
    fromMessage SomeMessage
    m = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Magnifier Window) -> X (Maybe (Magnifier Window)))
    -> (Magnifier Window -> Maybe (Magnifier Window))
    -> Magnifier Window
    -> X (Maybe (Magnifier Window))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Magnifier Window -> Maybe (Magnifier Window)
    forall a. a -> Maybe a
    Just (Magnifier Window -> X (Maybe (Magnifier Window)))
    -> Magnifier Window -> X (Maybe (Magnifier Window))
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier Window
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag Int
    n             (Double, Double)
    z                  Toggle
    On  MagnifyMaster
    t
                        | Just Toggle         <- SomeMessage -> Maybe MagnifyMsg
    forall m. Message m => SomeMessage -> Maybe m
    fromMessage SomeMessage
    m = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Magnifier Window) -> X (Maybe (Magnifier Window)))
    -> (Magnifier Window -> Maybe (Magnifier Window))
    -> Magnifier Window
    -> X (Maybe (Magnifier Window))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Magnifier Window -> Maybe (Magnifier Window)
    forall a. a -> Maybe a
    Just (Magnifier Window -> X (Maybe (Magnifier Window)))
    -> Magnifier Window -> X (Maybe (Magnifier Window))
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier Window
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag Int
    n             (Double, Double)
    z                  Toggle
    On  MagnifyMaster
    t
                        | Just (IncMasterN d :: Int
    d) <- SomeMessage -> Maybe IncMasterN
    forall m. Message m => SomeMessage -> Maybe m
    fromMessage SomeMessage
    m = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe (Magnifier Window) -> X (Maybe (Magnifier Window)))
    -> (Magnifier Window -> Maybe (Magnifier Window))
    -> Magnifier Window
    -> X (Maybe (Magnifier Window))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Magnifier Window -> Maybe (Magnifier Window)
    forall a. a -> Maybe a
    Just (Magnifier Window -> X (Maybe (Magnifier Window)))
    -> Magnifier Window -> X (Maybe (Magnifier Window))
    forall a b. (a -> b) -> a -> b
    $ Int
    -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier Window
    forall a.
    Int -> (Double, Double) -> Toggle -> MagnifyMaster -> Magnifier a
    Mag (Int -> Int -> Int
    forall a. Ord a => a -> a -> a
    max 0 (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    +Int
    d)) (Double, Double)
    z                  Toggle
    Off MagnifyMaster
    t
        handleMess _ _ = Maybe (Magnifier Window) -> X (Maybe (Magnifier Window))
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe (Magnifier Window)
    forall a. Maybe a
    Nothing

        modifierDescription :: Magnifier Window -> String
    modifierDescription (Mag _ _ On  All     ) = "Magnifier"
        modifierDescription (Mag _ _ On  NoMaster) = "Magnifier NoMaster"
        modifierDescription (Mag _ _ Off _       ) = "Magnifier (off)"

    type NewLayout a = Rectangle -> Stack a -> [(Window, Rectangle)] -> X ([(Window, Rectangle)], Maybe (Magnifier a))

    unlessMaster :: Int -> NewLayout a -> NewLayout a
    unlessMaster :: Int -> NewLayout a -> NewLayout a
    unlessMaster n :: Int
    n mainmod :: NewLayout a
    mainmod r :: Rectangle
    r s :: Stack a
    s wrs :: [(Window, Rectangle)]
    wrs = if [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null (Int -> [a] -> [a]
    forall a. Int -> [a] -> [a]
    drop (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -1) (Stack a -> [a]
    forall a. Stack a -> [a]
    up Stack a
    s)) then ([(Window, Rectangle)], Maybe (Magnifier a))
    -> X ([(Window, Rectangle)], Maybe (Magnifier a))
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([(Window, Rectangle)]
    wrs, Maybe (Magnifier a)
    forall a. Maybe a
    Nothing)
                                                                 else NewLayout a
    mainmod Rectangle
    r Stack a
    s [(Window, Rectangle)]
    wrs

    applyMagnifier :: (Double,Double) -> Rectangle -> t -> [(Window, Rectangle)]
                   -> X ([(Window, Rectangle)], Maybe a)
    applyMagnifier :: (Double, Double)
    -> Rectangle
    -> t
    -> [(Window, Rectangle)]
    -> X ([(Window, Rectangle)], Maybe a)
    applyMagnifier z :: (Double, Double)
    z r :: Rectangle
    r _ wrs :: [(Window, Rectangle)]
    wrs = do Maybe Window
    focused <- (WindowSet -> X (Maybe Window)) -> X (Maybe Window)
    forall a. (WindowSet -> X a) -> X a
    withWindowSet (Maybe Window -> X (Maybe Window)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Maybe Window -> X (Maybe Window))
    -> (WindowSet -> Maybe Window) -> WindowSet -> X (Maybe Window)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . WindowSet -> Maybe Window
    forall i l a s sd. StackSet i l a s sd -> Maybe a
    peek)
                                  let mag :: (Window, Rectangle)
    -> [(Window, Rectangle)] -> [(Window, Rectangle)]
    mag (w :: Window
    w,wr :: Rectangle
    wr) ws :: [(Window, Rectangle)]
    ws | Maybe Window
    focused Maybe Window -> Maybe Window -> Bool
    forall a. Eq a => a -> a -> Bool
    == Window -> Maybe Window
    forall a. a -> Maybe a
    Just Window
    w = [(Window, Rectangle)]
    ws [(Window, Rectangle)]
    -> [(Window, Rectangle)] -> [(Window, Rectangle)]
    forall a. [a] -> [a] -> [a]
    ++ [(Window
    w, Rectangle -> Rectangle -> Rectangle
    fit Rectangle
    r (Rectangle -> Rectangle) -> Rectangle -> Rectangle
    forall a b. (a -> b) -> a -> b
    $ (Double, Double) -> Rectangle -> Rectangle
    magnify (Double, Double)
    z Rectangle
    wr)]
                                                    | Bool
    otherwise         = (Window
    w,Rectangle
    wr) (Window, Rectangle)
    -> [(Window, Rectangle)] -> [(Window, Rectangle)]
    forall a. a -> [a] -> [a]
    : [(Window, Rectangle)]
    ws
                                  ([(Window, Rectangle)], Maybe a)
    -> X ([(Window, Rectangle)], Maybe a)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([(Window, Rectangle)] -> [(Window, Rectangle)]
    forall a. [a] -> [a]
    reverse ([(Window, Rectangle)] -> [(Window, Rectangle)])
    -> [(Window, Rectangle)] -> [(Window, Rectangle)]
    forall a b. (a -> b) -> a -> b
    $ ((Window, Rectangle)
     -> [(Window, Rectangle)] -> [(Window, Rectangle)])
    -> [(Window, Rectangle)]
    -> [(Window, Rectangle)]
    -> [(Window, Rectangle)]
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr (Window, Rectangle)
    -> [(Window, Rectangle)] -> [(Window, Rectangle)]
    mag [] [(Window, Rectangle)]
    wrs, Maybe a
    forall a. Maybe a
    Nothing)

    magnify :: (Double, Double) -> Rectangle -> Rectangle
    magnify :: (Double, Double) -> Rectangle -> Rectangle
    magnify (zoomx :: Double
    zoomx,zoomy :: Double
    zoomy) (Rectangle x :: Position
    x y :: Position
    y w :: Dimension
    w h :: Dimension
    h) = Position -> Position -> Dimension -> Dimension -> Rectangle
    Rectangle Position
    x' Position
    y' Dimension
    w' Dimension
    h'
        where x' :: Position
    x' = Position
    x Position -> Position -> Position
    forall a. Num a => a -> a -> a
    - Dimension -> Position
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Dimension
    w' Dimension -> Dimension -> Dimension
    forall a. Num a => a -> a -> a
    - Dimension
    w) Position -> Position -> Position
    forall a. Integral a => a -> a -> a
    `div` 2
              y' :: Position
    y' = Position
    y Position -> Position -> Position
    forall a. Num a => a -> a -> a
    - Dimension -> Position
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Dimension
    h' Dimension -> Dimension -> Dimension
    forall a. Num a => a -> a -> a
    - Dimension
    h) Position -> Position -> Position
    forall a. Integral a => a -> a -> a
    `div` 2
              w' :: Dimension
    w' = Double -> Dimension
    forall a b. (RealFrac a, Integral b) => a -> b
    round (Double -> Dimension) -> Double -> Dimension
    forall a b. (a -> b) -> a -> b
    $ Dimension -> Double
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Dimension
    w Double -> Double -> Double
    forall a. Num a => a -> a -> a
    * Double
    zoomx
              h' :: Dimension
    h' = Double -> Dimension
    forall a b. (RealFrac a, Integral b) => a -> b
    round (Double -> Dimension) -> Double -> Dimension
    forall a b. (a -> b) -> a -> b
    $ Dimension -> Double
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Dimension
    h Double -> Double -> Double
    forall a. Num a => a -> a -> a
    * Double
    zoomy

    fit :: Rectangle -> Rectangle -> Rectangle
    fit :: Rectangle -> Rectangle -> Rectangle
    fit (Rectangle sx :: Position
    sx sy :: Position
    sy sw :: Dimension
    sw sh :: Dimension
    sh) (Rectangle x :: Position
    x y :: Position
    y w :: Dimension
    w h :: Dimension
    h) = Position -> Position -> Dimension -> Dimension -> Rectangle
    Rectangle Position
    x' Position
    y' Dimension
    w' Dimension
    h'
        where x' :: Position
    x' = Position -> Position -> Position
    forall a. Ord a => a -> a -> a
    max Position
    sx (Position
    x Position -> Position -> Position
    forall a. Num a => a -> a -> a
    - (Position -> Position -> Position
    forall a. Ord a => a -> a -> a
    max 0 (Position
    x Position -> Position -> Position
    forall a. Num a => a -> a -> a
    + Dimension -> Position
    forall a b. (Integral a, Num b) => a -> b
    fi Dimension
    w Position -> Position -> Position
    forall a. Num a => a -> a -> a
    - Position
    sx Position -> Position -> Position
    forall a. Num a => a -> a -> a
    - Dimension -> Position
    forall a b. (Integral a, Num b) => a -> b
    fi Dimension
    sw)))
              y' :: Position
    y' = Position -> Position -> Position
    forall a. Ord a => a -> a -> a
    max Position
    sy (Position
    y Position -> Position -> Position
    forall a. Num a => a -> a -> a
    - (Position -> Position -> Position
    forall a. Ord a => a -> a -> a
    max 0 (Position
    y Position -> Position -> Position
    forall a. Num a => a -> a -> a
    + Dimension -> Position
    forall a b. (Integral a, Num b) => a -> b
    fi Dimension
    h Position -> Position -> Position
    forall a. Num a => a -> a -> a
    - Position
    sy Position -> Position -> Position
    forall a. Num a => a -> a -> a
    - Dimension -> Position
    forall a b. (Integral a, Num b) => a -> b
    fi Dimension
    sh)))
              w' :: Dimension
    w' = Dimension -> Dimension -> Dimension
    forall a. Ord a => a -> a -> a
    min Dimension
    sw Dimension
    w
              h' :: Dimension
    h' = Dimension -> Dimension -> Dimension
    forall a. Ord a => a -> a -> a
    min Dimension
    sh Dimension
    h