summaryrefslogtreecommitdiffstats
path: root/lib/Phi/Bindings
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-17 19:20:19 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-17 19:20:19 +0200
commit0fefcaa35f217ca2e1f15e2dd77742adfd231571 (patch)
tree046600165a46fbb5a75508a5fe5b9e738124ab7e /lib/Phi/Bindings
parentb66d6690d8a062053268b3246a2a55cbff46410d (diff)
downloadphi-0fefcaa35f217ca2e1f15e2dd77742adfd231571.tar
phi-0fefcaa35f217ca2e1f15e2dd77742adfd231571.zip
Some initial systray code
Diffstat (limited to 'lib/Phi/Bindings')
-rw-r--r--lib/Phi/Bindings/Util.hsc16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Phi/Bindings/Util.hsc b/lib/Phi/Bindings/Util.hsc
index 5058a8b..32737ff 100644
--- a/lib/Phi/Bindings/Util.hsc
+++ b/lib/Phi/Bindings/Util.hsc
@@ -1,10 +1,13 @@
{-# LANGUAGE ForeignFunctionInterface #-}
module Phi.Bindings.Util ( setClassHint
+ , visualIDFromVisual
+ , putClientMessage
, createXlibSurface
) where
+#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <cairo.h>
#include <cairo-xlib.h>
@@ -14,6 +17,7 @@ import Foreign.C.String (withCString)
import Foreign.C.Types
import Foreign.Ptr
import Foreign.Marshal.Alloc (alloca, allocaBytes)
+import Foreign.Marshal.Array
import Foreign.Storable
import Graphics.X11.Xlib
@@ -33,6 +37,17 @@ setClassHint disp wnd hint = allocaBytes (#size XClassHint) $ \p ->
(#poke XClassHint, res_class) p res_class
xSetClassHint disp wnd p
+foreign import ccall unsafe "X11/Xlib.h XVisualIDFromVisual"
+ visualIDFromVisual :: Visual -> VisualID
+
+putClientMessage :: XEventPtr -> Window -> Atom -> [CLong] -> IO ()
+putClientMessage event window message_type messageData = do
+ setEventType event clientMessage
+ (#poke XClientMessageEvent, window) event window
+ (#poke XClientMessageEvent, message_type) event message_type
+ (#poke XClientMessageEvent, format) event (32 :: CInt)
+ pokeArray ((#ptr XClientMessageEvent, data.l) event) $ take 5 messageData
+
foreign import ccall unsafe "cairo-xlib.h cairo_xlib_surface_create"
xlibSurfaceCreate :: Display -> Drawable -> Visual -> CInt -> CInt -> IO (Ptr Surface)
@@ -42,3 +57,4 @@ createXlibSurface dpy drawable visual width height = do
surface <- mkSurface surfacePtr
manageSurface surface
return surface
+