aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Hooks
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-11-13 21:34:34 +0100
committerDavid Roundy <droundy@darcs.net>2007-11-13 21:34:34 +0100
commitd1344ae3931b40d5d9dd7df3286d59f7e7940763 (patch)
treed0245bcb04b9bfb7b7b98644f52b41d88a05a173 /XMonad/Hooks
parente82edf4b4fb7b366a99201555b888beb6067a865 (diff)
downloadXMonadContrib-d1344ae3931b40d5d9dd7df3286d59f7e7940763.tar.gz
XMonadContrib-d1344ae3931b40d5d9dd7df3286d59f7e7940763.tar.xz
XMonadContrib-d1344ae3931b40d5d9dd7df3286d59f7e7940763.zip
add ToggleStruts capability to avoidStruts.
darcs-hash:20071113203434-72aca-760330df77f5c8f60507321ab9bb648284f8c7ce.gz
Diffstat (limited to 'XMonad/Hooks')
-rw-r--r--XMonad/Hooks/ManageDocks.hs27
1 files changed, 18 insertions, 9 deletions
diff --git a/XMonad/Hooks/ManageDocks.hs b/XMonad/Hooks/ManageDocks.hs
index 442d3b0..987e59b 100644
--- a/XMonad/Hooks/ManageDocks.hs
+++ b/XMonad/Hooks/ManageDocks.hs
@@ -26,6 +26,9 @@
-- > layoutHook = Layout $ toggleLayouts (noBorders Full) $ avoidStruts $
-- > your actual layouts here ||| ...
+-- You may also wish to bind a key to sendMessage ToggleStruts, which will
+-- toggle the avoidStruts behavior, so you can hide your panel at will.
+
-- This would enable a full-screen mode that overlaps the panel, while all
-- other layouts avoid the panel.
@@ -36,7 +39,7 @@ module XMonad.Hooks.ManageDocks (
manageDocksHook
,resetGap
,toggleGap
- ,avoidStruts
+ ,avoidStruts, ToggleStruts(ToggleStruts)
) where
import Control.Monad.Reader
@@ -150,18 +153,24 @@ 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
+avoidStruts = AvoidStruts True
+
+data AvoidStruts l a = AvoidStruts Bool (l a) deriving ( Read, Show )
-data AvoidStruts l a = AvoidStruts (l a) deriving ( Read, Show )
+data ToggleStruts = ToggleStruts deriving (Read,Show,Typeable)
+instance Message ToggleStruts
instance LayoutClass l a => LayoutClass (AvoidStruts l) a where
- doLayout (AvoidStruts lo) (Rectangle x y w h) s =
+ doLayout (AvoidStruts True lo) (Rectangle x y w h) s =
do (t,b,l,r) <- calcGap
let rect = Rectangle (x+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
+ return (wrs, AvoidStruts True `fmap` mlo')
+ doLayout (AvoidStruts False lo) r s = do (wrs,mlo') <- doLayout lo r s
+ return (wrs, AvoidStruts False `fmap` mlo')
+ handleMessage (AvoidStruts b l) m
+ | Just ToggleStruts <- fromMessage m = return $ Just $ AvoidStruts (not b) l
+ | otherwise = do ml' <- handleMessage l m
+ return (AvoidStruts b `fmap` ml')
+ description (AvoidStruts _ l) = description l