mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-20 09:10:04 +01:00
ei-demo-client: use xkb_keymap_new_from_buffer()
This is the more correct approach since we get a sized buffer from the server and people may use this as reference code in their implementation. Technically we cannot expect a true zero-terminated string from EIS. Unfortunately this means we need to work around libxkbcommon#307 to strip trailing zeroes from the buffer if any exist.
This commit is contained in:
parent
a924888f0f
commit
3e2e43e352
1 changed files with 8 additions and 1 deletions
|
|
@ -104,7 +104,14 @@ setup_xkb_keymap(struct ei_keymap *keymap)
|
|||
return;
|
||||
}
|
||||
|
||||
_unref_(xkb_keymap) *xkbmap = xkb_keymap_new_from_string(ctx, memmap_get_data(memmap),
|
||||
/* workaround for libxkbcommon#307 (fixed in libxkbcommon 1.6.0) - strip the trailing null byte */
|
||||
size_t sz = memmap_get_size(memmap);
|
||||
char *data = memmap_get_data(memmap);
|
||||
while (sz > 0 && data[sz - 1] == '\0')
|
||||
--sz;
|
||||
|
||||
_unref_(xkb_keymap) *xkbmap = xkb_keymap_new_from_buffer(ctx, memmap_get_data(memmap),
|
||||
memmap_get_size(memmap),
|
||||
XKB_KEYMAP_FORMAT_TEXT_V1,
|
||||
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
if (!xkbmap)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue