aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-10-24 00:00:25 +0200
committerDavid Roundy <droundy@darcs.net>2007-10-24 00:00:25 +0200
commiteeda11be4ab1292fb3c9f0e7e5997d1542cfcf3f (patch)
treecd5b3ebbba538877dbd97f5f8bffd6ecf521468c
parentaa9df9970c262b1e4ff0e349e5f28e1fdb73b460 (diff)
downloadXMonadContrib-eeda11be4ab1292fb3c9f0e7e5997d1542cfcf3f.tar.gz
XMonadContrib-eeda11be4ab1292fb3c9f0e7e5997d1542cfcf3f.tar.xz
XMonadContrib-eeda11be4ab1292fb3c9f0e7e5997d1542cfcf3f.zip
code to define a strut-avoiding layout.
darcs-hash:20071023220025-72aca-a741feec986227fcd60d4a7e09be98f163d6b118.gz
-rw-r--r--ManageDocks.hs19
1 files changed, 19 insertions, 0 deletions
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