{-# LANGUAGE CPP #-}
module Xmobar.X11.Draw (drawInWin) where
import Prelude hiding (lookup)
import Control.Monad.IO.Class
import Control.Monad.Reader
import Control.Monad (when)
import Control.Arrow ((&&&))
import Data.Map hiding (foldr, map, filter)
import Graphics.X11.Xlib hiding (textExtents, textWidth)
import Graphics.X11.Xlib.Extras
import Xmobar.Config.Types
import qualified Xmobar.X11.Bitmap as B
import Xmobar.X11.Actions (Action(..))
import Xmobar.X11.Types
import Xmobar.X11.Text
import Xmobar.X11.ColorCache
import Xmobar.X11.Window (drawBorder)
import Xmobar.X11.Parsers (Widget(..))
#ifdef XFT
import Xmobar.X11.MinXft
import Graphics.X11.Xrender
#endif
fi :: (Integral a, Num b) => a -> b
fi :: a -> b
fi = a -> b
forall a b. (Integral a, Num b) => a -> b
fromIntegral
drawInWin :: Rectangle -> [[(Widget, String, Int, Maybe [Action])]] -> X ()
drawInWin :: Rectangle -> [[(Widget, String, Int, Maybe [Action])]] -> X ()
drawInWin wr :: Rectangle
wr@(Rectangle Position
_ Position
_ Dimension
wid Dimension
ht) ~[[(Widget, String, Int, Maybe [Action])]
left,[(Widget, String, Int, Maybe [Action])]
center,[(Widget, String, Int, Maybe [Action])]
right] = do
XConf
r <- ReaderT XConf IO XConf
forall r (m :: * -> *). MonadReader r m => m r
ask
let (Config
c,Display
d) = (XConf -> Config
config (XConf -> Config)
-> (XConf -> Display) -> XConf -> (Config, Display)
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& XConf -> Display
display) XConf
r
(Window
w,([XFont]
fs,[Int]
vs)) = (XConf -> Window
window (XConf -> Window)
-> (XConf -> ([XFont], [Int]))
-> XConf
-> (Window, ([XFont], [Int]))
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& XConf -> [XFont]
fontListS (XConf -> [XFont]) -> (XConf -> [Int]) -> XConf -> ([XFont], [Int])
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& XConf -> [Int]
verticalOffsets) XConf
r
strLn :: [(Widget, b, Int, d)]
-> ReaderT XConf IO [(Widget, b, Int, Position)]
strLn = IO [(Widget, b, Int, Position)]
-> ReaderT XConf IO [(Widget, b, Int, Position)]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [(Widget, b, Int, Position)]
-> ReaderT XConf IO [(Widget, b, Int, Position)])
-> ([(Widget, b, Int, d)] -> IO [(Widget, b, Int, Position)])
-> [(Widget, b, Int, d)]
-> ReaderT XConf IO [(Widget, b, Int, Position)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Widget, b, Int, d) -> IO (Widget, b, Int, Position))
-> [(Widget, b, Int, d)] -> IO [(Widget, b, Int, Position)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Widget, b, Int, d) -> IO (Widget, b, Int, Position)
forall d b d.
Num d =>
(Widget, b, Int, d) -> IO (Widget, b, Int, d)
getWidth
iconW :: String -> Dimension
iconW String
i = Dimension -> (Bitmap -> Dimension) -> Maybe Bitmap -> Dimension
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Dimension
0 Bitmap -> Dimension
B.width (String -> Map String Bitmap -> Maybe Bitmap
forall k a. Ord k => k -> Map k a -> Maybe a
lookup String
i (Map String Bitmap -> Maybe Bitmap)
-> Map String Bitmap -> Maybe Bitmap
forall a b. (a -> b) -> a -> b
$ XConf -> Map String Bitmap
iconS XConf
r)
getWidth :: (Widget, b, Int, d) -> IO (Widget, b, Int, d)
getWidth (Text String
s,b
cl,Int
i,d
_) =
Display -> XFont -> String -> IO Int
textWidth Display
d ([XFont]
fs[XFont] -> Int -> XFont
forall a. [a] -> Int -> a
!!Int
i) String
s IO Int -> (Int -> IO (Widget, b, Int, d)) -> IO (Widget, b, Int, d)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
tw -> (Widget, b, Int, d) -> IO (Widget, b, Int, d)
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Widget
Text String
s,b
cl,Int
i,Int -> d
forall a b. (Integral a, Num b) => a -> b
fi Int
tw)
getWidth (Icon String
s,b
cl,Int
i,d
_) = (Widget, b, Int, d) -> IO (Widget, b, Int, d)
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Widget
Icon String
s,b
cl,Int
i,Dimension -> d
forall a b. (Integral a, Num b) => a -> b
fi (Dimension -> d) -> Dimension -> d
forall a b. (a -> b) -> a -> b
$ String -> Dimension
iconW String
s)
Window
p <- IO Window -> ReaderT XConf IO Window
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Window -> ReaderT XConf IO Window)
-> IO Window -> ReaderT XConf IO Window
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Dimension -> Dimension -> CInt -> IO Window
createPixmap Display
d Window
w Dimension
wid Dimension
ht
(Screen -> CInt
defaultDepthOfScreen (Display -> Screen
defaultScreenOfDisplay Display
d))
#if XFT
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Config -> Int
alpha Config
c Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
255) (IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> String -> Int -> Rectangle -> IO ()
drawBackground Display
d Window
p (Config -> String
bgColor Config
c) (Config -> Int
alpha Config
c) Rectangle
wr)
#else
_ <- return wr
#endif
Display -> [String] -> ([Window] -> X ()) -> X ()
forall (m :: * -> *) a.
MonadIO m =>
Display -> [String] -> ([Window] -> m a) -> m a
withColors Display
d [Config -> String
bgColor Config
c, Config -> String
borderColor Config
c] (([Window] -> X ()) -> X ()) -> ([Window] -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \[Window
bgcolor, Window
bdcolor] -> do
GC
gc <- IO GC -> ReaderT XConf IO GC
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GC -> ReaderT XConf IO GC) -> IO GC -> ReaderT XConf IO GC
forall a b. (a -> b) -> a -> b
$ Display -> Window -> IO GC
createGC Display
d Window
w
#if XFT
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Config -> Int
alpha Config
c Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
255) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ do
#else
do
#endif
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> GC -> Window -> IO ()
setForeground Display
d GC
gc Window
bgcolor
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display
-> Window
-> GC
-> Position
-> Position
-> Dimension
-> Dimension
-> IO ()
fillRectangle Display
d Window
p GC
gc Position
0 Position
0 Dimension
wid Dimension
ht
Window
-> GC
-> [XFont]
-> [Int]
-> Position
-> Align
-> [(Widget, String, Int, Position)]
-> X ()
printStrings Window
p GC
gc [XFont]
fs [Int]
vs Position
1 Align
L ([(Widget, String, Int, Position)] -> X ())
-> ReaderT XConf IO [(Widget, String, Int, Position)] -> X ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [(Widget, String, Int, Maybe [Action])]
-> ReaderT XConf IO [(Widget, String, Int, Position)]
forall b d.
[(Widget, b, Int, d)]
-> ReaderT XConf IO [(Widget, b, Int, Position)]
strLn [(Widget, String, Int, Maybe [Action])]
left
Window
-> GC
-> [XFont]
-> [Int]
-> Position
-> Align
-> [(Widget, String, Int, Position)]
-> X ()
printStrings Window
p GC
gc [XFont]
fs [Int]
vs Position
1 Align
R ([(Widget, String, Int, Position)] -> X ())
-> ReaderT XConf IO [(Widget, String, Int, Position)] -> X ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [(Widget, String, Int, Maybe [Action])]
-> ReaderT XConf IO [(Widget, String, Int, Position)]
forall b d.
[(Widget, b, Int, d)]
-> ReaderT XConf IO [(Widget, b, Int, Position)]
strLn [(Widget, String, Int, Maybe [Action])]
right
Window
-> GC
-> [XFont]
-> [Int]
-> Position
-> Align
-> [(Widget, String, Int, Position)]
-> X ()
printStrings Window
p GC
gc [XFont]
fs [Int]
vs Position
1 Align
C ([(Widget, String, Int, Position)] -> X ())
-> ReaderT XConf IO [(Widget, String, Int, Position)] -> X ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [(Widget, String, Int, Maybe [Action])]
-> ReaderT XConf IO [(Widget, String, Int, Position)]
forall b d.
[(Widget, b, Int, d)]
-> ReaderT XConf IO [(Widget, b, Int, Position)]
strLn [(Widget, String, Int, Maybe [Action])]
center
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Border
-> Int
-> Display
-> Window
-> GC
-> Window
-> Dimension
-> Dimension
-> IO ()
drawBorder (Config -> Border
border Config
c) (Config -> Int
borderWidth Config
c) Display
d Window
p GC
gc Window
bdcolor Dimension
wid Dimension
ht
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display
-> Window
-> Window
-> GC
-> Position
-> Position
-> Dimension
-> Dimension
-> Position
-> Position
-> IO ()
copyArea Display
d Window
p Window
w GC
gc Position
0 Position
0 Dimension
wid Dimension
ht Position
0 Position
0
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> GC -> IO ()
freeGC Display
d GC
gc
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> IO ()
freePixmap Display
d Window
p
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Bool -> IO ()
sync Display
d Bool
True
verticalOffset :: (Integral b, Integral a, MonadIO m) =>
a -> Widget -> XFont -> Int -> Config -> m b
verticalOffset :: a -> Widget -> XFont -> Int -> Config -> m b
verticalOffset a
ht (Text String
t) XFont
fontst Int
voffs Config
_
| Int
voffs Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> -Int
1 = b -> m b
forall (m :: * -> *) a. Monad m => a -> m a
return (b -> m b) -> b -> m b
forall a b. (a -> b) -> a -> b
$ Int -> b
forall a b. (Integral a, Num b) => a -> b
fi Int
voffs
| Bool
otherwise = do
(Position
as,Position
ds) <- IO (Position, Position) -> m (Position, Position)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Position, Position) -> m (Position, Position))
-> IO (Position, Position) -> m (Position, Position)
forall a b. (a -> b) -> a -> b
$ XFont -> String -> IO (Position, Position)
textExtents XFont
fontst String
t
let margin :: b
margin = (a -> b
forall a b. (Integral a, Num b) => a -> b
fi a
ht b -> b -> b
forall a. Num a => a -> a -> a
- Position -> b
forall a b. (Integral a, Num b) => a -> b
fi Position
ds b -> b -> b
forall a. Num a => a -> a -> a
- Position -> b
forall a b. (Integral a, Num b) => a -> b
fi Position
as) b -> b -> b
forall a. Integral a => a -> a -> a
`div` b
2
b -> m b
forall (m :: * -> *) a. Monad m => a -> m a
return (b -> m b) -> b -> m b
forall a b. (a -> b) -> a -> b
$ Position -> b
forall a b. (Integral a, Num b) => a -> b
fi Position
as b -> b -> b
forall a. Num a => a -> a -> a
+ b
margin b -> b -> b
forall a. Num a => a -> a -> a
- b
1
verticalOffset a
ht (Icon String
_) XFont
_ Int
_ Config
conf
| Config -> Int
iconOffset Config
conf Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> -Int
1 = b -> m b
forall (m :: * -> *) a. Monad m => a -> m a
return (b -> m b) -> b -> m b
forall a b. (a -> b) -> a -> b
$ Int -> b
forall a b. (Integral a, Num b) => a -> b
fi (Config -> Int
iconOffset Config
conf)
| Bool
otherwise = b -> m b
forall (m :: * -> *) a. Monad m => a -> m a
return (b -> m b) -> b -> m b
forall a b. (a -> b) -> a -> b
$ a -> b
forall a b. (Integral a, Num b) => a -> b
fi (a
ht a -> a -> a
forall a. Integral a => a -> a -> a
`div` a
2) b -> b -> b
forall a. Num a => a -> a -> a
- b
1
printString :: Display -> Drawable -> XFont -> GC -> String -> String
-> Position -> Position -> String -> Int -> IO ()
printString :: Display
-> Window
-> XFont
-> GC
-> String
-> String
-> Position
-> Position
-> String
-> Int
-> IO ()
printString Display
d Window
p (Core FontStruct
fs) GC
gc String
fc String
bc Position
x Position
y String
s Int
a = do
Display -> GC -> Window -> IO ()
setFont Display
d GC
gc (Window -> IO ()) -> Window -> IO ()
forall a b. (a -> b) -> a -> b
$ FontStruct -> Window
fontFromFontStruct FontStruct
fs
Display -> [String] -> ([Window] -> IO ()) -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
Display -> [String] -> ([Window] -> m a) -> m a
withColors Display
d [String
fc, String
bc] (([Window] -> IO ()) -> IO ()) -> ([Window] -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \[Window
fc', Window
bc'] -> do
Display -> GC -> Window -> IO ()
setForeground Display
d GC
gc Window
fc'
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
a Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
255) (Display -> GC -> Window -> IO ()
setBackground Display
d GC
gc Window
bc')
Display -> Window -> GC -> Position -> Position -> String -> IO ()
drawImageString Display
d Window
p GC
gc Position
x Position
y String
s
printString Display
d Window
p (Utf8 FontSet
fs) GC
gc String
fc String
bc Position
x Position
y String
s Int
a =
Display -> [String] -> ([Window] -> IO ()) -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
Display -> [String] -> ([Window] -> m a) -> m a
withColors Display
d [String
fc, String
bc] (([Window] -> IO ()) -> IO ()) -> ([Window] -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \[Window
fc', Window
bc'] -> do
Display -> GC -> Window -> IO ()
setForeground Display
d GC
gc Window
fc'
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
a Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
255) (Display -> GC -> Window -> IO ()
setBackground Display
d GC
gc Window
bc')
IO () -> IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Display
-> Window
-> FontSet
-> GC
-> Position
-> Position
-> String
-> IO ()
wcDrawImageString Display
d Window
p FontSet
fs GC
gc Position
x Position
y String
s
#ifdef XFT
printString Display
dpy Window
drw fs :: XFont
fs@(Xft [AXftFont]
fonts) GC
_ String
fc String
bc Position
x Position
y String
s Int
al =
Display
-> Window
-> String
-> String
-> (AXftDraw -> AXftColor -> AXftColor -> IO ())
-> IO ()
withDrawingColors Display
dpy Window
drw String
fc String
bc ((AXftDraw -> AXftColor -> AXftColor -> IO ()) -> IO ())
-> (AXftDraw -> AXftColor -> AXftColor -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \AXftDraw
draw AXftColor
fc' AXftColor
bc' -> do
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
al Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
255) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
(Position
a,Position
d) <- XFont -> String -> IO (Position, Position)
textExtents XFont
fs String
s
XGlyphInfo
gi <- Display -> [AXftFont] -> String -> IO XGlyphInfo
xftTxtExtents' Display
dpy [AXftFont]
fonts String
s
AXftDraw
-> AXftColor -> Position -> Position -> Int -> Position -> IO ()
forall a3 a2 a1 a.
(Integral a3, Integral a2, Integral a1, Integral a) =>
AXftDraw -> AXftColor -> a -> a1 -> a2 -> a3 -> IO ()
drawXftRect AXftDraw
draw AXftColor
bc' Position
x (Position
y Position -> Position -> Position
forall a. Num a => a -> a -> a
- Position
a) (Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ XGlyphInfo -> Int
xglyphinfo_xOff XGlyphInfo
gi) (Position
a Position -> Position -> Position
forall a. Num a => a -> a -> a
+ Position
d Position -> Position -> Position
forall a. Num a => a -> a -> a
+ Position
2)
AXftDraw
-> AXftColor -> [AXftFont] -> Integer -> Integer -> String -> IO ()
drawXftString' AXftDraw
draw AXftColor
fc' [AXftFont]
fonts (Position -> Integer
forall a. Integral a => a -> Integer
toInteger Position
x) (Position -> Integer
forall a. Integral a => a -> Integer
toInteger Position
y) String
s
#endif
printStrings :: Drawable -> GC -> [XFont] -> [Int] -> Position
-> Align -> [(Widget, String, Int, Position)] -> X ()
printStrings :: Window
-> GC
-> [XFont]
-> [Int]
-> Position
-> Align
-> [(Widget, String, Int, Position)]
-> X ()
printStrings Window
_ GC
_ [XFont]
_ [Int]
_ Position
_ Align
_ [] = () -> X ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
printStrings Window
dr GC
gc [XFont]
fontlist [Int]
voffs Position
offs Align
a sl :: [(Widget, String, Int, Position)]
sl@((Widget
s,String
c,Int
i,Position
l):[(Widget, String, Int, Position)]
xs) = do
XConf
r <- ReaderT XConf IO XConf
forall r (m :: * -> *). MonadReader r m => m r
ask
let (Config
conf,Display
d) = (XConf -> Config
config (XConf -> Config)
-> (XConf -> Display) -> XConf -> (Config, Display)
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& XConf -> Display
display) XConf
r
alph :: Int
alph = Config -> Int
alpha Config
conf
Rectangle Position
_ Position
_ Dimension
wid Dimension
ht = XConf -> Rectangle
rect XConf
r
totSLen :: Position
totSLen = ((Widget, String, Int, Position) -> Position -> Position)
-> Position -> [(Widget, String, Int, Position)] -> Position
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\(Widget
_,String
_,Int
_,Position
len) -> Position -> Position -> Position
forall a. Num a => a -> a -> a
(+) Position
len) Position
0 [(Widget, String, Int, Position)]
sl
remWidth :: Position
remWidth = Dimension -> Position
forall a b. (Integral a, Num b) => a -> b
fi Dimension
wid Position -> Position -> Position
forall a. Num a => a -> a -> a
- Position -> Position
forall a b. (Integral a, Num b) => a -> b
fi Position
totSLen
fontst :: XFont
fontst = [XFont]
fontlist [XFont] -> Int -> XFont
forall a. [a] -> Int -> a
!! Int
i
offset :: Position
offset = case Align
a of
Align
C -> (Position
remWidth Position -> Position -> Position
forall a. Num a => a -> a -> a
+ Position
offs) Position -> Position -> Position
forall a. Integral a => a -> a -> a
`div` Position
2
Align
R -> Position
remWidth
Align
L -> Position
offs
(String
fc,String
bc) = case (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
',') String
c of
(String
f,Char
',':String
b) -> (String
f, String
b )
(String
f, String
_) -> (String
f, Config -> String
bgColor Config
conf)
Position
valign <- Dimension
-> Widget -> XFont -> Int -> Config -> ReaderT XConf IO Position
forall b a (m :: * -> *).
(Integral b, Integral a, MonadIO m) =>
a -> Widget -> XFont -> Int -> Config -> m b
verticalOffset Dimension
ht Widget
s ([XFont] -> XFont
forall a. [a] -> a
head [XFont]
fontlist) ([Int]
voffs [Int] -> Int -> Int
forall a. [a] -> Int -> a
!! Int
i) Config
conf
case Widget
s of
(Text String
t) -> IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display
-> Window
-> XFont
-> GC
-> String
-> String
-> Position
-> Position
-> String
-> Int
-> IO ()
printString Display
d Window
dr XFont
fontst GC
gc String
fc String
bc Position
offset Position
valign String
t Int
alph
(Icon String
p) -> IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ IO () -> (Bitmap -> IO ()) -> Maybe Bitmap -> IO ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
(Display
-> Window
-> GC
-> String
-> String
-> Position
-> Position
-> Bitmap
-> IO ()
B.drawBitmap Display
d Window
dr GC
gc String
fc String
bc Position
offset Position
valign)
(String -> Map String Bitmap -> Maybe Bitmap
forall k a. Ord k => k -> Map k a -> Maybe a
lookup String
p (XConf -> Map String Bitmap
iconS XConf
r))
Window
-> GC
-> [XFont]
-> [Int]
-> Position
-> Align
-> [(Widget, String, Int, Position)]
-> X ()
printStrings Window
dr GC
gc [XFont]
fontlist [Int]
voffs (Position
offs Position -> Position -> Position
forall a. Num a => a -> a -> a
+ Position
l) Align
a [(Widget, String, Int, Position)]
xs