Skip to content

Commit

Permalink
Merge pull request #835 from Apprentice-Alchemist/patch-2
Browse files Browse the repository at this point in the history
If MAP_SHARED fails for the keymap fd try MAP_PRIVATE.
  • Loading branch information
RobDangerous authored Dec 18, 2023
2 parents 38416f1 + 8752796 commit 158cf1a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Backends/System/Linux/Sources/kinc/backend/wayland/system.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 158cf1a

Please sign in to comment.