Use xkb_keymap_new_from_buffer instead of xkb_keymap_new_from_string
xkb_keymap_new_from_string just calls xkb_keymap_new_from_buffer with size as `strlen(string)`.
0f1cae0cc4/src/keymap.c (L164)
According to the [spec](https://gitlab.freedesktop.org/wayland/wayland/-/blob/master/protocol/wayland.xml#L2182), MAP_PRIVATE should be used.
This commit is contained in:
parent
73754703c5
commit
a6b3a0956b
8
seat.c
8
seat.c
@ -15,16 +15,16 @@ static void keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
|||||||
swaylock_log(LOG_ERROR, "Unknown keymap format %d, aborting", format);
|
swaylock_log(LOG_ERROR, "Unknown keymap format %d, aborting", format);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
char *map_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
char *map_shm = mmap(NULL, size - 1, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
if (map_shm == MAP_FAILED) {
|
if (map_shm == MAP_FAILED) {
|
||||||
close(fd);
|
close(fd);
|
||||||
swaylock_log(LOG_ERROR, "Unable to initialize keymap shm, aborting");
|
swaylock_log(LOG_ERROR, "Unable to initialize keymap shm, aborting");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
struct xkb_keymap *keymap = xkb_keymap_new_from_string(
|
struct xkb_keymap *keymap = xkb_keymap_new_from_buffer(
|
||||||
state->xkb.context, map_shm, XKB_KEYMAP_FORMAT_TEXT_V1,
|
state->xkb.context, map_shm, size - 1, XKB_KEYMAP_FORMAT_TEXT_V1,
|
||||||
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
munmap(map_shm, size);
|
munmap(map_shm, size - 1);
|
||||||
close(fd);
|
close(fd);
|
||||||
assert(keymap);
|
assert(keymap);
|
||||||
struct xkb_state *xkb_state = xkb_state_new(keymap);
|
struct xkb_state *xkb_state = xkb_state_new(keymap);
|
||||||
|
Loading…
Reference in New Issue
Block a user