summaryrefslogtreecommitdiffstats
path: root/lib/Phi/Bindings
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Phi/Bindings')
-rw-r--r--lib/Phi/Bindings/Util.hsc30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Phi/Bindings/Util.hsc b/lib/Phi/Bindings/Util.hsc
index 32737ff..bae6c71 100644
--- a/lib/Phi/Bindings/Util.hsc
+++ b/lib/Phi/Bindings/Util.hsc
@@ -3,6 +3,7 @@
module Phi.Bindings.Util ( setClassHint
, visualIDFromVisual
, putClientMessage
+ , Phi.Bindings.Util.getEvent
, createXlibSurface
) where
@@ -51,6 +52,35 @@ putClientMessage event window message_type messageData = do
foreign import ccall unsafe "cairo-xlib.h cairo_xlib_surface_create"
xlibSurfaceCreate :: Display -> Drawable -> Visual -> CInt -> CInt -> IO (Ptr Surface)
+getEvent :: Display -> XEventPtr -> IO Event
+getEvent display p = do
+ eventType <- get_EventType p
+ case True of
+ _ | eventType == clientMessage -> do
+ serial <- (#peek XClientMessageEvent, serial) p
+ send_event <- (#peek XClientMessageEvent, send_event) p
+ window <- (#peek XClientMessageEvent, window) p
+ message_type <- (#peek XClientMessageEvent, message_type) p
+ format <- (#peek XClientMessageEvent, format) p
+ let datPtr = (#ptr XClientMessageEvent, data) p
+ dat <- case (format::CInt) of
+ 8 -> do a <- peekArray 20 datPtr
+ return $ map fromIntegral (a::[CUChar])
+ 16 -> do a <- peekArray 10 datPtr
+ return $ map fromIntegral (a::[CUShort])
+ 32 -> do a <- peekArray 5 datPtr
+ return $ map fromIntegral (a::[CULong])
+ return $ ClientMessageEvent { ev_event_type = eventType
+ , ev_serial = serial
+ , ev_send_event = send_event
+ , ev_event_display = display
+ , ev_window = window
+ , ev_message_type = message_type
+ , ev_data = dat
+ }
+ | otherwise -> Graphics.X11.Xlib.Extras.getEvent p
+
+
createXlibSurface :: Display -> Drawable -> Visual -> CInt -> CInt -> IO Surface
createXlibSurface dpy drawable visual width height = do
surfacePtr <- xlibSurfaceCreate dpy drawable visual width height