summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/X11/Draw.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-21 00:52:59 +0100
committerjao <jao@gnu.org>2022-09-21 01:11:33 +0100
commit832985aec801620baa08bc434def294da8ef3f44 (patch)
tree6bbc9d5903d753062932b5979b3f28e44e569b9e /src/Xmobar/X11/Draw.hs
parentc824651f98a84eab63cb5ba4a1a5cd98ba761036 (diff)
downloadxmobar-832985aec801620baa08bc434def294da8ef3f44.tar.gz
xmobar-832985aec801620baa08bc434def294da8ef3f44.tar.bz2
better abstracted icon drawing interface
Diffstat (limited to 'src/Xmobar/X11/Draw.hs')
-rw-r--r--src/Xmobar/X11/Draw.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Xmobar/X11/Draw.hs b/src/Xmobar/X11/Draw.hs
index 7e0dfd1..a056136 100644
--- a/src/Xmobar/X11/Draw.hs
+++ b/src/Xmobar/X11/Draw.hs
@@ -37,18 +37,21 @@ import qualified Xmobar.X11.CairoSurface as CS
import qualified Xmobar.X11.XRender as XRender
#endif
-drawXBitmap :: T.XConf -> X11.GC -> X11.Pixmap -> D.BitmapDrawer
+drawXBitmap :: T.XConf -> X11.GC -> X11.Pixmap -> D.IconDrawer
drawXBitmap xconf gc p h v path = do
let disp = T.display xconf
conf = T.config xconf
fc = C.fgColor conf
bc = C.bgColor conf
- case lookupXBitmap xconf path of
+ case M.lookup path (T.iconCache xconf) of
Just bm -> liftIO $ B.drawBitmap disp p gc fc bc (round h) (round v) bm
Nothing -> return ()
-lookupXBitmap :: T.XConf -> String -> Maybe B.Bitmap
-lookupXBitmap xconf path = M.lookup path (T.iconCache xconf)
+lookupXBitmap :: T.XConf -> String -> (Double, Double)
+lookupXBitmap xconf path =
+ case M.lookup path (T.iconCache xconf) of
+ Just bm -> (fromIntegral (B.width bm), fromIntegral (B.height bm))
+ Nothing -> (0, 0)
withPixmap :: X11.Display -> X11.Drawable -> X11.Rectangle -> FT.CInt
-> (X11.GC -> X11.Pixmap -> IO a) -> IO a