Port NoBorders

This commit is contained in:
Spencer Janssen
2007-11-01 07:08:59 +00:00
parent bd97249b22
commit 0b681cadc2

View File

@@ -26,11 +26,11 @@ module XMonadContrib.NoBorders (
) where ) where
import Control.Monad.State (gets) import Control.Monad.State (gets)
import Control.Monad.Reader (asks)
import Graphics.X11.Xlib import Graphics.X11.Xlib
import XMonad import XMonad
import XMonadContrib.LayoutModifier import XMonadContrib.LayoutModifier
import {-# SOURCE #-} Config (borderWidth)
import qualified StackSet as W import qualified StackSet as W
import Data.List ((\\)) import Data.List ((\\))
@@ -56,11 +56,11 @@ instance LayoutModifier WithBorder Window where
modifierDescription (WithBorder 0 _) = "NoBorders" modifierDescription (WithBorder 0 _) = "NoBorders"
modifierDescription (WithBorder n _) = "Borders " ++ show n modifierDescription (WithBorder n _) = "Borders " ++ show n
unhook (WithBorder _ s) = setBorders borderWidth s unhook (WithBorder _ s) = asks borderWidth >>= setBorders s
redoLayout (WithBorder n s) _ _ wrs = do redoLayout (WithBorder n s) _ _ wrs = do
setBorders borderWidth (s \\ ws) asks borderWidth >>= setBorders (s \\ ws)
setBorders n ws setBorders ws n
return (wrs, Just $ WithBorder n ws) return (wrs, Just $ WithBorder n ws)
where where
ws = map fst wrs ws = map fst wrs
@@ -71,26 +71,26 @@ noBorders = ModifiedLayout $ WithBorder 0 []
withBorder :: LayoutClass l a => Dimension -> l a -> ModifiedLayout WithBorder l a withBorder :: LayoutClass l a => Dimension -> l a -> ModifiedLayout WithBorder l a
withBorder b = ModifiedLayout $ WithBorder b [] withBorder b = ModifiedLayout $ WithBorder b []
setBorders :: Dimension -> [Window] -> X () setBorders :: [Window] -> Dimension -> X ()
setBorders bw ws = withDisplay $ \d -> mapM_ (\w -> io $ setWindowBorderWidth d w bw) ws setBorders ws bw = withDisplay $ \d -> mapM_ (\w -> io $ setWindowBorderWidth d w bw) ws
data SmartBorder a = SmartBorder [a] deriving (Read, Show) data SmartBorder a = SmartBorder [a] deriving (Read, Show)
instance LayoutModifier SmartBorder Window where instance LayoutModifier SmartBorder Window where
modifierDescription _ = "SmartBorder" modifierDescription _ = "SmartBorder"
unhook (SmartBorder s) = setBorders borderWidth s unhook (SmartBorder s) = asks borderWidth >>= setBorders s
redoLayout (SmartBorder s) _ _ wrs = do redoLayout (SmartBorder s) _ _ wrs = do
ss <- gets (W.screens . windowset) ss <- gets (W.screens . windowset)
if singleton ws && singleton ss if singleton ws && singleton ss
then do then do
setBorders borderWidth (s \\ ws) asks borderWidth >>= setBorders (s \\ ws)
setBorders 0 ws setBorders ws 0
return (wrs, Just $ SmartBorder ws) return (wrs, Just $ SmartBorder ws)
else do else do
setBorders borderWidth s asks borderWidth >>= setBorders s
return (wrs, Just $ SmartBorder []) return (wrs, Just $ SmartBorder [])
where where
ws = map fst wrs ws = map fst wrs