1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00

window: read the xdg keymap fd from 0 on Wayland (fixes #1144)

The wl_keyboard definition does not define that the incoming fd is always at seek position 0.
In fact, the spec says the fd "can be memory-mapped" and that's it.
And e.g. smithay client-toolkit uses mmap, but we don't :/

Use pread() to read from zero.
This commit is contained in:
Greg V 2021-09-19 23:08:37 +03:00 committed by Wez Furlong
parent b16f584866
commit b94e78c8ec

View File

@ -11,8 +11,7 @@ use mio::{Evented, Events, Poll, PollOpt, Ready, Token};
use smithay_client_toolkit as toolkit;
use std::cell::RefCell;
use std::collections::HashMap;
use std::io::Read;
use std::os::unix::io::FromRawFd;
use std::os::unix::{fs::FileExt, io::FromRawFd};
use std::rc::Rc;
use std::sync::atomic::AtomicUsize;
use toolkit::environment::Environment;
@ -169,7 +168,7 @@ impl WaylandConnection {
match format {
KeymapFormat::XkbV1 => {
let mut data = vec![0u8; *size as usize];
file.read_exact(&mut data)?;
file.read_exact_at(&mut data, 0)?;
// Dance around CString panicing on the NUL terminator
// in the xkbcommon crate
while let Some(0) = data.last() {