mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
new layout module X.L.Spacing, put blank space around each window
This commit is contained in:
parent
a3f931262b
commit
2eb98c1437
54
XMonad/Layout/Spacing.hs
Normal file
54
XMonad/Layout/Spacing.hs
Normal file
@ -0,0 +1,54 @@
|
||||
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- |
|
||||
-- Module : XMonad.Layout.Spacing
|
||||
-- Copyright : (c) Brent Yorgey
|
||||
-- License : BSD-style (see LICENSE)
|
||||
--
|
||||
-- Maintainer : <byorgey@gmail.com>
|
||||
-- Stability : unstable
|
||||
-- Portability : portable
|
||||
--
|
||||
-- Add a configurable amount of space around windows.
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
module XMonad.Layout.Spacing (
|
||||
-- * Usage
|
||||
-- $usage
|
||||
|
||||
spacing
|
||||
|
||||
) where
|
||||
|
||||
import Graphics.X11 (Rectangle(..))
|
||||
import Control.Arrow (second)
|
||||
|
||||
import XMonad.Layout.LayoutModifier
|
||||
|
||||
-- $usage
|
||||
-- You can use this module by importing it into your @~\/.xmonad\/xmonad.hs@ file:
|
||||
--
|
||||
-- > import XMonad.Layout.Spacing
|
||||
--
|
||||
-- and modifying your layoutHook as follows (for example):
|
||||
--
|
||||
-- > layoutHook = spacing 2 $ Tall 1 (3/100) (1/2)
|
||||
-- > -- put a 2px space around every window
|
||||
--
|
||||
|
||||
-- | Surround all windows by a certain number of pixels of blank space.
|
||||
spacing :: Int -> l a -> ModifiedLayout Spacing l a
|
||||
spacing p = ModifiedLayout (Spacing p)
|
||||
|
||||
data Spacing a = Spacing Int deriving (Show, Read)
|
||||
|
||||
instance LayoutModifier Spacing a where
|
||||
|
||||
pureModifier (Spacing p) _ _ wrs = (map (second $ shrinkRect p) wrs, Nothing)
|
||||
|
||||
modifierDescription (Spacing p) = "Spacing " ++ show p
|
||||
|
||||
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)
|
||||
where fi n = fromIntegral n -- avoid the DMR
|
@ -172,6 +172,7 @@ library
|
||||
XMonad.Layout.Simplest
|
||||
XMonad.Layout.SimpleDecoration
|
||||
XMonad.Layout.SimpleFloat
|
||||
XMonad.Layout.Spacing
|
||||
XMonad.Layout.Spiral
|
||||
XMonad.Layout.Square
|
||||
XMonad.Layout.ShowWName
|
||||
|
Loading…
x
Reference in New Issue
Block a user