wayland/keyboard: Use MetaAnonymousFile to share keymap files

Since protocol version 7 clients must use MAP_PRIVATE to map the keymap
fd, that means we can use memfd_create() to create the fd by using
meta_anonymous_file_open_fd() with META_ANONYMOUS_FILE_MAPMODE_PRIVATE,
for older versions we use META_ANONYMOUS_FILE_MAPMODE_SHARED to be
compatibile with MAP_SHARED.

Pretty much all of this code was written for Weston by Sebastian Wick,
see https://gitlab.freedesktop.org/wayland/weston/merge_requests/240.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1734

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1012
This commit is contained in:
Jonas Dreßler
2020-01-17 23:54:31 +01:00
parent 551a57ed7f
commit 988da215c8
2 changed files with 34 additions and 75 deletions

View File

@ -49,6 +49,7 @@
#include <xkbcommon/xkbcommon.h>
#include "clutter/clutter.h"
#include "core/meta-anonymous-file.h"
#include "wayland/meta-wayland-types.h"
#define META_TYPE_WAYLAND_KEYBOARD (meta_wayland_keyboard_get_type ())
@ -74,8 +75,7 @@ typedef struct
{
struct xkb_keymap *keymap;
struct xkb_state *state;
size_t keymap_size;
char *keymap_string;
MetaAnonymousFile *keymap_rofile;
} MetaWaylandXkbInfo;
struct _MetaWaylandKeyboard