Skip to content

Commit

Permalink
Merge pull request #596 from JakeStanger/build/nix
Browse files Browse the repository at this point in the history
refactor: update `nix` crate to latest version
  • Loading branch information
JakeStanger authored May 18, 2024
2 parents f7f991b + c876904 commit 3b6480f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
24 changes: 21 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ mlua = { version = "0.9.7", optional = true, features = ["luajit"] }
cairo-rs = { version = "0.18.5", optional = true, features = ["png"] }

# clipboard
nix = { version = "0.27.1", optional = true, features = ["event"] }
nix = { version = "0.28.0", optional = true, features = ["event", "fs"] }

# clock
chrono = { version = "0.4.38", optional = true, default_features = false, features = ["clock", "unstable-locales"] }
Expand Down
7 changes: 4 additions & 3 deletions src/clients/wayland/wlr_data_control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{lock, try_send, Ironbar};
use device::DataControlDevice;
use glib::Bytes;
use nix::fcntl::{fcntl, F_GETPIPE_SZ, F_SETPIPE_SZ};
use nix::sys::epoll::{Epoll, EpollCreateFlags, EpollEvent, EpollFlags};
use nix::sys::epoll::{Epoll, EpollCreateFlags, EpollEvent, EpollFlags, EpollTimeout};
use smithay_client_toolkit::data_device_manager::WritePipe;
use smithay_client_toolkit::reexports::calloop::{PostAction, RegistrationToken};
use std::cmp::min;
Expand Down Expand Up @@ -274,7 +274,7 @@ impl DataControlDeviceHandler for Environment {
Ok(token) => {
cur_offer.token.replace(token);
}
Err(err) => error!("{err:?}"),
Err(err) => error!("Failed to insert read pipe event: {err:?}"),
}
}
}
Expand Down Expand Up @@ -349,11 +349,12 @@ impl DataControlSourceHandler for Environment {
.add(fd, epoll_event)
.expect("to send valid epoll operation");

let timeout = EpollTimeout::from(100u16);
while !bytes.is_empty() {
let chunk = &bytes[..min(pipe_size as usize, bytes.len())];

epoll_fd
.wait(&mut events, 100)
.wait(&mut events, timeout)
.expect("Failed to wait to epoll");

match file.write(chunk) {
Expand Down
8 changes: 4 additions & 4 deletions src/clients/wayland/wlr_data_control/offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use nix::unistd::{close, pipe2};
use smithay_client_toolkit::data_device_manager::data_offer::DataOfferError;
use smithay_client_toolkit::data_device_manager::ReadPipe;
use std::ops::DerefMut;
use std::os::fd::{BorrowedFd, FromRawFd};
use std::os::fd::{AsFd, AsRawFd};
use std::sync::{Arc, Mutex};
use tracing::{trace, warn};
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle};
Expand Down Expand Up @@ -176,11 +176,11 @@ pub unsafe fn receive(
// create a pipe
let (readfd, writefd) = pipe2(OFlag::O_CLOEXEC)?;

offer.receive(mime_type, BorrowedFd::borrow_raw(writefd));
offer.receive(mime_type, writefd.as_fd());

if let Err(err) = close(writefd) {
if let Err(err) = close(writefd.as_raw_fd()) {
warn!("Failed to close write pipe: {}", err);
}

Ok(FromRawFd::from_raw_fd(readfd))
Ok(ReadPipe::from(readfd))
}

0 comments on commit 3b6480f

Please sign in to comment.