{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
module XMonad.Layout.DwmStyle
(
dwmStyle
, Theme (..)
, def
, DwmStyle (..)
, shrinkText, CustomShrink(CustomShrink)
, Shrinker(..)
) where
import XMonad
import XMonad.StackSet ( Stack (..) )
import XMonad.Layout.Decoration
dwmStyle :: (Eq a, Shrinker s) => s -> Theme
-> l a -> ModifiedLayout (Decoration DwmStyle s) l a
dwmStyle :: s -> Theme -> l a -> ModifiedLayout (Decoration DwmStyle s) l a
dwmStyle s
s Theme
c = s
-> Theme
-> DwmStyle a
-> l a
-> ModifiedLayout (Decoration DwmStyle s) l a
forall (ds :: * -> *) a s (l :: * -> *).
(DecorationStyle ds a, Shrinker s) =>
s -> Theme -> ds a -> l a -> ModifiedLayout (Decoration ds s) l a
decoration s
s Theme
c DwmStyle a
forall a. DwmStyle a
Dwm
data DwmStyle a = Dwm deriving (Int -> DwmStyle a -> ShowS
[DwmStyle a] -> ShowS
DwmStyle a -> String
(Int -> DwmStyle a -> ShowS)
-> (DwmStyle a -> String)
-> ([DwmStyle a] -> ShowS)
-> Show (DwmStyle a)
forall a. Int -> DwmStyle a -> ShowS
forall a. [DwmStyle a] -> ShowS
forall a. DwmStyle a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DwmStyle a] -> ShowS
$cshowList :: forall a. [DwmStyle a] -> ShowS
show :: DwmStyle a -> String
$cshow :: forall a. DwmStyle a -> String
showsPrec :: Int -> DwmStyle a -> ShowS
$cshowsPrec :: forall a. Int -> DwmStyle a -> ShowS
Show, ReadPrec [DwmStyle a]
ReadPrec (DwmStyle a)
Int -> ReadS (DwmStyle a)
ReadS [DwmStyle a]
(Int -> ReadS (DwmStyle a))
-> ReadS [DwmStyle a]
-> ReadPrec (DwmStyle a)
-> ReadPrec [DwmStyle a]
-> Read (DwmStyle a)
forall a. ReadPrec [DwmStyle a]
forall a. ReadPrec (DwmStyle a)
forall a. Int -> ReadS (DwmStyle a)
forall a. ReadS [DwmStyle a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DwmStyle a]
$creadListPrec :: forall a. ReadPrec [DwmStyle a]
readPrec :: ReadPrec (DwmStyle a)
$creadPrec :: forall a. ReadPrec (DwmStyle a)
readList :: ReadS [DwmStyle a]
$creadList :: forall a. ReadS [DwmStyle a]
readsPrec :: Int -> ReadS (DwmStyle a)
$creadsPrec :: forall a. Int -> ReadS (DwmStyle a)
Read)
instance Eq a => DecorationStyle DwmStyle a where
describeDeco :: DwmStyle a -> String
describeDeco DwmStyle a
_ = String
"DwmStyle"
shrink :: DwmStyle a -> Rectangle -> Rectangle -> Rectangle
shrink DwmStyle a
_ Rectangle
_ Rectangle
r = Rectangle
r
pureDecoration :: DwmStyle a
-> Dimension
-> Dimension
-> Rectangle
-> Stack a
-> [(a, Rectangle)]
-> (a, Rectangle)
-> Maybe Rectangle
pureDecoration DwmStyle a
_ Dimension
wh Dimension
ht Rectangle
_ s :: Stack a
s@(Stack a
fw [a]
_ [a]
_) [(a, Rectangle)]
_ (a
w,Rectangle Position
x Position
y Dimension
wid Dimension
_) =
if a
w a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
fw Bool -> Bool -> Bool
|| Bool -> Bool
not (Stack a -> a -> Bool
forall a. Eq a => Stack a -> a -> Bool
isInStack Stack a
s a
w) then Maybe Rectangle
forall a. Maybe a
Nothing else Rectangle -> Maybe Rectangle
forall a. a -> Maybe a
Just (Rectangle -> Maybe Rectangle) -> Rectangle -> Maybe Rectangle
forall a b. (a -> b) -> a -> b
$ Position -> Position -> Dimension -> Dimension -> Rectangle
Rectangle (Dimension -> Position
forall a b. (Integral a, Num b) => a -> b
fi Dimension
nx) Position
y Dimension
nwh (Dimension -> Dimension
forall a b. (Integral a, Num b) => a -> b
fi Dimension
ht)
where nwh :: Dimension
nwh = Dimension -> Dimension -> Dimension
forall a. Ord a => a -> a -> a
min Dimension
wid (Dimension -> Dimension) -> Dimension -> Dimension
forall a b. (a -> b) -> a -> b
$ Dimension -> Dimension
forall a b. (Integral a, Num b) => a -> b
fi Dimension
wh
nx :: Dimension
nx = Position -> Dimension
forall a b. (Integral a, Num b) => a -> b
fi Position
x Dimension -> Dimension -> Dimension
forall a. Num a => a -> a -> a
+ Dimension
wid Dimension -> Dimension -> Dimension
forall a. Num a => a -> a -> a
- Dimension
nwh