From c00a62dda169beb472fc2f386d0f673ca100dfa4 Mon Sep 17 00:00:00 2001 From: akbash Date: Sun, 20 Sep 2026 17:10:16 +0300 Subject: fix: preserve delayed mouse reports with confirmed keyboard input (#4247) * fix: preserve delayed mouse reports with confirmed keyboard input refs #3480 * fix: capture geometry before replaying buffered mouse input refs #3480 --------- Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: JJ Liebig --- src/platform/unix_common.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/platform/unix_common.rs') diff --git a/src/platform/unix_common.rs b/src/platform/unix_common.rs index a937b863..6063edd9 100644 --- a/src/platform/unix_common.rs +++ b/src/platform/unix_common.rs @@ -8,6 +8,29 @@ pub(crate) fn classify_child_exit(status: &portable_pty::ExitStatus) -> super::C } } +pub(crate) fn read_fd(fd: std::os::fd::RawFd, data: &mut [u8]) -> std::io::Result { + let result = unsafe { libc::read(fd, data.as_mut_ptr().cast(), data.len()) }; + if result < 0 { + Err(std::io::Error::last_os_error()) + } else { + Ok(result as usize) + } +} + +pub(crate) fn poll_fd_readable(fd: std::os::fd::RawFd, timeout_ms: i32) -> std::io::Result { + let mut descriptor = libc::pollfd { + fd, + events: libc::POLLIN, + revents: 0, + }; + let result = unsafe { libc::poll(&mut descriptor, 1, timeout_ms) }; + if result < 0 { + Err(std::io::Error::last_os_error()) + } else { + Ok(result > 0) + } +} + pub(crate) fn shutdown_client_stream(stream: &crate::ipc::LocalStream) -> std::io::Result<()> { let crate::ipc::LocalStream::UdSocket(stream) = stream; stream.inner().shutdown(std::net::Shutdown::Both) -- cgit v1.2.3