From 9054c793f8fc5fc7c9289a9d6be8ebd0cf6db54c Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Fri, 28 Sep 2007 19:46:15 +0200 Subject: Various fixes to NoBorders. Hopefully fixes bug #42 darcs-hash:20070928174615-a5988-7f41b07cf9254165d4e98daa41a3648157878409.gz --- NoBorders.hs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/NoBorders.hs b/NoBorders.hs index 085770e..e6b3a24 100644 --- a/NoBorders.hs +++ b/NoBorders.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE FlexibleInstances #-} + ----------------------------------------------------------------------------- -- | -- Module : XMonadContrib.NoBorders @@ -44,19 +46,27 @@ import qualified StackSet as W -- %layout -- prepend noBorders to default layouts above to remove their borders, like so: -- %layout , noBorders full -data WithBorder a = WithBorder Dimension deriving ( Read, Show ) +-- todo, use an InvisibleList. +data WithBorder a = WithBorder Dimension [a] deriving ( Read, Show ) + +instance LayoutModifier WithBorder Window where + modifierDescription (WithBorder 0 _) = "NoBorders" + modifierDescription (WithBorder n _) = "Borders " ++ show n + + unhook (WithBorder _ s) = setBorders borderWidth s -instance LayoutModifier WithBorder a where - hook (WithBorder b) = setborders b - unhook (WithBorder _) = setborders borderWidth + redoLayout (WithBorder n s) _ stack wrs = do + setBorders borderWidth s + setBorders n ws + return (wrs, Just $ WithBorder n ws) + where + ws = map fst wrs -noBorders :: Layout l a => l a -> ModifiedLayout WithBorder l a -noBorders = ModifiedLayout (WithBorder 0) +noBorders :: Layout l Window => l Window -> ModifiedLayout WithBorder l Window +noBorders = ModifiedLayout $ WithBorder 0 [] withBorder :: Layout l a => Dimension -> l a -> ModifiedLayout WithBorder l a -withBorder b = ModifiedLayout (WithBorder b) +withBorder b = ModifiedLayout $ WithBorder b [] -setborders :: Dimension -> X () -setborders bw = withDisplay $ \d -> - do ws <- gets (W.integrate' . W.stack . W.workspace . W.current . windowset) - mapM_ (\w -> io $ setWindowBorderWidth d w bw) ws +setBorders :: Dimension -> [Window] -> X () +setBorders bw ws = withDisplay $ \d -> mapM_ (\w -> io $ setWindowBorderWidth d w bw) ws -- cgit v1.2.3