diff options
author | Alexander Polakov <plhk@sdf.org> | 2013-02-03 22:08:45 +0400 |
---|---|---|
committer | Alexander Polakov <plhk@sdf.org> | 2013-02-03 22:08:45 +0400 |
commit | dc601c199d55a568902b653566cef49c488e415f (patch) | |
tree | a12f3601263623a6fa12b5ae736d4b8caa1a1fba /src | |
parent | 33b93acb17c0ccee7f3d55b5995e4352a0c6be1d (diff) | |
download | xmobar-dc601c199d55a568902b653566cef49c488e415f.tar.gz xmobar-dc601c199d55a568902b653566cef49c488e415f.tar.bz2 |
Fit to 80 columns
Diffstat (limited to 'src')
-rw-r--r-- | src/Bitmap.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Bitmap.hs b/src/Bitmap.hs index 44dec5d..3479e28 100644 --- a/src/Bitmap.hs +++ b/src/Bitmap.hs @@ -29,17 +29,17 @@ data Bitmap = Bitmap { width :: Dimension , pixmap :: Pixmap } -updateCache :: Display -> Window -> Map FilePath Bitmap -> [[(Widget, String)]] -> IO (Map FilePath Bitmap) +updateCache :: Display -> Window -> Map FilePath Bitmap -> [[(Widget, String)]] + -> IO (Map FilePath Bitmap) updateCache dpy win cache ps = do let paths = map (\(Icon p, _) -> p) . concatMap (filter icons) $ ps icons (Icon _, _) = True icons _ = False - foldM (\m path -> if member path m - then return m - else do bitmap <- loadBitmap dpy win path - case bitmap of - Nothing -> return m - Just bmap -> return $ insert path bmap m) cache paths + go m path = if member path m + then return m + else do bitmap <- loadBitmap dpy win path + return $ maybe m (\b -> insert path b m) bitmap + foldM go cache paths loadBitmap :: Display -> Drawable -> FilePath -> IO (Maybe Bitmap) loadBitmap d w p = do @@ -53,9 +53,11 @@ loadBitmap d w p = do return Nothing drawBitmap :: Display -> Drawable -> GC -> String -> String - -> Position -> Position -> Bitmap -> IO () -drawBitmap d p gc fc bc x y i = do + -> 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 setForeground d gc fc' setBackground d gc bc' - copyPlane d (pixmap i) p gc 0 0 (width i) (height i) x (y - (fromIntegral $ height i)) 1 + copyPlane d (pixmap i) p gc 0 0 w h x (y - (fromIntegral h)) 1 |