summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/X11/Bitmap.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/Bitmap.hs
parentc824651f98a84eab63cb5ba4a1a5cd98ba761036 (diff)
downloadxmobar-832985aec801620baa08bc434def294da8ef3f44.tar.gz
xmobar-832985aec801620baa08bc434def294da8ef3f44.tar.bz2
better abstracted icon drawing interface
Diffstat (limited to 'src/Xmobar/X11/Bitmap.hs')
-rw-r--r--src/Xmobar/X11/Bitmap.hs26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/Xmobar/X11/Bitmap.hs b/src/Xmobar/X11/Bitmap.hs
index d6a818b..b14356f 100644
--- a/src/Xmobar/X11/Bitmap.hs
+++ b/src/Xmobar/X11/Bitmap.hs
@@ -27,7 +27,6 @@ import System.Directory (doesFileExist)
import System.FilePath ((</>))
import System.Mem.Weak ( addFinalizer )
-import Xmobar.Draw.Types (BitmapType(..), Bitmap(..), BitmapCache)
import Xmobar.X11.ColorCache
#ifdef XPM
@@ -47,7 +46,18 @@ runExceptT = runErrorT
#endif
-updateCache :: Display -> Window -> Map FilePath Bitmap -> FilePath -> [FilePath]
+data BitmapType = Mono Pixel | Poly
+
+data Bitmap = Bitmap { width :: Dimension
+ , height :: Dimension
+ , pixmap :: Pixmap
+ , shapePixmap :: Maybe Pixmap
+ , bitmapType :: BitmapType
+ }
+
+type BitmapCache = Map FilePath Bitmap
+
+updateCache :: Display -> Window -> BitmapCache -> FilePath -> [FilePath]
-> IO BitmapCache
updateCache dpy win cache iconRoot paths = do
let expandPath path@('/':_) = path
@@ -107,15 +117,15 @@ drawBitmap :: Display -> Drawable -> GC -> String -> String
-> Position -> Position -> Bitmap -> IO ()
drawBitmap d p gc fc bc x y i =
withColors d [fc, bc] $ \[fc', bc'] -> do
- let w = bWidth i
- h = bHeight i
+ let w = width i
+ h = height i
y' = 1 + y - fromIntegral h `div` 2
setForeground d gc fc'
setBackground d gc bc'
- case bShapepixmap i of
+ case shapePixmap i of
Nothing -> return ()
Just mask -> setClipOrigin d gc x y' >> setClipMask d gc mask
- case bBitmaptype i of
- Poly -> copyArea d (bPixmap i) p gc 0 0 w h x y'
- Mono pl -> copyPlane d (bPixmap i) p gc 0 0 w h x y' pl
+ case bitmapType i of
+ Poly -> copyArea d (pixmap i) p gc 0 0 w h x y'
+ Mono pl -> copyPlane d (pixmap i) p gc 0 0 w h x y' pl
setClipMask d gc 0