summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/X11/CairoDraw.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-19 01:36:14 +0100
committerjao <jao@gnu.org>2022-09-19 01:36:14 +0100
commit44e407836e1437bd1f78edc4980eeb9fe42399b6 (patch)
tree27b3338391ac1f3164c6998d10c7c577be91813f /src/Xmobar/X11/CairoDraw.hs
parente8a8591201ce5d103e026b65430862e24b3b73be (diff)
downloadxmobar-44e407836e1437bd1f78edc4980eeb9fe42399b6.tar.gz
xmobar-44e407836e1437bd1f78edc4980eeb9fe42399b6.tar.bz2
cairo: non-cairo is not an option
Diffstat (limited to 'src/Xmobar/X11/CairoDraw.hs')
-rw-r--r--src/Xmobar/X11/CairoDraw.hs47
1 files changed, 3 insertions, 44 deletions
diff --git a/src/Xmobar/X11/CairoDraw.hs b/src/Xmobar/X11/CairoDraw.hs
index d66f959..a4172bb 100644
--- a/src/Xmobar/X11/CairoDraw.hs
+++ b/src/Xmobar/X11/CairoDraw.hs
@@ -15,18 +15,13 @@
--
------------------------------------------------------------------------------
-module Xmobar.X11.CairoDraw (drawInPixmap) where
-
-import qualified Data.Map as M
+module Xmobar.X11.CairoDraw (drawSegments, DrawContext (..), BitmapDrawer) where
import qualified Data.Colour.SRGB as SRGB
import qualified Data.Colour.Names as CNames
-import Control.Monad.IO.Class (liftIO)
import Control.Monad (foldM, when)
-import Control.Monad.Reader (ask)
-import qualified Graphics.X11.Xlib as X11
import qualified Graphics.Rendering.Cairo as Cairo
import qualified Graphics.Rendering.Pango as Pango
@@ -40,11 +35,6 @@ import qualified Xmobar.Text.Pango as TextPango
import qualified Xmobar.X11.Boxes as Boxes
import qualified Xmobar.X11.Bitmap as B
import qualified Xmobar.X11.Types as X
-import Xmobar.X11.CairoSurface (withXlibSurface)
-
-#ifdef XRENDER
-import qualified Xmobar.X11.XRender as XRender
-#endif
type Renderinfo = (P.Segment, Surface -> Double -> Double -> IO (), Double)
type BitmapDrawer = Double -> Double -> String -> IO ()
@@ -58,37 +48,6 @@ data DrawContext = DC { dcBitmapDrawer :: BitmapDrawer
, dcSegments :: [[P.Segment]]
}
-drawInPixmap :: X11.GC -> X11.Pixmap -> [[P.Segment]] -> X.X Actions
-drawInPixmap gc p s = do
- xconf <- ask
- let disp = X.display xconf
- vis = X11.defaultVisualOfScreen (X11.defaultScreenOfDisplay disp)
- (X11.Rectangle _ _ w h) = X.rect xconf
- dw = fromIntegral w
- dh = fromIntegral h
- conf = X.config xconf
- dc = DC (drawXBitmap xconf gc p) (lookupXBitmap xconf) conf dw dh s
- render = drawSegments dc
-#ifdef XRENDER
- color = C.bgColor conf
- alph = C.alpha conf
- liftIO $ XRender.drawBackground disp p color alph (X11.Rectangle 0 0 w h)
-#endif
- liftIO $ withXlibSurface disp p vis (fromIntegral w) (fromIntegral h) render
-
-drawXBitmap :: X.XConf -> X11.GC -> X11.Pixmap -> BitmapDrawer
-drawXBitmap xconf gc p h v path = do
- let disp = X.display xconf
- conf = X.config xconf
- fc = C.fgColor conf
- bc = C.bgColor conf
- case lookupXBitmap xconf path of
- Just bm -> liftIO $ B.drawBitmap disp p gc fc bc (round h) (round v) bm
- Nothing -> return ()
-
-lookupXBitmap :: X.XConf -> String -> Maybe B.Bitmap
-lookupXBitmap xconf path = M.lookup path (X.iconCache xconf)
-
readColourName :: String -> (SRGB.Colour Double, Double)
readColourName str =
case CNames.readColourName str of
@@ -148,8 +107,8 @@ withRenderinfo _ dctx seg@(P.Icon p, _, _, _) = do
wd = maybe 0 (fromIntegral . B.width) bm
ioff = C.iconOffset (dcConfig dctx)
vpos = dcHeight dctx / 2 + fromIntegral ioff
- draw _ off mx = when (off + wd <= mx) $ dcBitmapDrawer dctx off vpos p
- return (seg, draw, wd)
+ render _ off mx = when (off + wd <= mx) $ dcBitmapDrawer dctx off vpos p
+ return (seg, render, wd)
drawBox :: DrawContext -> Surface -> Double -> Double -> P.Box -> IO ()
drawBox dctx surf x0 x1 box@(P.Box _ _ w color _) =