mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-01 04:31:52 -07:00
This modifies all the contrib modules to work (so far as I know) with the new contrib layout. The exception is the LayoutHooks module, which isn't used. It exports an API that is inherently unsafe, so far as I can tell (and always has been).
64 lines
2.2 KiB
Haskell
64 lines
2.2 KiB
Haskell
{-# OPTIONS_GHC -fglasgow-exts #-}
|
|
-----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : XMonadContrib.Magnifier
|
|
-- Copyright : (c) Peter De Wachter 2007
|
|
-- License : BSD-style (see xmonad/LICENSE)
|
|
--
|
|
-- Maintainer : Peter De Wachter <pdewacht@gmail.com>
|
|
-- Stability : unstable
|
|
-- Portability : unportable
|
|
--
|
|
-- Screenshot : <http://caladan.rave.org/magnifier.png>
|
|
--
|
|
-- This layout hack increases the size of the window that has focus.
|
|
--
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
|
module XMonadContrib.Magnifier (
|
|
-- * Usage
|
|
-- $usage
|
|
magnifier, magnifier') where
|
|
|
|
import Graphics.X11.Xlib
|
|
import XMonad
|
|
import StackSet
|
|
import XMonadContrib.LayoutHelpers
|
|
|
|
-- $usage
|
|
-- > 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 = layoutModify (unlessMaster applyMagnifier) idModMod
|
|
|
|
-- | Increase the size of the window that has focus, even if it is the master window.
|
|
magnifier' :: Eq a => Layout a -> Layout a
|
|
magnifier' = layoutModify applyMagnifier idModMod
|
|
|
|
unlessMaster :: ModDo a -> ModDo a
|
|
unlessMaster mainmod r s wrs = if null (up s) then return (wrs, Nothing)
|
|
else mainmod r s wrs
|
|
|
|
applyMagnifier :: Eq a => ModDo a
|
|
applyMagnifier r s wrs = return (map mag wrs, Nothing)
|
|
where mag (w,wr) | w == focus s = (w, shrink r $ magnify wr)
|
|
| otherwise = (w,wr)
|
|
|
|
magnify :: Rectangle -> Rectangle
|
|
magnify (Rectangle x y w h) = Rectangle x' y' w' h'
|
|
where x' = x - fromIntegral (w' - w) `div` 2
|
|
y' = y - fromIntegral (h' - h) `div` 2
|
|
w' = round $ fromIntegral w * zoom
|
|
h' = round $ fromIntegral h * zoom
|
|
zoom = 1.5 :: Double
|
|
|
|
shrink :: Rectangle -> Rectangle -> Rectangle
|
|
shrink (Rectangle sx sy sw sh) (Rectangle x y w h) = Rectangle x' y' w' h'
|
|
where x' = max sx x
|
|
y' = max sy y
|
|
w' = min w (fromIntegral sx + sw - fromIntegral x')
|
|
h' = min h (fromIntegral sy + sh - fromIntegral y')
|