module Xmobar.X11.Window where
import qualified Control.Monad as CM
import qualified Data.Function as DF
import qualified Data.List as DL
import qualified Data.Maybe as DM
import qualified Graphics.X11.Xlib as X
import qualified Graphics.X11.Xlib.Extras as Xx
import qualified Graphics.X11.Xinerama as Xi
import qualified Foreign.C.Types as C
import qualified System.Posix.Process as PP
import qualified Xmobar.Config.Types as T
import qualified Xmobar.X11.Text as Txt
newWindow ::
X.Display -> X.Screen -> X.Window -> X.Rectangle -> Bool -> IO X.Window
newWindow :: Display -> Screen -> Atom -> Rectangle -> Bool -> IO Atom
newWindow Display
dpy Screen
scr Atom
rw (X.Rectangle Position
x Position
y Dimension
w Dimension
h) Bool
o = do
let visual :: Visual
visual = Screen -> Visual
X.defaultVisualOfScreen Screen
scr
attrmask :: Atom
attrmask = if Bool
o then Atom
X.cWOverrideRedirect else Atom
0
forall a. (Ptr SetWindowAttributes -> IO a) -> IO a
X.allocaSetWindowAttributes forall a b. (a -> b) -> a -> b
$
\Ptr SetWindowAttributes
attributes -> do
Ptr SetWindowAttributes -> Bool -> IO ()
X.set_override_redirect Ptr SetWindowAttributes
attributes Bool
o
Display
-> Atom
-> Position
-> Position
-> Dimension
-> Dimension
-> CInt
-> CInt
-> CInt
-> Visual
-> Atom
-> Ptr SetWindowAttributes
-> IO Atom
X.createWindow Display
dpy Atom
rw Position
x Position
y Dimension
w Dimension
h CInt
0 (Screen -> CInt
X.defaultDepthOfScreen Screen
scr)
CInt
X.inputOutput Visual
visual Atom
attrmask Ptr SetWindowAttributes
attributes
createWin :: X.Display -> Txt.XFont -> T.Config -> IO (X.Rectangle, X.Window)
createWin :: Display -> XFont -> Config -> IO (Rectangle, Atom)
createWin Display
d XFont
fs Config
c = do
let dflt :: Dimension
dflt = Display -> Dimension
X.defaultScreen Display
d
[Rectangle]
srs <- Display -> IO [Rectangle]
Xi.getScreenInfo Display
d
Atom
rootw <- Display -> Dimension -> IO Atom
X.rootWindow Display
d Dimension
dflt
(Position
as,Position
ds) <- XFont -> String -> IO (Position, Position)
Txt.textExtents XFont
fs String
"0"
let ht :: Position
ht = Position
as forall a. Num a => a -> a -> a
+ Position
ds forall a. Num a => a -> a -> a
+ Position
4
r :: Rectangle
r = Config -> XPosition -> [Rectangle] -> Dimension -> Rectangle
setPosition Config
c (Config -> XPosition
T.position Config
c) [Rectangle]
srs (forall a b. (Integral a, Num b) => a -> b
fromIntegral Position
ht)
Atom
win <- Display -> Screen -> Atom -> Rectangle -> Bool -> IO Atom
newWindow Display
d (Display -> Screen
X.defaultScreenOfDisplay Display
d) Atom
rootw Rectangle
r (Config -> Bool
T.overrideRedirect Config
c)
Config -> Display -> Atom -> IO ()
setProperties Config
c Display
d Atom
win
Rectangle -> Config -> Display -> Atom -> [Rectangle] -> IO ()
setStruts Rectangle
r Config
c Display
d Atom
win [Rectangle]
srs
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
CM.when (Config -> Bool
T.lowerOnStart Config
c) forall a b. (a -> b) -> a -> b
$ Display -> Atom -> IO ()
X.lowerWindow Display
d Atom
win
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
CM.unless (Config -> Bool
T.hideOnStart Config
c) forall a b. (a -> b) -> a -> b
$ Rectangle -> Config -> Display -> Atom -> IO ()
showWindow Rectangle
r Config
c Display
d Atom
win
forall (m :: * -> *) a. Monad m => a -> m a
return (Rectangle
r,Atom
win)
repositionWin :: X.Display -> X.Window -> Txt.XFont -> T.Config -> IO X.Rectangle
repositionWin :: Display -> Atom -> XFont -> Config -> IO Rectangle
repositionWin Display
d Atom
win XFont
fs Config
c = do
[Rectangle]
srs <- Display -> IO [Rectangle]
Xi.getScreenInfo Display
d
(Position
as,Position
ds) <- XFont -> String -> IO (Position, Position)
Txt.textExtents XFont
fs String
"0"
let ht :: Position
ht = Position
as forall a. Num a => a -> a -> a
+ Position
ds forall a. Num a => a -> a -> a
+ Position
4
r :: Rectangle
r = Config -> XPosition -> [Rectangle] -> Dimension -> Rectangle
setPosition Config
c (Config -> XPosition
T.position Config
c) [Rectangle]
srs (forall a b. (Integral a, Num b) => a -> b
fromIntegral Position
ht)
Display
-> Atom -> Position -> Position -> Dimension -> Dimension -> IO ()
X.moveResizeWindow Display
d Atom
win
(Rectangle -> Position
X.rect_x Rectangle
r) (Rectangle -> Position
X.rect_y Rectangle
r) (Rectangle -> Dimension
X.rect_width Rectangle
r) (Rectangle -> Dimension
X.rect_height Rectangle
r)
Rectangle -> Config -> Display -> Atom -> [Rectangle] -> IO ()
setStruts Rectangle
r Config
c Display
d Atom
win [Rectangle]
srs
Display -> Bool -> IO ()
X.sync Display
d Bool
False
forall (m :: * -> *) a. Monad m => a -> m a
return Rectangle
r
fi :: (Integral a, Num b) => a -> b
fi :: forall a b. (Integral a, Num b) => a -> b
fi = forall a b. (Integral a, Num b) => a -> b
fromIntegral
setPosition ::
T.Config -> T.XPosition -> [X.Rectangle] -> X.Dimension -> X.Rectangle
setPosition :: Config -> XPosition -> [Rectangle] -> Dimension -> Rectangle
setPosition Config
c XPosition
p [Rectangle]
rs Dimension
ht =
case XPosition
p' of
XPosition
T.Top -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle Position
rx Position
ry Dimension
rw Dimension
h
T.TopP Int
l Int
r -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (Position
rx forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Int
l) Position
ry (Dimension
rw forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
l forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
r) Dimension
h
T.TopH Int
ch -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle Position
rx Position
ry Dimension
rw (forall {a}. Integral a => a -> Dimension
mh Int
ch)
T.TopHM Int
ch Int
l Int
r Int
t Int
_ ->
Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (Position
rx forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Int
l) (Position
ry forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Int
t) (Dimension
rw forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
l forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
r) (forall {a}. Integral a => a -> Dimension
mh Int
ch)
T.TopW Align
a Int
i -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (forall {b}. Integral b => Align -> b -> Position
ax Align
a Int
i) Position
ry (Int -> Dimension
nw Int
i) Dimension
h
T.TopSize Align
a Int
i Int
ch -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (forall {b}. Integral b => Align -> b -> Position
ax Align
a Int
i) Position
ry (Int -> Dimension
nw Int
i) (forall {a}. Integral a => a -> Dimension
mh Int
ch)
XPosition
T.Bottom -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle Position
rx Position
ny Dimension
rw Dimension
h
T.BottomH Int
ch -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle Position
rx (forall {a}. Integral a => a -> Position
ny' Int
ch) Dimension
rw (forall {a}. Integral a => a -> Dimension
mh Int
ch)
T.BottomHM Int
ch Int
l Int
r Int
_ Int
b ->
Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (Position
rx forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Int
l) (Position
ry forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Dimension
rh forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
b forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi (forall {a}. Integral a => a -> Dimension
mh Int
ch)) (Dimension
rw forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
l forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
r) (forall {a}. Integral a => a -> Dimension
mh Int
ch)
T.BottomW Align
a Int
i -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (forall {b}. Integral b => Align -> b -> Position
ax Align
a Int
i) Position
ny (Int -> Dimension
nw Int
i) Dimension
h
T.BottomP Int
l Int
r -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (Position
rx forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Int
l) Position
ny (Dimension
rw forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
l forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Int
r) Dimension
h
T.BottomSize Align
a Int
i Int
ch -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (forall {b}. Integral b => Align -> b -> Position
ax Align
a Int
i) (forall {a}. Integral a => a -> Position
ny' Int
ch) (Int -> Dimension
nw Int
i) (forall {a}. Integral a => a -> Dimension
mh Int
ch)
T.Static Int
cx Int
cy Int
cw Int
ch -> Position -> Position -> Dimension -> Dimension -> Rectangle
X.Rectangle (forall a b. (Integral a, Num b) => a -> b
fi Int
cx) (forall a b. (Integral a, Num b) => a -> b
fi Int
cy) (forall a b. (Integral a, Num b) => a -> b
fi Int
cw) (forall a b. (Integral a, Num b) => a -> b
fi Int
ch)
T.OnScreen Int
_ XPosition
p'' -> Config -> XPosition -> [Rectangle] -> Dimension -> Rectangle
setPosition Config
c XPosition
p'' [Rectangle
scr] Dimension
ht
where
(scr :: Rectangle
scr@(X.Rectangle Position
rx Position
ry Dimension
rw Dimension
rh), XPosition
p') =
case XPosition
p of T.OnScreen Int
i XPosition
x -> (forall a. a -> Maybe a -> a
DM.fromMaybe ([Rectangle] -> Rectangle
picker [Rectangle]
rs) forall a b. (a -> b) -> a -> b
$ forall {a} {b}. (Eq a, Num a, Enum a) => a -> [b] -> Maybe b
safeIndex Int
i [Rectangle]
rs, XPosition
x)
XPosition
_ -> ([Rectangle] -> Rectangle
picker [Rectangle]
rs, XPosition
p)
ny :: Position
ny = Position
ry forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi (Dimension
rh forall a. Num a => a -> a -> a
- Dimension
ht)
center :: a -> Position
center a
i = Position
rx forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi (forall a. Integral a => a -> a -> a
div (forall {a}. Integral a => a -> Dimension
remwid a
i) Dimension
2)
right :: a -> Position
right a
i = Position
rx forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi (forall {a}. Integral a => a -> Dimension
remwid a
i)
remwid :: a -> Dimension
remwid a
i = Dimension
rw forall a. Num a => a -> a -> a
- Dimension -> Dimension
pw (forall a b. (Integral a, Num b) => a -> b
fi a
i)
ax :: Align -> b -> Position
ax Align
T.L = forall a b. a -> b -> a
const Position
rx
ax Align
T.R = forall {a}. Integral a => a -> Position
right
ax Align
T.C = forall {a}. Integral a => a -> Position
center
pw :: Dimension -> Dimension
pw Dimension
i = Dimension
rw forall a. Num a => a -> a -> a
* forall a. Ord a => a -> a -> a
min Dimension
100 Dimension
i forall a. Integral a => a -> a -> a
`div` Dimension
100
nw :: Int -> Dimension
nw = forall a b. (Integral a, Num b) => a -> b
fi forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dimension -> Dimension
pw forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fi
h :: Dimension
h = forall a b. (Integral a, Num b) => a -> b
fi Dimension
ht
mh :: a -> Dimension
mh a
h' = forall a. Ord a => a -> a -> a
max (forall a b. (Integral a, Num b) => a -> b
fi a
h') Dimension
h
ny' :: a -> Position
ny' a
h' = Position
ry forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi (Dimension
rh forall a. Num a => a -> a -> a
- forall {a}. Integral a => a -> Dimension
mh a
h')
safeIndex :: a -> [b] -> Maybe b
safeIndex a
i = forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup a
i forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. [a] -> [b] -> [(a, b)]
zip [a
0..]
picker :: [Rectangle] -> Rectangle
picker = if Config -> Bool
T.pickBroadest Config
c
then forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
DL.maximumBy (forall a. Ord a => a -> a -> Ordering
compare forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`DF.on` Rectangle -> Dimension
X.rect_width)
else forall a. [a] -> a
head
setProperties :: T.Config -> X.Display -> X.Window -> IO ()
setProperties :: Config -> Display -> Atom -> IO ()
setProperties Config
c Display
d Atom
w = do
let mkatom :: String -> IO Atom
mkatom String
n = Display -> String -> Bool -> IO Atom
X.internAtom Display
d String
n Bool
False
Atom
card <- String -> IO Atom
mkatom String
"CARDINAL"
Atom
atom <- String -> IO Atom
mkatom String
"ATOM"
Display -> Atom -> String -> Atom -> IO ()
X.setTextProperty Display
d Atom
w (Config -> String
T.wmClass Config
c) Atom
X.wM_CLASS
Display -> Atom -> String -> Atom -> IO ()
X.setTextProperty Display
d Atom
w (Config -> String
T.wmName Config
c) Atom
X.wM_NAME
Atom
wtype <- String -> IO Atom
mkatom String
"_NET_WM_WINDOW_TYPE"
Atom
dock <- String -> IO Atom
mkatom String
"_NET_WM_WINDOW_TYPE_DOCK"
Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
Xx.changeProperty32 Display
d Atom
w Atom
wtype Atom
atom CInt
Xx.propModeReplace [forall a b. (Integral a, Num b) => a -> b
fi Atom
dock]
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
CM.when (Config -> Bool
T.allDesktops Config
c) forall a b. (a -> b) -> a -> b
$ do
Atom
desktop <- String -> IO Atom
mkatom String
"_NET_WM_DESKTOP"
Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
Xx.changeProperty32 Display
d Atom
w Atom
desktop Atom
card CInt
Xx.propModeReplace [CLong
0xffffffff]
Atom
pid <- String -> IO Atom
mkatom String
"_NET_WM_PID"
IO ProcessID
PP.getProcessID forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
Xx.changeProperty32 Display
d Atom
w Atom
pid Atom
card CInt
Xx.propModeReplace forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fi
setStruts' :: X.Display -> X.Window -> [C.CLong] -> IO ()
setStruts' :: Display -> Atom -> [CLong] -> IO ()
setStruts' Display
d Atom
w [CLong]
svs = do
let mkatom :: String -> IO Atom
mkatom String
n = Display -> String -> Bool -> IO Atom
X.internAtom Display
d String
n Bool
False
Atom
card <- String -> IO Atom
mkatom String
"CARDINAL"
Atom
pstrut <- String -> IO Atom
mkatom String
"_NET_WM_STRUT_PARTIAL"
Atom
strut <- String -> IO Atom
mkatom String
"_NET_WM_STRUT"
Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
Xx.changeProperty32 Display
d Atom
w Atom
pstrut Atom
card CInt
Xx.propModeReplace [CLong]
svs
Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
Xx.changeProperty32 Display
d Atom
w Atom
strut Atom
card CInt
Xx.propModeReplace (forall a. Int -> [a] -> [a]
take Int
4 [CLong]
svs)
setStruts ::
X.Rectangle -> T.Config -> X.Display -> X.Window -> [X.Rectangle] -> IO ()
setStruts :: Rectangle -> Config -> Display -> Atom -> [Rectangle] -> IO ()
setStruts Rectangle
r Config
c Display
d Atom
w [Rectangle]
rs = do
let svs :: [CLong]
svs = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fi forall a b. (a -> b) -> a -> b
$ Rectangle -> XPosition -> Int -> [Int]
getStrutValues Rectangle
r (Config -> XPosition
T.position Config
c) ([Rectangle] -> Int
getRootWindowHeight [Rectangle]
rs)
Display -> Atom -> [CLong] -> IO ()
setStruts' Display
d Atom
w [CLong]
svs
getRootWindowHeight :: [X.Rectangle] -> Int
getRootWindowHeight :: [Rectangle] -> Int
getRootWindowHeight [Rectangle]
srs = forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum (forall a b. (a -> b) -> [a] -> [b]
map forall {a}. Num a => Rectangle -> a
getMaxScreenYCoord [Rectangle]
srs)
where
getMaxScreenYCoord :: Rectangle -> a
getMaxScreenYCoord Rectangle
sr = forall a b. (Integral a, Num b) => a -> b
fi (Rectangle -> Position
X.rect_y Rectangle
sr) forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi (Rectangle -> Dimension
X.rect_height Rectangle
sr)
getStrutValues :: X.Rectangle -> T.XPosition -> Int -> [Int]
getStrutValues :: Rectangle -> XPosition -> Int -> [Int]
getStrutValues r :: Rectangle
r@(X.Rectangle Position
x Position
y Dimension
w Dimension
h) XPosition
p Int
rwh =
case XPosition
p of
T.OnScreen Int
_ XPosition
p' -> Rectangle -> XPosition -> Int -> [Int]
getStrutValues Rectangle
r XPosition
p' Int
rwh
XPosition
T.Top -> [Int
0, Int
0, Int
st , Int
0 , Int
0, Int
0, Int
0, Int
0, Int
nx, Int
nw, Int
0 , Int
0 ]
T.TopH Int
_ -> [Int
0, Int
0, Int
st , Int
0 , Int
0, Int
0, Int
0, Int
0, Int
nx, Int
nw, Int
0 , Int
0 ]
T.TopHM Int
_ Int
_ Int
_ Int
_ Int
b -> [Int
0, Int
0, Int
stforall a. Num a => a -> a -> a
+Int
b, Int
0 , Int
0, Int
0, Int
0, Int
0, Int
nx, Int
nw, Int
0 , Int
0 ]
T.TopP Int
_ Int
_ -> [Int
0, Int
0, Int
st , Int
0 , Int
0, Int
0, Int
0, Int
0, Int
nx, Int
nw, Int
0 , Int
0 ]
T.TopW Align
_ Int
_ -> [Int
0, Int
0, Int
st , Int
0 , Int
0, Int
0, Int
0, Int
0, Int
nx, Int
nw, Int
0 , Int
0 ]
T.TopSize {} -> [Int
0, Int
0, Int
st , Int
0 , Int
0, Int
0, Int
0, Int
0, Int
nx, Int
nw, Int
0 , Int
0 ]
XPosition
T.Bottom -> [Int
0, Int
0, Int
0 , Int
sb , Int
0, Int
0, Int
0, Int
0, Int
0 , Int
0 , Int
nx, Int
nw]
T.BottomH Int
_ -> [Int
0, Int
0, Int
0 , Int
sb , Int
0, Int
0, Int
0, Int
0, Int
0 , Int
0 , Int
nx, Int
nw]
T.BottomHM Int
_ Int
_ Int
_ Int
t Int
_ -> [Int
0, Int
0, Int
0 , Int
sbforall a. Num a => a -> a -> a
+Int
t, Int
0, Int
0, Int
0, Int
0, Int
0 , Int
0 , Int
nx, Int
nw]
T.BottomP Int
_ Int
_ -> [Int
0, Int
0, Int
0 , Int
sb , Int
0, Int
0, Int
0, Int
0, Int
0 , Int
0 , Int
nx, Int
nw]
T.BottomW Align
_ Int
_ -> [Int
0, Int
0, Int
0 , Int
sb , Int
0, Int
0, Int
0, Int
0, Int
0 , Int
0 , Int
nx, Int
nw]
T.BottomSize {} -> [Int
0, Int
0, Int
0 , Int
sb , Int
0, Int
0, Int
0, Int
0, Int
0 , Int
0 , Int
nx, Int
nw]
T.Static {} -> XPosition -> Int -> [Int]
getStaticStrutValues XPosition
p Int
rwh
where st :: Int
st = forall a b. (Integral a, Num b) => a -> b
fi Position
y forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Dimension
h
sb :: Int
sb = Int
rwh forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fi Position
y
nx :: Int
nx = forall a b. (Integral a, Num b) => a -> b
fi Position
x
nw :: Int
nw = forall a b. (Integral a, Num b) => a -> b
fi (Position
x forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fi Dimension
w forall a. Num a => a -> a -> a
- Position
1)
getStaticStrutValues :: T.XPosition -> Int -> [Int]
getStaticStrutValues :: XPosition -> Int -> [Int]
getStaticStrutValues (T.Static Int
cx Int
cy Int
cw Int
ch) Int
rwh
| Int
cy forall a. Ord a => a -> a -> Bool
< (Int
rwh forall a. Integral a => a -> a -> a
`div` Int
2) = [Int
0, Int
0, Int
st, Int
0, Int
0, Int
0, Int
0, Int
0, Int
xs, Int
xe, Int
0, Int
0]
| Bool
otherwise = [Int
0, Int
0, Int
0, Int
sb, Int
0, Int
0, Int
0, Int
0, Int
0, Int
0, Int
xs, Int
xe]
where st :: Int
st = Int
cy forall a. Num a => a -> a -> a
+ Int
ch
sb :: Int
sb = Int
rwh forall a. Num a => a -> a -> a
- Int
cy
xs :: Int
xs = Int
cx
xe :: Int
xe = Int
xs forall a. Num a => a -> a -> a
+ Int
cw forall a. Num a => a -> a -> a
- Int
1
getStaticStrutValues XPosition
_ Int
_ = [Int
0, Int
0, Int
0, Int
0, Int
0, Int
0, Int
0, Int
0, Int
0, Int
0, Int
0, Int
0]
hideWindow :: X.Display -> X.Window -> IO ()
hideWindow :: Display -> Atom -> IO ()
hideWindow Display
d Atom
w = do
Display -> Atom -> [CLong] -> IO ()
setStruts' Display
d Atom
w (forall a. Int -> a -> [a]
replicate Int
12 CLong
0)
Display -> Atom -> IO ()
Xx.unmapWindow Display
d Atom
w forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Display -> Bool -> IO ()
X.sync Display
d Bool
False
showWindow :: X.Rectangle -> T.Config -> X.Display -> X.Window -> IO ()
showWindow :: Rectangle -> Config -> Display -> Atom -> IO ()
showWindow Rectangle
r Config
c Display
d Atom
w = do
Display -> Atom -> IO ()
X.mapWindow Display
d Atom
w
Display -> IO [Rectangle]
Xi.getScreenInfo Display
d forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Rectangle -> Config -> Display -> Atom -> [Rectangle] -> IO ()
setStruts Rectangle
r Config
c Display
d Atom
w
Display -> Bool -> IO ()
X.sync Display
d Bool
False
isMapped :: X.Display -> X.Window -> IO Bool
isMapped :: Display -> Atom -> IO Bool
isMapped Display
d Atom
w = WindowAttributes -> Bool
ism forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Display -> Atom -> IO WindowAttributes
Xx.getWindowAttributes Display
d Atom
w
where ism :: WindowAttributes -> Bool
ism Xx.WindowAttributes { wa_map_state :: WindowAttributes -> CInt
Xx.wa_map_state = CInt
wms } = CInt
wms forall a. Eq a => a -> a -> Bool
/= CInt
Xx.waIsUnmapped