From eeda11be4ab1292fb3c9f0e7e5997d1542cfcf3f Mon Sep 17 00:00:00 2001 From: David Roundy Date: Wed, 24 Oct 2007 00:00:25 +0200 Subject: code to define a strut-avoiding layout. darcs-hash:20071023220025-72aca-a741feec986227fcd60d4a7e09be98f163d6b118.gz --- ManageDocks.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ManageDocks.hs b/ManageDocks.hs index 13aa7db..b9f9aec 100644 --- a/ManageDocks.hs +++ b/ManageDocks.hs @@ -22,6 +22,7 @@ module XMonadContrib.ManageDocks ( manageDocksHook ,resetGap ,toggleGap + ,avoidStruts ) where import Control.Monad.Reader @@ -132,3 +133,21 @@ toggleGap = do -- Piecewise maximum of a 4-tuple of Ints max4 :: (Int, Int, Int, Int) -> (Int, Int, Int, Int) -> (Int, Int, Int, Int) max4 (a1,a2,a3,a4) (b1,b2,b3,b4) = (max a1 b1, max a2 b2, max a3 b3, max a4 b4) + +-- | Adjust layout automagically. +avoidStruts :: LayoutClass l a => l a -> AvoidStruts l a +avoidStruts = AvoidStruts + +data AvoidStruts l a = AvoidStruts (l a) deriving ( Read, Show ) + +instance LayoutClass l a => LayoutClass (AvoidStruts l) a where + doLayout (AvoidStruts lo) (Rectangle x y w h) s = + do (t,l,b,r) <- calcGap + let rect = Rectangle (x+10+fromIntegral l) (y+fromIntegral t) + (w-fromIntegral l-fromIntegral r) (h-fromIntegral t-fromIntegral b) + (wrs,mlo') <- doLayout lo rect s + return (wrs, AvoidStruts `fmap` mlo') + handleMessage (AvoidStruts l) m = + do ml' <- handleMessage l m + return (AvoidStruts `fmap` ml') + description (AvoidStruts l) = description l -- cgit v1.2.3