{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, PatternGuards #-}
module XMonad.Layout.Spacing
(
Spacing (..)
, spacingRaw
, spacing, spacingWithEdge
, smartSpacing, smartSpacingWithEdge
, SpacingModifier (..)
, setSmartSpacing
, setScreenSpacing, setScreenSpacingEnabled
, setWindowSpacing, setWindowSpacingEnabled
, toggleSmartSpacing
, toggleScreenSpacingEnabled
, toggleWindowSpacingEnabled
, setScreenWindowSpacing
, incWindowSpacing, incScreenSpacing
, decWindowSpacing, decScreenSpacing
, incScreenWindowSpacing, decScreenWindowSpacing
, Border (..)
, borderMap, borderIncrementBy
, SpacingWithEdge
, SmartSpacing, SmartSpacingWithEdge
, ModifySpacing (..)
, setSpacing, incSpacing
) where
import XMonad
import XMonad.StackSet as W
import qualified XMonad.Util.Rectangle as R
import XMonad.Layout.LayoutModifier
import XMonad.Actions.MessageFeedback
data Border = Border
{ Border -> Integer
top :: Integer
, Border -> Integer
bottom :: Integer
, Border -> Integer
right :: Integer
, Border -> Integer
left :: Integer
} deriving (Int -> Border -> ShowS
[Border] -> ShowS
Border -> String
(Int -> Border -> ShowS)
-> (Border -> String) -> ([Border] -> ShowS) -> Show Border
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Border] -> ShowS
$cshowList :: [Border] -> ShowS
show :: Border -> String
$cshow :: Border -> String
showsPrec :: Int -> Border -> ShowS
$cshowsPrec :: Int -> Border -> ShowS
Show,ReadPrec [Border]
ReadPrec Border
Int -> ReadS Border
ReadS [Border]
(Int -> ReadS Border)
-> ReadS [Border]
-> ReadPrec Border
-> ReadPrec [Border]
-> Read Border
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Border]
$creadListPrec :: ReadPrec [Border]
readPrec :: ReadPrec Border
$creadPrec :: ReadPrec Border
readList :: ReadS [Border]
$creadList :: ReadS [Border]
readsPrec :: Int -> ReadS Border
$creadsPrec :: Int -> ReadS Border
Read)
data Spacing a = Spacing
{ forall a. Spacing a -> Bool
smartBorder :: Bool
, forall a. Spacing a -> Border
screenBorder :: Border
, forall a. Spacing a -> Bool
screenBorderEnabled :: Bool
, forall a. Spacing a -> Border
windowBorder :: Border
, forall a. Spacing a -> Bool
windowBorderEnabled :: Bool
} deriving (Int -> Spacing a -> ShowS
[Spacing a] -> ShowS
Spacing a -> String
(Int -> Spacing a -> ShowS)
-> (Spacing a -> String)
-> ([Spacing a] -> ShowS)
-> Show (Spacing a)
forall a. Int -> Spacing a -> ShowS
forall a. [Spacing a] -> ShowS
forall a. Spacing a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Spacing a] -> ShowS
$cshowList :: forall a. [Spacing a] -> ShowS
show :: Spacing a -> String
$cshow :: forall a. Spacing a -> String
showsPrec :: Int -> Spacing a -> ShowS
$cshowsPrec :: forall a. Int -> Spacing a -> ShowS
Show,ReadPrec [Spacing a]
ReadPrec (Spacing a)
Int -> ReadS (Spacing a)
ReadS [Spacing a]
(Int -> ReadS (Spacing a))
-> ReadS [Spacing a]
-> ReadPrec (Spacing a)
-> ReadPrec [Spacing a]
-> Read (Spacing a)
forall a. ReadPrec [Spacing a]
forall a. ReadPrec (Spacing a)
forall a. Int -> ReadS (Spacing a)
forall a. ReadS [Spacing a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Spacing a]
$creadListPrec :: forall a. ReadPrec [Spacing a]
readPrec :: ReadPrec (Spacing a)
$creadPrec :: forall a. ReadPrec (Spacing a)
readList :: ReadS [Spacing a]
$creadList :: forall a. ReadS [Spacing a]
readsPrec :: Int -> ReadS (Spacing a)
$creadsPrec :: forall a. Int -> ReadS (Spacing a)
Read)
instance Eq a => LayoutModifier Spacing a where
modifyLayout :: forall (l :: * -> *).
LayoutClass l a =>
Spacing a
-> Workspace String (l a) a
-> Rectangle
-> X ([(a, Rectangle)], Maybe (l a))
modifyLayout (Spacing Bool
_b Border
_sb Bool
False Border
_wb Bool
_wbe) Workspace String (l a) a
wsp Rectangle
lr =
Workspace String (l a) a
-> Rectangle -> X ([(a, Rectangle)], Maybe (l a))
forall (layout :: * -> *) a.
LayoutClass layout a =>
Workspace String (layout a) a
-> Rectangle -> X ([(a, Rectangle)], Maybe (layout a))
runLayout Workspace String (l a) a
wsp Rectangle
lr
modifyLayout (Spacing Bool
b Border
sb Bool
_sbe Border
_wb Bool
_wbe) Workspace String (l a) a
wsp Rectangle
lr = do
let sb1 :: Border
sb1 = Border -> Border
borderClampGTZero Border
sb
lr' :: Rectangle
lr' = Border -> Integer -> Rectangle -> Rectangle
withBorder' Border
sb1 Integer
2 Rectangle
lr
sb2 :: Border
sb2 = Rectangle -> Rectangle -> Border
toBorder Rectangle
lr' Rectangle
lr
([(a, Rectangle)]
wrs,Maybe (l a)
ml) <- Workspace String (l a) a
-> Rectangle -> X ([(a, Rectangle)], Maybe (l a))
forall (layout :: * -> *) a.
LayoutClass layout a =>
Workspace String (layout a) a
-> Rectangle -> X ([(a, Rectangle)], Maybe (layout a))
runLayout Workspace String (l a) a
wsp Rectangle
lr'
let ff :: (a, Rectangle) -> (a, [(a, Rectangle)]) -> (a, [(a, Rectangle)])
ff (a
w,Rectangle
wr) (a
i,[(a, Rectangle)]
ps) = if a
w a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (Maybe (Stack a) -> [a]
forall a. Maybe (Stack a) -> [a]
W.integrate' (Maybe (Stack a) -> [a])
-> (Workspace String (l a) a -> Maybe (Stack a))
-> Workspace String (l a) a
-> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Workspace String (l a) a -> Maybe (Stack a)
forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack (Workspace String (l a) a -> [a])
-> Workspace String (l a) a -> [a]
forall a b. (a -> b) -> a -> b
$ Workspace String (l a) a
wsp)
then let wr' :: Rectangle
wr' = Border -> Integer -> Rectangle -> Rectangle
withBorder' Border
sb2 Integer
2 Rectangle
wr
in (a
ia -> a -> a
forall a. Num a => a -> a -> a
+a
1,(a
w,Rectangle
wr')(a, Rectangle) -> [(a, Rectangle)] -> [(a, Rectangle)]
forall a. a -> [a] -> [a]
:[(a, Rectangle)]
ps)
else let wr' :: Rectangle
wr' = Rectangle -> Rectangle -> Border -> Rectangle
moveByQuadrant Rectangle
lr Rectangle
wr Border
sb2
in (a
i,(a
w,Rectangle
wr')(a, Rectangle) -> [(a, Rectangle)] -> [(a, Rectangle)]
forall a. a -> [a] -> [a]
:[(a, Rectangle)]
ps)
(Integer
c,[(a, Rectangle)]
wrs') = ((a, Rectangle)
-> (Integer, [(a, Rectangle)]) -> (Integer, [(a, Rectangle)]))
-> (Integer, [(a, Rectangle)])
-> [(a, Rectangle)]
-> (Integer, [(a, Rectangle)])
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (a, Rectangle)
-> (Integer, [(a, Rectangle)]) -> (Integer, [(a, Rectangle)])
forall {a}.
Num a =>
(a, Rectangle) -> (a, [(a, Rectangle)]) -> (a, [(a, Rectangle)])
ff (Integer
0::Integer,[]) [(a, Rectangle)]
wrs
([(a, Rectangle)], Maybe (l a))
-> X ([(a, Rectangle)], Maybe (l a))
forall (m :: * -> *) a. Monad m => a -> m a
return (([(a, Rectangle)], Maybe (l a))
-> X ([(a, Rectangle)], Maybe (l a)))
-> ([(a, Rectangle)], Maybe (l a))
-> X ([(a, Rectangle)], Maybe (l a))
forall a b. (a -> b) -> a -> b
$ if Integer
c Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Integer
1 Bool -> Bool -> Bool
&& Bool
b
then ([(a, Rectangle)]
wrs',Maybe (l a)
ml)
else ([(a, Rectangle)]
wrs,Maybe (l a)
ml)
where
moveByQuadrant :: Rectangle -> Rectangle -> Border -> Rectangle
moveByQuadrant :: Rectangle -> Rectangle -> Border -> Rectangle
moveByQuadrant Rectangle
rr mr :: Rectangle
mr@Rectangle{rect_x :: Rectangle -> Position
rect_x = Position
x, rect_y :: Rectangle -> Position
rect_y = Position
y} (Border Integer
bt Integer
bb Integer
br Integer
bl) =
let (Ratio Integer
rcx,Ratio Integer
rcy) = Rectangle -> (Ratio Integer, Ratio Integer)
R.center Rectangle
rr
(Ratio Integer
mcx,Ratio Integer
mcy) = Rectangle -> (Ratio Integer, Ratio Integer)
R.center Rectangle
mr
dx :: Integer
dx = Ordering -> (Integer, Integer, Integer) -> Integer
forall a. Ordering -> (a, a, a) -> a
orderSelect (Ratio Integer -> Ratio Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Ratio Integer
mcx Ratio Integer
rcx) (Integer
bl,Integer
0,Integer -> Integer
forall a. Num a => a -> a
negate Integer
br)
dy :: Integer
dy = Ordering -> (Integer, Integer, Integer) -> Integer
forall a. Ordering -> (a, a, a) -> a
orderSelect (Ratio Integer -> Ratio Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Ratio Integer
mcy Ratio Integer
rcy) (Integer
bt,Integer
0,Integer -> Integer
forall a. Num a => a -> a
negate Integer
bb)
in Rectangle
mr { rect_x :: Position
rect_x = Position
x Position -> Position -> Position
forall a. Num a => a -> a -> a
+ Integer -> Position
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
dx, rect_y :: Position
rect_y = Position
y Position -> Position -> Position
forall a. Num a => a -> a -> a
+ Integer -> Position
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
dy }
pureModifier :: Spacing a
-> Rectangle
-> Maybe (Stack a)
-> [(a, Rectangle)]
-> ([(a, Rectangle)], Maybe (Spacing a))
pureModifier (Spacing Bool
_b Border
_sb Bool
_sbe Border
_wb Bool
False) Rectangle
_lr Maybe (Stack a)
_mst [(a, Rectangle)]
wrs =
([(a, Rectangle)]
wrs, Maybe (Spacing a)
forall a. Maybe a
Nothing)
pureModifier (Spacing Bool
b Border
_sb Bool
_sbe Border
wb Bool
_wbe) Rectangle
_lr Maybe (Stack a)
mst [(a, Rectangle)]
wrs =
let wb' :: Border
wb' = Border -> Border
borderClampGTZero Border
wb
ff :: (a, Rectangle) -> (a, [(a, Rectangle)]) -> (a, [(a, Rectangle)])
ff p :: (a, Rectangle)
p@(a
w,Rectangle
wr) (a
i,[(a, Rectangle)]
ps) = if a
w a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` Maybe (Stack a) -> [a]
forall a. Maybe (Stack a) -> [a]
W.integrate' Maybe (Stack a)
mst
then let wr' :: Rectangle
wr' = Border -> Integer -> Rectangle -> Rectangle
withBorder' Border
wb' Integer
2 Rectangle
wr
in (a
ia -> a -> a
forall a. Num a => a -> a -> a
+a
1,(a
w,Rectangle
wr')(a, Rectangle) -> [(a, Rectangle)] -> [(a, Rectangle)]
forall a. a -> [a] -> [a]
:[(a, Rectangle)]
ps)
else (a
i,(a, Rectangle)
p(a, Rectangle) -> [(a, Rectangle)] -> [(a, Rectangle)]
forall a. a -> [a] -> [a]
:[(a, Rectangle)]
ps)
(Integer
c,[(a, Rectangle)]
wrs') = ((a, Rectangle)
-> (Integer, [(a, Rectangle)]) -> (Integer, [(a, Rectangle)]))
-> (Integer, [(a, Rectangle)])
-> [(a, Rectangle)]
-> (Integer, [(a, Rectangle)])
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (a, Rectangle)
-> (Integer, [(a, Rectangle)]) -> (Integer, [(a, Rectangle)])
forall {a}.
Num a =>
(a, Rectangle) -> (a, [(a, Rectangle)]) -> (a, [(a, Rectangle)])
ff (Integer
0::Integer,[]) [(a, Rectangle)]
wrs
in if Integer
c Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Integer
1 Bool -> Bool -> Bool
&& Bool
b
then ([(a, Rectangle)]
wrs, Maybe (Spacing a)
forall a. Maybe a
Nothing)
else ([(a, Rectangle)]
wrs', Maybe (Spacing a)
forall a. Maybe a
Nothing)
pureMess :: Spacing a -> SomeMessage -> Maybe (Spacing a)
pureMess s :: Spacing a
s@(Spacing Bool
b Border
sb Bool
sbe Border
wb Bool
wbe) SomeMessage
m
| Just (ModifySmartBorder Bool -> Bool
f) <- SomeMessage -> Maybe SpacingModifier
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
m
= Spacing a -> Maybe (Spacing a)
forall a. a -> Maybe a
Just (Spacing a -> Maybe (Spacing a)) -> Spacing a -> Maybe (Spacing a)
forall a b. (a -> b) -> a -> b
$ Spacing a
s { smartBorder :: Bool
smartBorder = Bool -> Bool
f Bool
b }
| Just (ModifyScreenBorder Border -> Border
f) <- SomeMessage -> Maybe SpacingModifier
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
m
= Spacing a -> Maybe (Spacing a)
forall a. a -> Maybe a
Just (Spacing a -> Maybe (Spacing a)) -> Spacing a -> Maybe (Spacing a)
forall a b. (a -> b) -> a -> b
$ Spacing a
s { screenBorder :: Border
screenBorder = Border -> Border
f Border
sb }
| Just (ModifyScreenBorderEnabled Bool -> Bool
f) <- SomeMessage -> Maybe SpacingModifier
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
m
= Spacing a -> Maybe (Spacing a)
forall a. a -> Maybe a
Just (Spacing a -> Maybe (Spacing a)) -> Spacing a -> Maybe (Spacing a)
forall a b. (a -> b) -> a -> b
$ Spacing a
s { screenBorderEnabled :: Bool
screenBorderEnabled = Bool -> Bool
f Bool
sbe }
| Just (ModifyWindowBorder Border -> Border
f) <- SomeMessage -> Maybe SpacingModifier
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
m
= Spacing a -> Maybe (Spacing a)
forall a. a -> Maybe a
Just (Spacing a -> Maybe (Spacing a)) -> Spacing a -> Maybe (Spacing a)
forall a b. (a -> b) -> a -> b
$ Spacing a
s { windowBorder :: Border
windowBorder = Border -> Border
f Border
wb }
| Just (ModifyWindowBorderEnabled Bool -> Bool
f) <- SomeMessage -> Maybe SpacingModifier
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
m
= Spacing a -> Maybe (Spacing a)
forall a. a -> Maybe a
Just (Spacing a -> Maybe (Spacing a)) -> Spacing a -> Maybe (Spacing a)
forall a b. (a -> b) -> a -> b
$ Spacing a
s { windowBorderEnabled :: Bool
windowBorderEnabled = Bool -> Bool
f Bool
wbe }
| Just (ModifySpacing Int -> Int
f) <- SomeMessage -> Maybe ModifySpacing
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
m
= Spacing a -> Maybe (Spacing a)
forall a. a -> Maybe a
Just (Spacing a -> Maybe (Spacing a)) -> Spacing a -> Maybe (Spacing a)
forall a b. (a -> b) -> a -> b
$ let f' :: Border -> Border
f' = (Integer -> Integer) -> Border -> Border
borderMap (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Integer) -> (Integer -> Int) -> Integer -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int
f (Int -> Int) -> (Integer -> Int) -> Integer -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
in Spacing a
s { screenBorder :: Border
screenBorder = Border -> Border
f' Border
sb, windowBorder :: Border
windowBorder = Border -> Border
f' Border
wb }
| Bool
otherwise
= Maybe (Spacing a)
forall a. Maybe a
Nothing
modifierDescription :: Spacing a -> String
modifierDescription Spacing {} =
String
"Spacing"
spacingRaw :: Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a -> ModifiedLayout Spacing l a
spacingRaw :: forall (l :: * -> *) a.
Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
spacingRaw Bool
b Border
sb Bool
sbe Border
wb Bool
wbe = Spacing a -> l a -> ModifiedLayout Spacing l a
forall (m :: * -> *) (l :: * -> *) a.
m a -> l a -> ModifiedLayout m l a
ModifiedLayout (Bool -> Border -> Bool -> Border -> Bool -> Spacing a
forall a. Bool -> Border -> Bool -> Border -> Bool -> Spacing a
Spacing Bool
b Border
sb Bool
sbe Border
wb Bool
wbe)
data SpacingModifier
= ModifySmartBorder (Bool -> Bool)
| ModifyScreenBorder (Border -> Border)
| ModifyScreenBorderEnabled (Bool -> Bool)
| ModifyWindowBorder (Border -> Border)
| ModifyWindowBorderEnabled (Bool -> Bool)
instance Message SpacingModifier
setSmartSpacing :: Bool -> X ()
setSmartSpacing :: Bool -> X ()
setSmartSpacing = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ())
-> (Bool -> SpacingModifier) -> Bool -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Bool) -> SpacingModifier
ModifySmartBorder ((Bool -> Bool) -> SpacingModifier)
-> (Bool -> Bool -> Bool) -> Bool -> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Bool -> Bool
forall a b. a -> b -> a
const
setScreenSpacing :: Border -> X ()
setScreenSpacing :: Border -> X ()
setScreenSpacing = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ())
-> (Border -> SpacingModifier) -> Border -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Border -> Border) -> SpacingModifier
ModifyScreenBorder ((Border -> Border) -> SpacingModifier)
-> (Border -> Border -> Border) -> Border -> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Border -> Border -> Border
forall a b. a -> b -> a
const
setScreenSpacingEnabled :: Bool -> X ()
setScreenSpacingEnabled :: Bool -> X ()
setScreenSpacingEnabled = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ())
-> (Bool -> SpacingModifier) -> Bool -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Bool) -> SpacingModifier
ModifyScreenBorderEnabled ((Bool -> Bool) -> SpacingModifier)
-> (Bool -> Bool -> Bool) -> Bool -> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Bool -> Bool
forall a b. a -> b -> a
const
setWindowSpacing :: Border -> X ()
setWindowSpacing :: Border -> X ()
setWindowSpacing = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ())
-> (Border -> SpacingModifier) -> Border -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Border -> Border) -> SpacingModifier
ModifyWindowBorder ((Border -> Border) -> SpacingModifier)
-> (Border -> Border -> Border) -> Border -> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Border -> Border -> Border
forall a b. a -> b -> a
const
setWindowSpacingEnabled :: Bool -> X ()
setWindowSpacingEnabled :: Bool -> X ()
setWindowSpacingEnabled = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ())
-> (Bool -> SpacingModifier) -> Bool -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Bool) -> SpacingModifier
ModifyWindowBorderEnabled ((Bool -> Bool) -> SpacingModifier)
-> (Bool -> Bool -> Bool) -> Bool -> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Bool -> Bool
forall a b. a -> b -> a
const
toggleSmartSpacing :: X ()
toggleSmartSpacing :: X ()
toggleSmartSpacing = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ()) -> SpacingModifier -> X ()
forall a b. (a -> b) -> a -> b
$ (Bool -> Bool) -> SpacingModifier
ModifySmartBorder Bool -> Bool
not
toggleScreenSpacingEnabled :: X ()
toggleScreenSpacingEnabled :: X ()
toggleScreenSpacingEnabled = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ()) -> SpacingModifier -> X ()
forall a b. (a -> b) -> a -> b
$ (Bool -> Bool) -> SpacingModifier
ModifyScreenBorderEnabled Bool -> Bool
not
toggleWindowSpacingEnabled :: X ()
toggleWindowSpacingEnabled :: X ()
toggleWindowSpacingEnabled = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ()) -> SpacingModifier -> X ()
forall a b. (a -> b) -> a -> b
$ (Bool -> Bool) -> SpacingModifier
ModifyWindowBorderEnabled Bool -> Bool
not
setScreenWindowSpacing :: Integer -> X ()
setScreenWindowSpacing :: Integer -> X ()
setScreenWindowSpacing = [SpacingModifier] -> X ()
forall a. Message a => [a] -> X ()
sendMessages ([SpacingModifier] -> X ())
-> (Integer -> [SpacingModifier]) -> Integer -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> [(Border -> Border) -> SpacingModifier] -> [SpacingModifier])
-> [(Border -> Border) -> SpacingModifier]
-> (((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> [SpacingModifier]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> [(Border -> Border) -> SpacingModifier] -> [SpacingModifier]
forall a b. (a -> b) -> [a] -> [b]
map [(Border -> Border) -> SpacingModifier
ModifyWindowBorder,(Border -> Border) -> SpacingModifier
ModifyScreenBorder]
((((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> [SpacingModifier])
-> (Integer
-> ((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> Integer
-> [SpacingModifier]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (((Border -> Border) -> SpacingModifier)
-> (Border -> Border) -> SpacingModifier)
-> (Border -> Border)
-> ((Border -> Border) -> SpacingModifier)
-> SpacingModifier
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((Border -> Border) -> SpacingModifier)
-> (Border -> Border) -> SpacingModifier
forall a. a -> a
id ((Border -> Border)
-> ((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> (Integer -> Border -> Border)
-> Integer
-> ((Border -> Border) -> SpacingModifier)
-> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Border -> Border -> Border
forall a b. a -> b -> a
const (Border -> Border -> Border)
-> (Integer -> Border) -> Integer -> Border -> Border
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Border
uniformBorder
incWindowSpacing :: Integer -> X ()
incWindowSpacing :: Integer -> X ()
incWindowSpacing = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ())
-> (Integer -> SpacingModifier) -> Integer -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Border -> Border) -> SpacingModifier
ModifyWindowBorder ((Border -> Border) -> SpacingModifier)
-> (Integer -> Border -> Border) -> Integer -> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Border -> Border
borderIncrementBy
incScreenSpacing :: Integer -> X ()
incScreenSpacing :: Integer -> X ()
incScreenSpacing = SpacingModifier -> X ()
forall a. Message a => a -> X ()
sendMessage (SpacingModifier -> X ())
-> (Integer -> SpacingModifier) -> Integer -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Border -> Border) -> SpacingModifier
ModifyScreenBorder ((Border -> Border) -> SpacingModifier)
-> (Integer -> Border -> Border) -> Integer -> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Border -> Border
borderIncrementBy
decWindowSpacing :: Integer -> X ()
decWindowSpacing :: Integer -> X ()
decWindowSpacing = Integer -> X ()
incWindowSpacing (Integer -> X ()) -> (Integer -> Integer) -> Integer -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
negate
decScreenSpacing :: Integer -> X ()
decScreenSpacing :: Integer -> X ()
decScreenSpacing = Integer -> X ()
incScreenSpacing (Integer -> X ()) -> (Integer -> Integer) -> Integer -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
negate
incScreenWindowSpacing :: Integer -> X ()
incScreenWindowSpacing :: Integer -> X ()
incScreenWindowSpacing = [SpacingModifier] -> X ()
forall a. Message a => [a] -> X ()
sendMessages ([SpacingModifier] -> X ())
-> (Integer -> [SpacingModifier]) -> Integer -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> [(Border -> Border) -> SpacingModifier] -> [SpacingModifier])
-> [(Border -> Border) -> SpacingModifier]
-> (((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> [SpacingModifier]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> [(Border -> Border) -> SpacingModifier] -> [SpacingModifier]
forall a b. (a -> b) -> [a] -> [b]
map [(Border -> Border) -> SpacingModifier
ModifyWindowBorder,(Border -> Border) -> SpacingModifier
ModifyScreenBorder]
((((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> [SpacingModifier])
-> (Integer
-> ((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> Integer
-> [SpacingModifier]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (((Border -> Border) -> SpacingModifier)
-> (Border -> Border) -> SpacingModifier)
-> (Border -> Border)
-> ((Border -> Border) -> SpacingModifier)
-> SpacingModifier
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((Border -> Border) -> SpacingModifier)
-> (Border -> Border) -> SpacingModifier
forall a. a -> a
id ((Border -> Border)
-> ((Border -> Border) -> SpacingModifier) -> SpacingModifier)
-> (Integer -> Border -> Border)
-> Integer
-> ((Border -> Border) -> SpacingModifier)
-> SpacingModifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Border -> Border
borderIncrementBy
decScreenWindowSpacing :: Integer -> X ()
decScreenWindowSpacing :: Integer -> X ()
decScreenWindowSpacing = Integer -> X ()
incScreenWindowSpacing (Integer -> X ()) -> (Integer -> Integer) -> Integer -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer
forall a. Num a => a -> a
negate
uniformBorder :: Integer -> Border
uniformBorder :: Integer -> Border
uniformBorder Integer
i = Integer -> Integer -> Integer -> Integer -> Border
Border Integer
i Integer
i Integer
i Integer
i
borderMap :: (Integer -> Integer) -> Border -> Border
borderMap :: (Integer -> Integer) -> Border -> Border
borderMap Integer -> Integer
f (Border Integer
t Integer
b Integer
r Integer
l) = Integer -> Integer -> Integer -> Integer -> Border
Border (Integer -> Integer
f Integer
t) (Integer -> Integer
f Integer
b) (Integer -> Integer
f Integer
r) (Integer -> Integer
f Integer
l)
borderClampGTZero :: Border -> Border
borderClampGTZero :: Border -> Border
borderClampGTZero = (Integer -> Integer) -> Border -> Border
borderMap (Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
max Integer
0)
borderIncrementBy :: Integer -> Border -> Border
borderIncrementBy :: Integer -> Border -> Border
borderIncrementBy Integer
i (Border Integer
t Integer
b Integer
r Integer
l) =
let bl :: [Integer]
bl = [Integer
t,Integer
b,Integer
r,Integer
l]
o :: Integer
o = [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum [Integer]
bl
o' :: Integer
o' = Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
max Integer
i (Integer -> Integer) -> Integer -> Integer
forall a b. (a -> b) -> a -> b
$ Integer -> Integer
forall a. Num a => a -> a
negate Integer
o
in Integer -> Integer -> Integer -> Integer -> Border
Border (Integer
t Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
o') (Integer
b Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
o') (Integer
r Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
o') (Integer
l Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
o')
withBorder' :: Border -> Integer -> Rectangle -> Rectangle
withBorder' :: Border -> Integer -> Rectangle -> Rectangle
withBorder' (Border Integer
t Integer
b Integer
r Integer
l) = Integer
-> Integer
-> Integer
-> Integer
-> Integer
-> Rectangle
-> Rectangle
R.withBorder Integer
t Integer
b Integer
r Integer
l
toBorder :: Rectangle -> Rectangle -> Border
toBorder :: Rectangle -> Rectangle -> Border
toBorder Rectangle
r1 Rectangle
r2 =
let R.PointRectangle Integer
r1_x1 Integer
r1_y1 Integer
r1_x2 Integer
r1_y2 = Rectangle -> PointRectangle Integer
R.pixelsToCoordinates Rectangle
r1
R.PointRectangle Integer
r2_x1 Integer
r2_y1 Integer
r2_x2 Integer
r2_y2 = Rectangle -> PointRectangle Integer
R.pixelsToCoordinates Rectangle
r2
l :: Integer
l = Integer
r2_x1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
r1_x1
r :: Integer
r = Integer
r1_x2 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
r2_x2
t :: Integer
t = Integer
r2_y1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
r1_y1
b :: Integer
b = Integer
r1_y2 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
r2_y2
in Integer -> Integer -> Integer -> Integer -> Border
Border Integer
t Integer
b Integer
r Integer
l
orderSelect :: Ordering -> (a,a,a) -> a
orderSelect :: forall a. Ordering -> (a, a, a) -> a
orderSelect Ordering
o (a
lt,a
eq,a
gt) = case Ordering
o of
Ordering
LT -> a
lt
Ordering
EQ -> a
eq
Ordering
GT -> a
gt
{-# DEPRECATED SpacingWithEdge, SmartSpacing, SmartSpacingWithEdge "Use Spacing instead." #-}
{-# DEPRECATED ModifySpacing "Use SpacingModifier instead, perhaps with sendMessages." #-}
{-# DEPRECATED setSpacing "Use setScreenWindowSpacing instead." #-}
{-# DEPRECATED incSpacing "Use incScreenWindowSpacing instead." #-}
type SpacingWithEdge = Spacing
type SmartSpacing = Spacing
type SmartSpacingWithEdge = Spacing
newtype ModifySpacing = ModifySpacing (Int -> Int)
instance Message ModifySpacing
spacing :: Int -> l a -> ModifiedLayout Spacing l a
spacing :: forall (l :: * -> *) a. Int -> l a -> ModifiedLayout Spacing l a
spacing Int
i = Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
forall (l :: * -> *) a.
Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
spacingRaw Bool
False (Integer -> Border
uniformBorder Integer
0) Bool
False (Integer -> Border
uniformBorder Integer
i') Bool
True
where i' :: Integer
i' = Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i
spacingWithEdge :: Int -> l a -> ModifiedLayout Spacing l a
spacingWithEdge :: forall (l :: * -> *) a. Int -> l a -> ModifiedLayout Spacing l a
spacingWithEdge Int
i = Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
forall (l :: * -> *) a.
Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
spacingRaw Bool
False (Integer -> Border
uniformBorder Integer
i') Bool
True (Integer -> Border
uniformBorder Integer
i') Bool
True
where i' :: Integer
i' = Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i
smartSpacing :: Int -> l a -> ModifiedLayout Spacing l a
smartSpacing :: forall (l :: * -> *) a. Int -> l a -> ModifiedLayout Spacing l a
smartSpacing Int
i = Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
forall (l :: * -> *) a.
Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
spacingRaw Bool
True (Integer -> Border
uniformBorder Integer
0) Bool
False (Integer -> Border
uniformBorder Integer
i') Bool
True
where i' :: Integer
i' = Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i
smartSpacingWithEdge :: Int -> l a -> ModifiedLayout Spacing l a
smartSpacingWithEdge :: forall (l :: * -> *) a. Int -> l a -> ModifiedLayout Spacing l a
smartSpacingWithEdge Int
i = Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
forall (l :: * -> *) a.
Bool
-> Border
-> Bool
-> Border
-> Bool
-> l a
-> ModifiedLayout Spacing l a
spacingRaw Bool
True (Integer -> Border
uniformBorder Integer
i') Bool
True (Integer -> Border
uniformBorder Integer
i') Bool
True
where i' :: Integer
i' = Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i
setSpacing :: Int -> X ()
setSpacing :: Int -> X ()
setSpacing = Integer -> X ()
setScreenWindowSpacing (Integer -> X ()) -> (Int -> Integer) -> Int -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral
incSpacing :: Int -> X ()
incSpacing :: Int -> X ()
incSpacing = Integer -> X ()
incScreenWindowSpacing (Integer -> X ()) -> (Int -> Integer) -> Int -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral