summaryrefslogtreecommitdiffstats
path: root/lib/Phi/Bindings
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-19 11:16:50 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-19 11:16:50 +0200
commit19c4bb35212b422ce0c3d8808357e0edf8728218 (patch)
tree4c6d596f730f176f802402cd9787ad661ec1f36f /lib/Phi/Bindings
parent581e1f9c63101fd2a00711748415997b0c20b793 (diff)
downloadphi-19c4bb35212b422ce0c3d8808357e0edf8728218.tar
phi-19c4bb35212b422ce0c3d8808357e0edf8728218.zip
Basic systray implementation
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