diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-08-13 01:12:50 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-08-13 01:14:56 +0100 |
commit | 2d0eee125442524f2df009ebd6d4df166a74d6f9 (patch) | |
tree | c27a7eb3153da94340ed75f94130a3e1bf1bda36 /src/wl_window.c | |
parent | 07b742e9da2a12d163d7733aaefc5ae6bce555b6 (diff) | |
download | imv-2d0eee125442524f2df009ebd6d4df166a74d6f9.tar.gz |
Wayland: Detect keyboard layout automatically
Diffstat (limited to 'src/wl_window.c')
-rw-r--r-- | src/wl_window.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/wl_window.c b/src/wl_window.c index a6b16ae..635fd4f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -9,6 +9,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/mman.h> #include <wayland-client.h> #include <wayland-egl.h> @@ -42,6 +43,8 @@ struct imv_window { bool fullscreen; int scale; + char *keymap; + struct { struct { double last; @@ -92,11 +95,17 @@ static const struct xdg_wm_base_listener shell_listener_xdg = { static void keyboard_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int32_t fd, uint32_t size) { - (void)data; (void)keyboard; (void)format; - (void)fd; - (void)size; + struct imv_window *window = data; + if (window->keymap) { + free(window->keymap); + } + window->keymap = malloc(size); + char *src = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); + memcpy(window->keymap, src, size); + munmap(src, size); + close(fd); } static void keyboard_enter(void *data, struct wl_keyboard *keyboard, @@ -785,3 +794,8 @@ void imv_window_pump_events(struct imv_window *window, imv_event_handler handler } } } + +const char *imv_window_keymap(struct imv_window *window) +{ + return window->keymap; +} |