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 authored and Wez Furlong committed 2021-09-19 15:59:29 -07:00
1 parent b16f584866
commit b94e78c8ec
1 file changed
+2 -3
+2 -3
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() {