mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
'XMonad.Layout.Spacing': compatibility tweaks
* All the backwards-compatibility functions now accept `Int` rather than `Integer`: `spacing`, `spacingWithEdge`, `smartSpacing`, `smartSpacingWithEdge`, `setSpacing`, and `incSpacing`. Work done by @LSLeary. * Introduce the new functions `setScreenWindowSpacing`, `incScreenWindowSpacing`, `decScreenWindowSpacing`. Unlike their original `setSpacing`, `incSpacing` counterparts, these refresh no more than once. Requires `sendMessages` from my PR of `XMonad.Actions.MessageFeedback`. Suggestion by @LSLeary and implemented so any combination of messages can be sent without triggering unnecessary refreshes.
This commit is contained in:
parent
e0b1954e62
commit
2fde742e7a
@ -29,8 +29,10 @@ module XMonad.Layout.Spacing
|
|||||||
, toggleSmartSpacing
|
, toggleSmartSpacing
|
||||||
, toggleScreenSpacingEnabled
|
, toggleScreenSpacingEnabled
|
||||||
, toggleWindowSpacingEnabled
|
, toggleWindowSpacingEnabled
|
||||||
|
, setScreenWindowSpacing
|
||||||
, incWindowSpacing, incScreenSpacing
|
, incWindowSpacing, incScreenSpacing
|
||||||
, decWindowSpacing, decScreenSpacing
|
, decWindowSpacing, decScreenSpacing
|
||||||
|
, incScreenWindowSpacing, decScreenWindowSpacing
|
||||||
, borderIncrementBy
|
, borderIncrementBy
|
||||||
-- * Backwards Compatibility
|
-- * Backwards Compatibility
|
||||||
-- $backwardsCompatibility
|
-- $backwardsCompatibility
|
||||||
@ -41,8 +43,9 @@ module XMonad.Layout.Spacing
|
|||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.StackSet as W
|
import XMonad.StackSet as W
|
||||||
import XMonad.Layout.LayoutModifier
|
|
||||||
import qualified XMonad.Util.Rectangle as R
|
import qualified XMonad.Util.Rectangle as R
|
||||||
|
import XMonad.Layout.LayoutModifier
|
||||||
|
import XMonad.Actions.MessageFeedback
|
||||||
|
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
@ -235,6 +238,12 @@ toggleScreenSpacingEnabled = sendMessage $ ModifyScreenBorderEnabled not
|
|||||||
toggleWindowSpacingEnabled :: X ()
|
toggleWindowSpacingEnabled :: X ()
|
||||||
toggleWindowSpacingEnabled = sendMessage $ ModifyWindowBorderEnabled not
|
toggleWindowSpacingEnabled = sendMessage $ ModifyWindowBorderEnabled not
|
||||||
|
|
||||||
|
-- | Set all borders to a uniform size; see 'setWindowSpacing' and
|
||||||
|
-- 'setScreenSpacing'.
|
||||||
|
setScreenWindowSpacing :: Integer -> X ()
|
||||||
|
setScreenWindowSpacing = sendMessages . flip map [ModifyWindowBorder,ModifyScreenBorder]
|
||||||
|
. flip id . const . uniformBorder
|
||||||
|
|
||||||
-- | Increment the borders of 'windowBorder' using 'borderIncrementBy', which
|
-- | Increment the borders of 'windowBorder' using 'borderIncrementBy', which
|
||||||
-- preserves border ratios during clamping.
|
-- preserves border ratios during clamping.
|
||||||
incWindowSpacing :: Integer -> X ()
|
incWindowSpacing :: Integer -> X ()
|
||||||
@ -252,6 +261,20 @@ decWindowSpacing = incWindowSpacing . negate
|
|||||||
decScreenSpacing :: Integer -> X ()
|
decScreenSpacing :: Integer -> X ()
|
||||||
decScreenSpacing = incScreenSpacing . negate
|
decScreenSpacing = incScreenSpacing . negate
|
||||||
|
|
||||||
|
-- | Increment both screen and window borders; see 'incWindowSpacing' and
|
||||||
|
-- 'incScreenSpacing'.
|
||||||
|
incScreenWindowSpacing :: Integer -> X ()
|
||||||
|
incScreenWindowSpacing = sendMessages . flip map [ModifyWindowBorder,ModifyScreenBorder]
|
||||||
|
. flip id . borderIncrementBy
|
||||||
|
|
||||||
|
-- | Inverse of 'incScreenWindowSpacing'.
|
||||||
|
decScreenWindowSpacing :: Integer -> X ()
|
||||||
|
decScreenWindowSpacing = incScreenWindowSpacing . negate
|
||||||
|
|
||||||
|
-- | Construct a uniform 'Border'. That is, having equal individual borders.
|
||||||
|
uniformBorder :: Integer -> Border
|
||||||
|
uniformBorder i = Border i i i i
|
||||||
|
|
||||||
-- | Map a function over a 'Border'. That is, over the four individual borders.
|
-- | Map a function over a 'Border'. That is, over the four individual borders.
|
||||||
borderMap :: (Integer -> Integer) -> Border -> Border
|
borderMap :: (Integer -> Integer) -> Border -> Border
|
||||||
borderMap f (Border t b r l) = Border (f t) (f b) (f r) (f l)
|
borderMap f (Border t b r l) = Border (f t) (f b) (f r) (f l)
|
||||||
@ -300,8 +323,8 @@ orderSelect o (lt,eq,gt) = case o of
|
|||||||
-- Backwards Compatibility:
|
-- Backwards Compatibility:
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
{-# DEPRECATED spacing, spacingWithEdge, smartSpacing, smartSpacingWithEdge "Use spacingRaw instead." #-}
|
{-# DEPRECATED spacing, spacingWithEdge, smartSpacing, smartSpacingWithEdge "Use spacingRaw instead." #-}
|
||||||
{-# DEPRECATED setSpacing "Use setWindowSpacing/setScreenSpacing instead." #-}
|
{-# DEPRECATED setSpacing "Use setScreenWindowSpacing instead." #-}
|
||||||
{-# DEPRECATED incSpacing "Use incWindowSpacing/incScreenSpacing instead." #-}
|
{-# DEPRECATED incSpacing "Use incScreenWindowSpacing instead." #-}
|
||||||
|
|
||||||
-- $backwardsCompatibility
|
-- $backwardsCompatibility
|
||||||
-- The following functions exist solely for compatibility with pre-0.14
|
-- The following functions exist solely for compatibility with pre-0.14
|
||||||
@ -309,33 +332,34 @@ orderSelect o (lt,eq,gt) = case o of
|
|||||||
|
|
||||||
-- | Surround all windows by a certain number of pixels of blank space. See
|
-- | Surround all windows by a certain number of pixels of blank space. See
|
||||||
-- 'spacingRaw'.
|
-- 'spacingRaw'.
|
||||||
spacing :: Integer -> l a -> ModifiedLayout Spacing l a
|
spacing :: Int -> l a -> ModifiedLayout Spacing l a
|
||||||
spacing i = spacingRaw False (Border 0 0 0 0) False (Border i i i i) True
|
spacing i = spacingRaw False (uniformBorder 0) False (uniformBorder i') True
|
||||||
|
where i' = fromIntegral i
|
||||||
|
|
||||||
-- | Surround all windows by a certain number of pixels of blank space, and
|
-- | Surround all windows by a certain number of pixels of blank space, and
|
||||||
-- additionally adds the same amount of spacing around the edge of the screen.
|
-- additionally adds the same amount of spacing around the edge of the screen.
|
||||||
-- See 'spacingRaw'.
|
-- See 'spacingRaw'.
|
||||||
spacingWithEdge :: Integer -> l a -> ModifiedLayout Spacing l a
|
spacingWithEdge :: Int -> l a -> ModifiedLayout Spacing l a
|
||||||
spacingWithEdge i = spacingRaw False (Border i i i i) True (Border i i i i) True
|
spacingWithEdge i = spacingRaw False (uniformBorder i') True (uniformBorder i') True
|
||||||
|
where i' = fromIntegral i
|
||||||
|
|
||||||
-- | Surrounds all windows with blank space, except when the window is the only
|
-- | Surrounds all windows with blank space, except when the window is the only
|
||||||
-- visible window on the current workspace. See 'spacingRaw'.
|
-- visible window on the current workspace. See 'spacingRaw'.
|
||||||
smartSpacing :: Integer -> l a -> ModifiedLayout Spacing l a
|
smartSpacing :: Int -> l a -> ModifiedLayout Spacing l a
|
||||||
smartSpacing i = spacingRaw True (Border 0 0 0 0) False (Border i i i i) True
|
smartSpacing i = spacingRaw True (uniformBorder 0) False (uniformBorder i') True
|
||||||
|
where i' = fromIntegral i
|
||||||
|
|
||||||
-- | Surrounds all windows with blank space, and adds the same amount of
|
-- | Surrounds all windows with blank space, and adds the same amount of
|
||||||
-- spacing around the edge of the screen, except when the window is the only
|
-- spacing around the edge of the screen, except when the window is the only
|
||||||
-- visible window on the current workspace. See 'spacingRaw'.
|
-- visible window on the current workspace. See 'spacingRaw'.
|
||||||
smartSpacingWithEdge :: Integer -> l a -> ModifiedLayout Spacing l a
|
smartSpacingWithEdge :: Int -> l a -> ModifiedLayout Spacing l a
|
||||||
smartSpacingWithEdge i = spacingRaw True (Border i i i i) True (Border i i i i) True
|
smartSpacingWithEdge i = spacingRaw True (uniformBorder i') True (uniformBorder i') True
|
||||||
|
where i' = fromIntegral i
|
||||||
|
|
||||||
-- | Set all borders to a uniform size; see 'setWindowSpacing' and
|
-- | See 'setScreenWindowSpacing'.
|
||||||
-- 'setScreenSpacing'.
|
setSpacing :: Int -> X ()
|
||||||
setSpacing :: Integer -> X ()
|
setSpacing = setScreenWindowSpacing . fromIntegral
|
||||||
setSpacing i = setWindowSpacing b >> setScreenSpacing b
|
|
||||||
where b = Border i i i i
|
|
||||||
|
|
||||||
-- | Increment both screen and window borders; see 'incWindowSpacing' and
|
-- | See 'incScreenWindowSpacing'.
|
||||||
-- 'incScreenSpacing'.
|
incSpacing :: Int -> X ()
|
||||||
incSpacing :: Integer -> X ()
|
incSpacing = incScreenWindowSpacing . fromIntegral
|
||||||
incSpacing i = incWindowSpacing i >> incScreenSpacing i
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user