From 45f2305f618d7411ed4c168c86228b68c2bfe539 Mon Sep 17 00:00:00 2001 From: En-En <39373446+En-En-Code@users.noreply.github.com> Date: Fri, 7 Nov 2025 01:40:08 +0000 Subject: [PATCH] refactor: change `select` to `poll` in `write_pipe` Not sure why I could not get `poll` to work in the first place. --- src/xstate/selection.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/xstate/selection.rs b/src/xstate/selection.rs index f021294..2309828 100644 --- a/src/xstate/selection.rs +++ b/src/xstate/selection.rs @@ -2,8 +2,7 @@ use super::{get_atom_name, XState}; use crate::server::selection::{Clipboard, ForeignSelection, Primary, SelectionType}; use crate::{RealServerState, X11Selection}; use log::{debug, error, warn}; -use rustix::event::{fd_set_insert, select}; -use rustix::fd::AsRawFd; +use rustix::event::{poll, PollFd, PollFlags}; use smithay_client_toolkit::data_device_manager::WritePipe; use std::cell::RefCell; use std::collections::VecDeque; @@ -175,14 +174,8 @@ impl Selection { Ok(n) => buf = &buf[n..], Err(ref e) if e.kind() == ErrorKind::Interrupted => {} Err(ref e) if e.kind() == ErrorKind::WouldBlock => { - let mut writefds = [Default::default()]; - fd_set_insert(&mut writefds, pipe.as_raw_fd()); - // SAFETY: nfds is correctly set to the numerically largest raw file - // desciprtor being selected on plus 1, and all one fd is open for the - // duration of the call. - unsafe { - select(pipe.as_raw_fd() + 1, None, Some(&mut writefds), None, None)?; - } + let mut pollfds = [PollFd::new(pipe, PollFlags::OUT)]; + poll(&mut pollfds, None)?; } Err(e) => return Err(e), }