diff options
Diffstat (limited to 'src/Wetterhorn/FFI.hs')
-rw-r--r-- | src/Wetterhorn/FFI.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Wetterhorn/FFI.hs b/src/Wetterhorn/FFI.hs index bfb3cbd..d941493 100644 --- a/src/Wetterhorn/FFI.hs +++ b/src/Wetterhorn/FFI.hs @@ -18,6 +18,13 @@ import Foreign import Foreign.C (CChar) import Wetterhorn.Core +runForeign :: (WConfig -> W ()) -> Wetterhorn -> IO Wetterhorn +runForeign fn stblptr = do + (conf, st) <- deRefStablePtr stblptr + freeStablePtr stblptr + (_, state') <- runW (fn conf) (conf, st) + newStablePtr (conf, state') + -- | This function should be defined somewhere in the code. This is kind of like -- the "main" function in XMonad. foreign import ccall wetterhorn :: IO Wetterhorn @@ -59,3 +66,10 @@ pluginMarshalState stblptr outlen = do forM_ (zip [0 ..] (BS.unpack bs)) $ \(off, w8) -> do pokeByteOff ret off w8 return ret + +foreign export ccall "plugin_handle_keybinding" + pluginHandleKeybinding :: + Word32 -> Wetterhorn -> IO Wetterhorn + +pluginHandleKeybinding :: Word32 -> Wetterhorn -> IO Wetterhorn +pluginHandleKeybinding sym = runForeign (`keybindingHandler` sym) |