aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Vogt <vogt.adam@gmail.com>2015-03-10 19:20:46 +0100
committerAdam Vogt <vogt.adam@gmail.com>2015-03-10 19:20:46 +0100
commit97d1c33b8862ff430d755e2cda6a2f5fc1e44894 (patch)
tree711e2589786c1c4b3b3d4157d0243b103c105917
parent533ce6f1d3e3c7cfdb43fcdea1ce74987f41081b (diff)
downloadXMonadContrib-97d1c33b8862ff430d755e2cda6a2f5fc1e44894.tar.gz
XMonadContrib-97d1c33b8862ff430d755e2cda6a2f5fc1e44894.tar.xz
XMonadContrib-97d1c33b8862ff430d755e2cda6a2f5fc1e44894.zip
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
-rw-r--r--XMonad/Layout/Spacing.hs28
1 files 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