diff options
author | jao <jao@gnu.org> | 2022-09-11 02:27:56 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-09-11 02:28:18 +0100 |
commit | d0f547be5380ec14cc334b15a530ba869668581a (patch) | |
tree | 764bb33481073aff0f924df9dbce6375f5581995 /src/Xmobar/X11/CairoDraw.hs | |
parent | 65f2bb18a372fc32a95c9887ba7a4006dc4ea24a (diff) | |
download | xmobar-d0f547be5380ec14cc334b15a530ba869668581a.tar.gz xmobar-d0f547be5380ec14cc334b15a530ba869668581a.tar.bz2 |
cairo: alpha (still pseudo, via xrender)
Diffstat (limited to 'src/Xmobar/X11/CairoDraw.hs')
-rw-r--r-- | src/Xmobar/X11/CairoDraw.hs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Xmobar/X11/CairoDraw.hs b/src/Xmobar/X11/CairoDraw.hs index 464dfa3..32adac2 100644 --- a/src/Xmobar/X11/CairoDraw.hs +++ b/src/Xmobar/X11/CairoDraw.hs @@ -53,8 +53,9 @@ segmentMarkup :: Config -> Segment -> String segmentMarkup conf (Text txt, info, idx, _actions) = let fnt = fixXft $ indexedFont conf idx (fg, bg) = colorComponents conf (tColorsString info) - attrs = [P.FontDescr fnt, P.FontForeground fg, P.FontBackground bg] - in P.markSpan attrs $ P.escapeMarkup txt + attrs = [P.FontDescr fnt, P.FontForeground fg] + attrs' = if bg == bgColor conf then attrs else P.FontBackground bg:attrs + in P.markSpan attrs' $ P.escapeMarkup txt segmentMarkup _ _ = "" withLayoutInfo :: P.PangoContext -> Double -> Config -> Segment -> IO LayoutInfo @@ -86,21 +87,21 @@ renderLayout surface maxoff (off, actions) (segment, lyt, lwidth, voff) = setSourceColor :: RGBS.Colour Double -> C.Render () setSourceColor = RGBS.uncurryRGB C.setSourceRGB . SRGB.toSRGB -background :: Config -> SRGB.Colour Double -> C.Render () -background conf colour = do - setSourceColor colour - C.paintWithAlpha $ (fromIntegral (alpha conf)) / 255.0 - readColourName :: String -> IO (RGBS.Colour Double) readColourName str = do case CNames.readColourName str of Just c -> return c Nothing -> return $ SRGB.sRGB24read str +background :: Config -> SRGB.Colour Double -> C.Render () +background conf colour = do + setSourceColor colour + C.paintWithAlpha $ (fromIntegral (alpha conf)) / 255.0 + renderBackground :: Config -> Surface -> IO () renderBackground conf surface = do - col <- readColourName (bgColor conf) - C.renderWith surface (background conf col) + when (alpha conf >= 255) + (readColourName (bgColor conf) >>= C.renderWith surface . background conf) drawRect :: String -> Double -> (Double, Double, Double, Double) -> C.Render() drawRect name wd (x0, y0, x1, y1) = do |