From 9697f1792eca6bd968c4abed7adda45b37236305 Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Sat, 29 Sep 2007 03:09:46 +0200 Subject: Add smartBorders darcs-hash:20070929010946-a5988-c2b8952b46d30c05e1ec88d692d312b464de4f01.gz --- NoBorders.hs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/NoBorders.hs b/NoBorders.hs index e6b3a24..df0167d 100644 --- a/NoBorders.hs +++ b/NoBorders.hs @@ -21,6 +21,7 @@ module XMonadContrib.NoBorders ( -- * Usage -- $usage noBorders, + smartBorders, withBorder ) where @@ -70,3 +71,23 @@ withBorder b = ModifiedLayout $ WithBorder b [] setBorders :: Dimension -> [Window] -> X () setBorders bw ws = withDisplay $ \d -> mapM_ (\w -> io $ setWindowBorderWidth d w bw) ws + +data SmartBorder a = SmartBorder [a] deriving (Read, Show) + +instance LayoutModifier SmartBorder Window where + modifierDescription _ = "SmartBorder" + + unhook (SmartBorder s) = setBorders borderWidth s + + redoLayout (SmartBorder s) _ stack wrs = do + ss <- gets (W.screens . windowset) + setBorders borderWidth s + + if singleton ws && singleton ss + then do setBorders 0 ws; return (wrs, Just $ SmartBorder ws) + else return (wrs, Just $ SmartBorder []) + where + ws = map fst wrs + singleton = null . drop 1 + +smartBorders = ModifiedLayout (SmartBorder []) -- cgit v1.2.3