1
0
Fork 0
forked from wry/wry

autocommit 2022-02-14 21:13:42 CET

This commit is contained in:
Julian Orth 2022-02-14 21:13:42 +01:00
parent 9b8e1ac29f
commit da6b29f138
44 changed files with 5903 additions and 364 deletions

View file

@ -8,7 +8,7 @@ use crate::wire::wl_keyboard::*;
use crate::wire::{WlKeyboardId, WlSurfaceId};
use std::rc::Rc;
use thiserror::Error;
use uapi::{c, Errno, OwnedFd};
use uapi::{OwnedFd};
pub const REPEAT_INFO_SINCE: u32 = 4;
@ -34,36 +34,6 @@ impl WlKeyboard {
}
}
pub fn needs_dedicated_keymap_fd(&self) -> bool {
self.seat.version < 7
}
pub fn keymap_fd(&self) -> Result<Rc<OwnedFd>, WlKeyboardError> {
if !self.needs_dedicated_keymap_fd() {
return Ok(self.seat.global.layout.clone());
}
let fd = match uapi::memfd_create("shared-keymap", c::MFD_CLOEXEC) {
Ok(fd) => fd,
Err(e) => return Err(WlKeyboardError::KeymapMemfd(e.into())),
};
let target = self.seat.global.layout_size as c::off_t;
let mut pos = 0;
while pos < target {
let rem = target - pos;
let res = uapi::sendfile(
fd.raw(),
self.seat.global.layout.raw(),
Some(&mut pos),
rem as usize,
);
match res {
Ok(_) | Err(Errno(c::EINTR)) => {}
Err(e) => return Err(WlKeyboardError::KeymapCopy(e.into())),
}
}
Ok(Rc::new(fd))
}
pub fn send_keymap(self: &Rc<Self>, format: u32, fd: Rc<OwnedFd>, size: u32) {
self.seat.client.event(Keymap {
self_id: self.id,