From b94e78c8ec5cf0442833ee0cf46230f95e03f5ca Mon Sep 17 00:00:00 2001 From: Greg V Date: Sun, 19 Sep 2021 23:08:37 +0300 Subject: [PATCH] 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. --- window/src/os/wayland/connection.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/window/src/os/wayland/connection.rs b/window/src/os/wayland/connection.rs index 6b93bde03..3d50ea87e 100644 --- a/window/src/os/wayland/connection.rs +++ b/window/src/os/wayland/connection.rs @@ -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() {