diff options
author | jao <jao@gnu.org> | 2022-09-20 05:41:27 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-09-20 05:41:27 +0100 |
commit | 4b4c9fe0a8849fad124a2f75e815e648dafd4969 (patch) | |
tree | 69fe7d3f6a5a939c8120c0ff5cd9d71a61da648e /src/Xmobar/X11/Bitmap.hs | |
parent | c7681d79108f6e03f5adc33ebb96f14cf9b83f16 (diff) | |
download | xmobar-4b4c9fe0a8849fad124a2f75e815e648dafd4969.tar.gz xmobar-4b4c9fe0a8849fad124a2f75e815e648dafd4969.tar.bz2 |
new namespace: Xmobar.Draw
Diffstat (limited to 'src/Xmobar/X11/Bitmap.hs')
-rw-r--r-- | src/Xmobar/X11/Bitmap.hs | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/Xmobar/X11/Bitmap.hs b/src/Xmobar/X11/Bitmap.hs index 220741e..d6a818b 100644 --- a/src/Xmobar/X11/Bitmap.hs +++ b/src/Xmobar/X11/Bitmap.hs @@ -20,10 +20,14 @@ module Xmobar.X11.Bitmap import Control.Monad import Control.Monad.Trans(MonadIO(..)) import Data.Map hiding (map) + import Graphics.X11.Xlib hiding (Segment) + 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 @@ -43,17 +47,6 @@ runExceptT = runErrorT #endif -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 -> Map FilePath Bitmap -> FilePath -> [FilePath] -> IO BitmapCache updateCache dpy win cache iconRoot paths = do @@ -114,15 +107,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 = width i - h = height i + let w = bWidth i + h = bHeight i y' = 1 + y - fromIntegral h `div` 2 setForeground d gc fc' setBackground d gc bc' - case shapePixmap i of + case bShapepixmap i of Nothing -> return () Just mask -> setClipOrigin d gc x y' >> setClipMask d gc mask - 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 + 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 setClipMask d gc 0 |