Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

seat: avoid copying the keymap for each client #3092

Merged
merged 3 commits into from
Sep 5, 2021

Conversation

emersion
Copy link
Member

@emersion emersion commented Aug 7, 2021

If a client supports wl_keyboard version 7, no need to allocate
and copy a new keymap file. We can use a read-only file instead.

@emersion
Copy link
Member Author

TBH, I wonder if we even need wl_seat v7 to do this. v7 only mentions MAP_SHARED, not PROT_READ.

@kennylevinsen
Copy link
Member

I don't see anything mentioned, so let's do it unconditionally. Worst case we discover a faulty protocol assumption. :)

This function behaves like allocate_shm_file, except it also
returns a read-only FD. This is useful to share the same segment
of memory with many Wayland clients.
This exposes a read-only FD with the keymap.
We can just send a read-only file descriptor instead.
@emersion
Copy link
Member Author

emersion commented Sep 4, 2021

Updated to always send a read-only FD. Tested with a few clients (GTK, Qt, foot, alacritty, etc), all seem to work fine.

Also opened https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/176 to make the spec clearer.

Copy link
Member

@kennylevinsen kennylevinsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants