diff options
-rw-r--r-- | harness/CMakeLists.txt | 3 | ||||
-rw-r--r-- | harness/include/plugin.h | 2 | ||||
-rw-r--r-- | harness/src/plugin.c | 2 | ||||
-rw-r--r-- | harness/src/wl.c | 9 | ||||
-rw-r--r-- | src/Wetterhorn/Core.hs | 3 | ||||
-rw-r--r-- | src/Wetterhorn/FFI.hs | 5 |
6 files changed, 18 insertions, 6 deletions
diff --git a/harness/CMakeLists.txt b/harness/CMakeLists.txt index 80312eb..0b91cd3 100644 --- a/harness/CMakeLists.txt +++ b/harness/CMakeLists.txt @@ -76,4 +76,5 @@ add_executable (wtr_harness ${SOURCES} ${PLUGIN_LOAD} ${PLUGIN_INTF} target_link_libraries(wtr_harness dl) target_link_directories(wtr_harness PUBLIC "../wlroots/build/") -target_link_libraries(wtr_harness wlroots wayland-server xkbcommon) +target_link_libraries(wtr_harness wlroots wayland-server xkbcommon pthread) +target_link_options(wtr_harness PRIVATE -Wl,--wrap=pthread_create) diff --git a/harness/include/plugin.h b/harness/include/plugin.h index 37e36ba..feac626 100644 --- a/harness/include/plugin.h +++ b/harness/include/plugin.h @@ -136,7 +136,7 @@ typedef struct PLUGIN { */ EXPORT(opqst_t (*plugin_handle_keybinding)( struct wlr_event_keyboard_key *event, uint32_t modifiers, uint32_t keysym, - int *out_handled, opqst_t state)); + uint32_t codepoint, int *out_handled, opqst_t state)); /* * Handles a surface being mapped, unmapped or destroyed. diff --git a/harness/src/plugin.c b/harness/src/plugin.c index b46cb5f..3c18d03 100644 --- a/harness/src/plugin.c +++ b/harness/src/plugin.c @@ -1,6 +1,8 @@ #include "plugin.h" #include "foreign_intf.h" +#include <sys/stat.h> +#include <unistd.h> #include <ctype.h> #include <dlfcn.h> #include <pthread.h> diff --git a/harness/src/wl.c b/harness/src/wl.c index 3f00e06..cdc3447 100644 --- a/harness/src/wl.c +++ b/harness/src/wl.c @@ -186,12 +186,17 @@ static void keyboard_handle_key(struct wl_listener *listener, void *data) int nsyms = xkb_state_key_get_syms(keyboard->device->keyboard->xkb_state, keycode, &syms); uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard); + uint32_t codepoint; /* Pass the information along to the plugin for the plugin to handle. The * plugin will return via 'handled' whether or not the key event was handled * or not. */ int handled = 0; - plugin_call_update_state(server->plugin, plugin_handle_keybinding, event, - modifiers, syms[0], &handled); + if (nsyms > 0) { + codepoint = + xkb_state_key_get_utf32(keyboard->device->keyboard->xkb_state, keycode); + plugin_call_update_state(server->plugin, plugin_handle_keybinding, event, + modifiers, syms[0], codepoint, &handled); + } if (!handled) { /* Otherwise, we pass it along to the client. */ diff --git a/src/Wetterhorn/Core.hs b/src/Wetterhorn/Core.hs index 16978bb..36b0f82 100644 --- a/src/Wetterhorn/Core.hs +++ b/src/Wetterhorn/Core.hs @@ -78,7 +78,8 @@ data KeyEvent = KeyEvent keycode :: Word32, state :: KeyState, modifiers :: Word32, - keysym :: Word32 + keysym :: Word32, + codepoint :: Char } deriving (Show, Read, Ord, Eq) diff --git a/src/Wetterhorn/FFI.hs b/src/Wetterhorn/FFI.hs index 969f86f..58c1aff 100644 --- a/src/Wetterhorn/FFI.hs +++ b/src/Wetterhorn/FFI.hs @@ -88,6 +88,7 @@ foreign export ccall "plugin_handle_keybinding" Ptr () -> Word32 -> Word32 -> + Word32 -> Ptr CInt -> Wetterhorn -> IO Wetterhorn @@ -96,10 +97,11 @@ pluginHandleKeybinding :: Ptr () -> Word32 -> Word32 -> + Word32 -> Ptr CInt -> Wetterhorn -> IO Wetterhorn -pluginHandleKeybinding eventPtr mods sym = +pluginHandleKeybinding eventPtr mods sym cp = runForeignWithReturn $ \config -> do event <- wio $ runForeignDemarshal eventPtr $ do @@ -114,6 +116,7 @@ pluginHandleKeybinding eventPtr mods sym = (if keyState == (0 :: Word8) then KeyReleased else KeyPressed) mods sym + (toEnum $ fromIntegral cp) (\b -> if b then 1 else 0) <$> keybindingHandler config event foreign export ccall "plugin_handle_surface_map" |