From 8752796744b6d67304641971be89b08f9111a4c4 Mon Sep 17 00:00:00 2001 From: Zeta <53486764+Apprentice-Alchemist@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:15:54 +0100 Subject: [PATCH] If MAP_SHARED fails for the keymap fd try MAP_PRIVATE. --- .../Linux/Sources/kinc/backend/wayland/system.c.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Backends/System/Linux/Sources/kinc/backend/wayland/system.c.h b/Backends/System/Linux/Sources/kinc/backend/wayland/system.c.h index 4e3762ee7..3a36178f3 100644 --- a/Backends/System/Linux/Sources/kinc/backend/wayland/system.c.h +++ b/Backends/System/Linux/Sources/kinc/backend/wayland/system.c.h @@ -432,8 +432,12 @@ void wl_keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard, uint case WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1: { char *mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); if (mapStr == MAP_FAILED) { - close(fd); - return; + mapStr = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); + if (mapStr == MAP_FAILED) { + kinc_log(KINC_LOG_LEVEL_ERROR, "Failed to map wayland keymap."); + close(fd); + return; + } } keyboard->keymap = wl_xkb.xkb_keymap_new_from_string(wl_ctx.xkb_context, mapStr, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); munmap(mapStr, size); @@ -1320,4 +1324,4 @@ void kinc_wl_mouse_set_position(int window_index, int x, int y) { void kinc_wl_mouse_get_position(int window_index, int *x, int *y) { *x = wl_ctx.seat.mouse.x; *y = wl_ctx.seat.mouse.y; -} \ No newline at end of file +}