diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2024-08-04 17:31:56 +0200 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2024-08-04 17:31:56 +0200 |
| commit | 0e1add6fae63eb51c5f73caf4dd42838ec955a86 (patch) | |
| tree | b8227332daef96f5e5562db35ab8e368e6f347a3 /wayland/Wayland/Server/System.hsc | |
| parent | f677b43111622459853e3906c6cc028d94313e69 (diff) | |
implement signal handling
Diffstat (limited to 'wayland/Wayland/Server/System.hsc')
| -rw-r--r-- | wayland/Wayland/Server/System.hsc | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/wayland/Wayland/Server/System.hsc b/wayland/Wayland/Server/System.hsc index d86f59a..60940ce 100644 --- a/wayland/Wayland/Server/System.hsc +++ b/wayland/Wayland/Server/System.hsc @@ -1,20 +1,11 @@ {-# LANGUAGE ForeignFunctionInterface #-} -module Wayland.Server.System - ( WLMessage(..) - , WLInterface(..) - , WLDisplay(WLDisplay) - , wlDisplayCreate - , wlDisplayDestroy - , wlDisplayAddSocketAuto - , wlDisplayRun - , wlDisplayTerminate - ) where +module Wayland.Server.System where #include <wayland-server.h> -import Foreign (Ptr, Storable(..)) -import Foreign.C (CString, CInt) +import Foreign (FunPtr, Ptr, Storable(..)) +import Foreign.C (CString, CInt(..)) data WLMessage = WLMessage { msgName :: CString @@ -31,7 +22,14 @@ data WLInterface , ifEvents :: Ptr WLMessage } -newtype WLDisplay = WLDisplay (Ptr WLDisplay) +newtype WLDisplay = WLDisplay (Ptr WLDisplay) +newtype WLEventLoop = WLEventLoop (Ptr WLEventLoop) +newtype WLEventSource = WLEventSource (Ptr WLEventSource) + +type WLEventLoopSignalFunc = CInt -> Ptr () -> IO CInt + +foreign import ccall "wrapper" + wrapWLEventLoopSignalFunc :: WLEventLoopSignalFunc -> IO (FunPtr WLEventLoopSignalFunc) foreign import ccall "wl_display_create" wlDisplayCreate :: IO WLDisplay @@ -48,6 +46,12 @@ foreign import ccall "wl_display_run" foreign import ccall "wl_display_terminate" wlDisplayTerminate :: WLDisplay -> IO () +foreign import ccall "wl_display_get_event_loop" + wlDisplayGetEventLoop :: WLDisplay -> IO WLEventLoop + +foreign import ccall "wl_event_loop_add_signal" + wlEventLoopAddSignal :: WLEventLoop -> CInt -> FunPtr WLEventLoopSignalFunc -> Ptr () -> IO WLEventSource + instance Storable WLMessage where sizeOf _ = #{size struct wl_message} alignment _ = #{alignment struct wl_message} |
