From 97d1c33b8862ff430d755e2cda6a2f5fc1e44894 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Tue, 10 Mar 2015 19:20:46 +0100 Subject: merge conflicts in X.L.Spacing Ignore-this: f0830d6483d30d643e7e182e310ec042 I should have just applied Anton Pirogov March 4 patch. darcs-hash:20150310182046-1499c-b23bcf058b68fb1a6f63d390269a038679be3b2a.gz --- XMonad/Layout/Spacing.hs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/XMonad/Layout/Spacing.hs b/XMonad/Layout/Spacing.hs index 38ffbd5..e0a25dd 100644 --- a/XMonad/Layout/Spacing.hs +++ b/XMonad/Layout/Spacing.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} +{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, DeriveDataTypeable #-} +{-# LANGUAGE PatternGuards #-} ----------------------------------------------------------------------------- -- | @@ -21,12 +22,13 @@ module XMonad.Layout.Spacing ( spacingWithEdge, SpacingWithEdge, smartSpacing, SmartSpacing, smartSpacingWithEdge, SmartSpacingWithEdge, - + ModifySpacing(..), setSpacing, incSpacing ) where import Graphics.X11 (Rectangle(..)) import Control.Arrow (second) -import XMonad.Core (runLayout) +import XMonad.Operations (sendMessage) +import XMonad.Core (runLayout,Message,fromMessage,Typeable) import XMonad.StackSet (up, down, Workspace(..)) import XMonad.Util.Font (fi) @@ -49,10 +51,26 @@ spacing p = ModifiedLayout (Spacing p) data Spacing a = Spacing Int deriving (Show, Read) +-- | Message to dynamically modify (e.g. increase/decrease/set) the size of the window spacing +data ModifySpacing = ModifySpacing (Int -> Int) deriving (Typeable) +instance Message ModifySpacing + +-- | Set spacing to given amount +setSpacing :: Int -> X () +setSpacing n = sendMessage $ ModifySpacing $ const n + +-- | Increase spacing by given amount +incSpacing :: Int -> X () +incSpacing n = sendMessage $ ModifySpacing $ (+n) + instance LayoutModifier Spacing a where pureModifier (Spacing p) _ _ wrs = (map (second $ shrinkRect p) wrs, Nothing) + pureMess (Spacing px) m + | Just (ModifySpacing f) <- fromMessage m = Just $ Spacing $ max 0 $ f px + | otherwise = Nothing + modifierDescription (Spacing p) = "Spacing " ++ show p -- | Surround all windows by a certain number of pixels of blank space, and @@ -66,6 +84,10 @@ instance LayoutModifier SpacingWithEdge a where pureModifier (SpacingWithEdge p) _ _ wrs = (map (second $ shrinkRect p) wrs, Nothing) + pureMess (SpacingWithEdge px) m + | Just (ModifySpacing f) <- fromMessage m = Just $ SpacingWithEdge $ max 0 $ f px + | otherwise = Nothing + modifyLayout (SpacingWithEdge p) w r = runLayout w (shrinkRect p r) modifierDescription (SpacingWithEdge p) = "SpacingWithEdge " ++ show p -- cgit v1.2.3