summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/X11/CairoDraw.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-09 03:03:57 +0100
committerjao <jao@gnu.org>2022-09-09 03:03:57 +0100
commitf81a7cfef463907ba4b68cb1352a869960350685 (patch)
treedf12acba69a8a347420d77d0f0e5eb2a71e5f65b /src/Xmobar/X11/CairoDraw.hs
parentcf9c9d37707fb86e99f2402ccad33a1545706564 (diff)
downloadxmobar-f81a7cfef463907ba4b68cb1352a869960350685.tar.gz
xmobar-f81a7cfef463907ba4b68cb1352a869960350685.tar.bz2
cairo: drawing skeleton from an xlib cairo surface
Diffstat (limited to 'src/Xmobar/X11/CairoDraw.hs')
-rw-r--r--src/Xmobar/X11/CairoDraw.hs48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Xmobar/X11/CairoDraw.hs b/src/Xmobar/X11/CairoDraw.hs
new file mode 100644
index 0000000..424ea90
--- /dev/null
+++ b/src/Xmobar/X11/CairoDraw.hs
@@ -0,0 +1,48 @@
+------------------------------------------------------------------------------
+-- |
+-- Module: Xmobar.X11.CairoDraw
+-- Copyright: (c) 2022 Jose Antonio Ortega Ruiz
+-- License: BSD3-style (see LICENSE)
+--
+-- Maintainer: jao@gnu.org
+-- Stability: unstable
+-- Portability: unportable
+-- Created: Fri Sep 09, 2022 02:03
+--
+-- Drawing the xmobar contents using Cairo and Pango
+--
+--
+------------------------------------------------------------------------------
+
+module Xmobar.X11.CairoDraw (drawInPixmap) where
+
+import Control.Monad.IO.Class
+import Control.Monad.Reader
+
+import Graphics.X11.Xlib hiding (Segment)
+import GI.Cairo.Render.Types
+
+import Xmobar.Run.Parsers (Segment)
+import Xmobar.X11.Types
+import Xmobar.X11.CairoSurface
+-- import Xmobar.Text.Pango
+import Xmobar.Config.Types
+
+drawInPixmap :: Pixmap -> Dimension -> Dimension -> [[Segment]] -> X ()
+drawInPixmap p w h s = do
+ xconf <- ask
+ let disp = display xconf
+ scr = screenOfDisplay disp 0
+ c = config xconf
+ fi = fromIntegral
+ liftIO $ withBitmapSurface disp p scr (fi w) (fi h) (renderSegments c s)
+
+
+renderSegment :: String -> String -> Surface -> Segment -> IO ()
+renderSegment _fg _bg _surface _segment = undefined
+
+renderSegments :: Config -> [[Segment]] -> Surface -> IO ()
+renderSegments conf segments surface = do
+ let bg = bgColor conf
+ fg = fgColor conf
+ mapM_ (renderSegment fg bg surface) (concat segments)