From cabf7d96ae1026e5f69a106f5cabe4c183c30298 Mon Sep 17 00:00:00 2001 From: daedalusinfinity Date: Sun, 23 Sep 2012 05:45:27 +0200 Subject: Added smart spacing to the spacing module Ignore-this: 9104bc8feb832f63f2f18998c0f7ba92 Added smart spacing to the spacing module, which adds spacing to all windows, except to windows on singleton workspaces. darcs-hash:20120923034527-6243b-e3036a0e7e350648026148a4ff0d25db40358e52.gz --- XMonad/Layout/Spacing.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'XMonad/Layout') diff --git a/XMonad/Layout/Spacing.hs b/XMonad/Layout/Spacing.hs index 6a2ba2c..609c858 100644 --- a/XMonad/Layout/Spacing.hs +++ b/XMonad/Layout/Spacing.hs @@ -18,6 +18,7 @@ module XMonad.Layout.Spacing ( -- $usage spacing, Spacing, + smartSpacing, SmartSpacing, ) where @@ -52,3 +53,17 @@ instance LayoutModifier Spacing a where shrinkRect :: Int -> Rectangle -> Rectangle shrinkRect p (Rectangle x y w h) = Rectangle (x+fi p) (y+fi p) (w-2*fi p) (h-2*fi p) + +-- | Surrounds all windows with blank space, except when the window is the only +-- visible window on the current workspace. +smartSpacing :: Int -> l a -> ModifiedLayout SmartSpacing l a +smartSpacing p = ModifiedLayout (SmartSpacing p) + +data SmartSpacing a = SmartSpacing Int deriving (Show, Read) + +instance LayoutModifier SmartSpacing a where + + pureModifier _ _ _ [x] = ([x], Nothing) + pureModifier (SmartSpacing p) _ _ wrs = (map (second $ shrinkRect p) wrs, Nothing) + + modifierDescription (SmartSpacing p) = "SmartSpacing " ++ show p -- cgit v1.2.3