From 862f79967c00eb0ee3aaff20aebe17603b414ef4 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Thu, 22 Nov 2007 20:01:24 +0100 Subject: Magnifier: some fixes and refactoring. It now works properly. darcs-hash:20071122190124-32816-6e6366a5b0a872479bdd2d06c8b29952c66adff7.gz --- XMonad/Layout/Magnifier.hs | 56 ++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'XMonad') diff --git a/XMonad/Layout/Magnifier.hs b/XMonad/Layout/Magnifier.hs index 823cfca..633bd65 100644 --- a/XMonad/Layout/Magnifier.hs +++ b/XMonad/Layout/Magnifier.hs @@ -1,18 +1,19 @@ {-# OPTIONS_GHC -fglasgow-exts #-} - ----------------------------------------------------------------------------- -- | -- Module : XMonad.Layout.Magnifier -- Copyright : (c) Peter De Wachter 2007 -- License : BSD-style (see xmonad/LICENSE) -- --- Maintainer : Peter De Wachter +-- Maintainer : Peter De Wachter , +-- andrea.rossato@unibz.it -- Stability : unstable -- Portability : unportable -- -- Screenshot : -- --- This layout hack increases the size of the window that has focus. +-- This is a layout modifier that will make a layout increase the size +-- of the window that has focus. -- ----------------------------------------------------------------------------- @@ -21,8 +22,7 @@ module XMonad.Layout.Magnifier ( -- * Usage -- $usage magnifier, - Magnifier(..), - Magnifier'(..)) where + magnifier') where import Graphics.X11.Xlib (Window, Rectangle(..)) import XMonad @@ -30,29 +30,41 @@ import XMonad.StackSet import XMonad.Layout.LayoutModifier -- $usage +-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: +-- -- > import XMonad.Layout.Magnifier --- > layouts = [ magnifier tiled , magnifier $ mirror tiled ] +-- +-- Then edit your @layoutHook@ by adding the Magnifier layout modifier +-- to some layout: +-- +-- > myLayouts = magnifier (Tall 1 (3/100) (1/2)) ||| Full ||| etc.. +-- > main = xmonad dafaultConfig { layoutHook = myLayouts } +-- +-- For more detailed instructions on editing the layoutHook see: +-- +-- "XMonad.Doc.Extending#Editing_the_layout_hook" --- %import XMonad.Layout.Magnifier --- %layout , magnifier tiled --- %layout , magnifier $ mirror tiled +-- | Increase the size of the window that has focus, unless it is the +-- master window. +magnifier :: l a -> ModifiedLayout Magnifier l a +magnifier = ModifiedLayout (M True) --- | Increase the size of the window that has focus, unless it is the master window. -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' :: l a -> ModifiedLayout Magnifier l a +magnifier' = ModifiedLayout (M False) --- | Increase the size of the window that has focus, even if it is the master window. -data Magnifier' a = Magnifier' deriving (Read, Show) -instance LayoutModifier Magnifier' Window where - modifierDescription _ = "Magnifier'" - redoLayout _ = applyMagnifier +data Magnifier a = M Bool deriving (Read, Show) -magnifier :: l a -> ModifiedLayout Magnifier l a -magnifier = ModifiedLayout Magnifier +instance LayoutModifier Magnifier Window where + modifierDescription (M b) = (if b then "" else "All") ++ "Magnifier" + redoLayout (M b) = if b + then unlessMaster applyMagnifier + else applyMagnifier + +type NewLayout a = Rectangle -> Stack a -> [(Window, Rectangle)] -> X ([(Window, Rectangle)], Maybe (Magnifier a)) -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 :: NewLayout a -> NewLayout a unlessMaster mainmod r s wrs = if null (up s) then return (wrs, Nothing) else mainmod r s wrs -- cgit v1.2.3