{-# LANGUAGE TypeSynonymInstances, MultiParamTypeClasses #-}
module XMonad.Layout.SimplestFloat
(
simplestFloat
, SimplestFloat
) where
import XMonad
import qualified XMonad.StackSet as S
import XMonad.Layout.WindowArranger
import XMonad.Layout.LayoutModifier
import XMonad.Util.XUtils (fi)
simplestFloat :: Eq a => (ModifiedLayout WindowArranger SimplestFloat) a
simplestFloat :: ModifiedLayout WindowArranger SimplestFloat a
simplestFloat = SimplestFloat a -> ModifiedLayout WindowArranger SimplestFloat a
forall (l :: * -> *) a. l a -> ModifiedLayout WindowArranger l a
windowArrangeAll SimplestFloat a
forall a. SimplestFloat a
SF
data SimplestFloat a = SF deriving (Int -> SimplestFloat a -> ShowS
[SimplestFloat a] -> ShowS
SimplestFloat a -> String
(Int -> SimplestFloat a -> ShowS)
-> (SimplestFloat a -> String)
-> ([SimplestFloat a] -> ShowS)
-> Show (SimplestFloat a)
forall a. Int -> SimplestFloat a -> ShowS
forall a. [SimplestFloat a] -> ShowS
forall a. SimplestFloat a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimplestFloat a] -> ShowS
$cshowList :: forall a. [SimplestFloat a] -> ShowS
show :: SimplestFloat a -> String
$cshow :: forall a. SimplestFloat a -> String
showsPrec :: Int -> SimplestFloat a -> ShowS
$cshowsPrec :: forall a. Int -> SimplestFloat a -> ShowS
Show, ReadPrec [SimplestFloat a]
ReadPrec (SimplestFloat a)
Int -> ReadS (SimplestFloat a)
ReadS [SimplestFloat a]
(Int -> ReadS (SimplestFloat a))
-> ReadS [SimplestFloat a]
-> ReadPrec (SimplestFloat a)
-> ReadPrec [SimplestFloat a]
-> Read (SimplestFloat a)
forall a. ReadPrec [SimplestFloat a]
forall a. ReadPrec (SimplestFloat a)
forall a. Int -> ReadS (SimplestFloat a)
forall a. ReadS [SimplestFloat a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimplestFloat a]
$creadListPrec :: forall a. ReadPrec [SimplestFloat a]
readPrec :: ReadPrec (SimplestFloat a)
$creadPrec :: forall a. ReadPrec (SimplestFloat a)
readList :: ReadS [SimplestFloat a]
$creadList :: forall a. ReadS [SimplestFloat a]
readsPrec :: Int -> ReadS (SimplestFloat a)
$creadsPrec :: forall a. Int -> ReadS (SimplestFloat a)
Read)
instance LayoutClass SimplestFloat Window where
doLayout :: SimplestFloat Window
-> Rectangle
-> Stack Window
-> X ([(Window, Rectangle)], Maybe (SimplestFloat Window))
doLayout SF sc :: Rectangle
sc (S.Stack w :: Window
w l :: [Window]
l r :: [Window]
r) = ([(Window, Rectangle)]
-> ([(Window, Rectangle)], Maybe (SimplestFloat Window)))
-> X [(Window, Rectangle)]
-> X ([(Window, Rectangle)], Maybe (SimplestFloat Window))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([(Window, Rectangle)]
-> Maybe (SimplestFloat Window)
-> ([(Window, Rectangle)], Maybe (SimplestFloat Window)))
-> Maybe (SimplestFloat Window)
-> [(Window, Rectangle)]
-> ([(Window, Rectangle)], Maybe (SimplestFloat Window))
forall a b c. (a -> b -> c) -> b -> a -> c
flip (,) Maybe (SimplestFloat Window)
forall a. Maybe a
Nothing)
(X [(Window, Rectangle)]
-> X ([(Window, Rectangle)], Maybe (SimplestFloat Window)))
-> X [(Window, Rectangle)]
-> X ([(Window, Rectangle)], Maybe (SimplestFloat Window))
forall a b. (a -> b) -> a -> b
$ (Window -> X (Window, Rectangle))
-> [Window] -> X [(Window, Rectangle)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Rectangle -> Window -> X (Window, Rectangle)
getSize Rectangle
sc) (Window
w Window -> [Window] -> [Window]
forall a. a -> [a] -> [a]
: [Window] -> [Window]
forall a. [a] -> [a]
reverse [Window]
l [Window] -> [Window] -> [Window]
forall a. [a] -> [a] -> [a]
++ [Window]
r)
description :: SimplestFloat Window -> String
description _ = "SimplestFloat"
getSize :: Rectangle -> Window -> X (Window,Rectangle)
getSize :: Rectangle -> Window -> X (Window, Rectangle)
getSize (Rectangle rx :: Position
rx ry :: Position
ry _ _) w :: Window
w = do
Display
d <- (XConf -> Display) -> X Display
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Display
display
Window
bw <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks (XConfig Layout -> Window
forall (l :: * -> *). XConfig l -> Window
borderWidth (XConfig Layout -> Window)
-> (XConf -> XConfig Layout) -> XConf -> Window
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XConf -> XConfig Layout
config)
WindowAttributes
wa <- IO WindowAttributes -> X WindowAttributes
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO WindowAttributes -> X WindowAttributes)
-> IO WindowAttributes -> X WindowAttributes
forall a b. (a -> b) -> a -> b
$ Display -> Window -> IO WindowAttributes
getWindowAttributes Display
d Window
w
let x :: Position
x = Position -> Position -> Position
forall a. Ord a => a -> a -> a
max Position
rx (Position -> Position) -> Position -> Position
forall a b. (a -> b) -> a -> b
$ CInt -> Position
forall a b. (Integral a, Num b) => a -> b
fi (CInt -> Position) -> CInt -> Position
forall a b. (a -> b) -> a -> b
$ WindowAttributes -> CInt
wa_x WindowAttributes
wa
y :: Position
y = Position -> Position -> Position
forall a. Ord a => a -> a -> a
max Position
ry (Position -> Position) -> Position -> Position
forall a b. (a -> b) -> a -> b
$ CInt -> Position
forall a b. (Integral a, Num b) => a -> b
fi (CInt -> Position) -> CInt -> Position
forall a b. (a -> b) -> a -> b
$ WindowAttributes -> CInt
wa_y WindowAttributes
wa
wh :: Window
wh = (CInt -> Window
forall a b. (Integral a, Num b) => a -> b
fi (CInt -> Window) -> CInt -> Window
forall a b. (a -> b) -> a -> b
$ WindowAttributes -> CInt
wa_width WindowAttributes
wa) Window -> Window -> Window
forall a. Num a => a -> a -> a
+ (Window
bw Window -> Window -> Window
forall a. Num a => a -> a -> a
* 2)
ht :: Window
ht = (CInt -> Window
forall a b. (Integral a, Num b) => a -> b
fi (CInt -> Window) -> CInt -> Window
forall a b. (a -> b) -> a -> b
$ WindowAttributes -> CInt
wa_height WindowAttributes
wa) Window -> Window -> Window
forall a. Num a => a -> a -> a
+ (Window
bw Window -> Window -> Window
forall a. Num a => a -> a -> a
* 2)
(Window, Rectangle) -> X (Window, Rectangle)
forall (m :: * -> *) a. Monad m => a -> m a
return (Window
w, Position -> Position -> Window -> Window -> Rectangle
Rectangle Position
x Position
y Window
wh Window
ht)