summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/X11/CairoSurface.hsc
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-11 22:34:27 +0100
committerjao <jao@gnu.org>2022-09-11 22:34:46 +0100
commit7e72fe0bc695b1d69ea58d2f28c014aaae6ee613 (patch)
tree435022558904c8698c246fb67a464fda4c1dd41e /src/Xmobar/X11/CairoSurface.hsc
parent7b6542e6b13d5457509a3bf79e3ad3ad9a42e48e (diff)
downloadxmobar-7e72fe0bc695b1d69ea58d2f28c014aaae6ee613.tar.gz
xmobar-7e72fe0bc695b1d69ea58d2f28c014aaae6ee613.tar.bz2
cairo: a couple of as yet unused imported foreign functions
Diffstat (limited to 'src/Xmobar/X11/CairoSurface.hsc')
-rw-r--r--src/Xmobar/X11/CairoSurface.hsc20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/Xmobar/X11/CairoSurface.hsc b/src/Xmobar/X11/CairoSurface.hsc
index 2037abe..6dad490 100644
--- a/src/Xmobar/X11/CairoSurface.hsc
+++ b/src/Xmobar/X11/CairoSurface.hsc
@@ -16,10 +16,13 @@
--
------------------------------------------------------------------------------
-module Xmobar.X11.CairoSurface (withXlibSurface, withBitmapSurface) where
+module Xmobar.X11.CairoSurface (withXlibSurface
+ , withBitmapSurface
+ , setSurfaceDrawable) where
import Graphics.X11.Xlib.Types
import Graphics.X11.Types
+import Graphics.X11.Xlib (defaultScreenOfDisplay)
import Graphics.Rendering.Cairo.Types
import qualified Graphics.Rendering.Cairo.Internal as Internal
@@ -34,6 +37,9 @@ foreign import ccall "cairo_xlib_surface_create"
foreign import ccall "cairo_xlib_surface_create_for_bitmap"
cBitmapCreate :: Display -> Pixmap -> Screen -> CInt -> CInt -> Ptr Surface
+foreign import ccall "cairo_xlib_surface_set_drawable"
+ cSetDrawable :: Ptr Surface -> Drawable -> CInt -> CInt -> ()
+
createXlibSurface :: Display -> Drawable -> Visual -> Int -> Int -> IO Surface
createXlibSurface d dr v w h =
mkSurface $ cSurfaceCreate d dr v (fromIntegral w) (fromIntegral h)
@@ -50,10 +56,14 @@ createBitmapSurface :: Display -> Pixmap -> Screen -> Int -> Int -> IO Surface
createBitmapSurface d p s w h =
mkSurface $ cBitmapCreate d p s (fromIntegral w) (fromIntegral h)
-withBitmapSurface ::
- Display -> Pixmap -> Screen -> Int -> Int -> (Surface -> IO a) -> IO a
-withBitmapSurface d p s w h f = do
- surface <- createBitmapSurface d p s w h
+withBitmapSurface :: Display -> Pixmap -> Int -> Int -> (Surface -> IO a) -> IO a
+withBitmapSurface d p w h f = do
+ surface <- createBitmapSurface d p (defaultScreenOfDisplay d) w h
ret <- f surface
Internal.surfaceDestroy surface
return ret
+
+setSurfaceDrawable :: Surface -> Drawable -> Int -> Int -> IO ()
+setSurfaceDrawable surface dr w h =
+ withSurface surface $
+ \s -> return $ cSetDrawable s dr (fromIntegral w) (fromIntegral h)