aboutsummaryrefslogtreecommitdiffstats
path: root/Magnifier.hs
diff options
context:
space:
mode:
authorPeter De Wachter <pdewacht@gmail.com>2007-06-14 22:32:19 +0200
committerPeter De Wachter <pdewacht@gmail.com>2007-06-14 22:32:19 +0200
commit483e6dc13bce446443ecbe980740803f31251e61 (patch)
tree96f791424a2cf65a4013982e807367ca884a8970 /Magnifier.hs
parent14d623d780af79243097adbd531256885731008e (diff)
downloadXMonadContrib-483e6dc13bce446443ecbe980740803f31251e61.tar.gz
XMonadContrib-483e6dc13bce446443ecbe980740803f31251e61.tar.xz
XMonadContrib-483e6dc13bce446443ecbe980740803f31251e61.zip
Magnifier layout hack
This layout hack increases the size of the window that has focus (the master window excepted). This causes it to overlap with nearby windows, so not for tiling purists :) Screenshot: http://caladan.rave.org/magnifier.png darcs-hash:20070614203219-06a25-a68f17a556c9fa11c486970717e1bab28273eab2.gz
Diffstat (limited to 'Magnifier.hs')
-rw-r--r--Magnifier.hs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Magnifier.hs b/Magnifier.hs
new file mode 100644
index 0000000..3f378ff
--- /dev/null
+++ b/Magnifier.hs
@@ -0,0 +1,47 @@
+-----------------------------------------------------------------------------
+-- |
+-- 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.
+-- The master window is left alone. (Maybe that should be an option.)
+--
+--
+-----------------------------------------------------------------------------
+
+
+module XMonadContrib.Magnifier (magnifier) where
+
+import Graphics.X11.Xlib
+import XMonad
+import StackSet
+
+magnifier :: Layout -> Layout
+magnifier l = l { doLayout = \r s -> applyMagnifier r s `fmap` doLayout l r s
+ , modifyLayout = \x -> fmap magnifier `fmap` modifyLayout l x }
+
+applyMagnifier :: Rectangle -> Stack Window -> [(Window, Rectangle)] -> [(Window, 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)
+
+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')