From 3e385d5c4868b4f7d65ac1f86659c607a7a919cc Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 15 May 2024 16:49:46 +0400 Subject: Clear fd flags before sending selection --- src/handlers/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 080dd161..9f0812d1 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -15,6 +15,7 @@ use smithay::desktop::{PopupKind, PopupManager}; use smithay::input::pointer::{CursorIcon, CursorImageStatus, PointerHandle}; use smithay::input::{keyboard, Seat, SeatHandler, SeatState}; use smithay::output::Output; +use smithay::reexports::rustix::fs::{fcntl_setfl, OFlags}; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource; use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; @@ -188,6 +189,10 @@ impl SelectionHandler for State { let buf = user_data.clone(); thread::spawn(move || { + // Clear O_NONBLOCK, otherwise io::copy() will stop halfway. + if let Err(err) = fcntl_setfl(&fd, OFlags::empty()) { + warn!("error clearing flags on selection target fd: {err:?}"); + } if let Err(err) = File::from(fd).write_all(&buf) { warn!("error writing selection: {err:?}"); } -- cgit