1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-02 03:01:04 +02:00

refactor(wlr data control): update to new nix epoll bindings

This commit is contained in:
Jake Stanger 2023-09-05 22:43:29 +01:00
parent 60bb69feec
commit 4e67b73a83
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61

View file

@ -12,7 +12,7 @@ use crate::{lock, send};
use device::DataControlDevice; use device::DataControlDevice;
use glib::Bytes; use glib::Bytes;
use nix::fcntl::{fcntl, F_GETPIPE_SZ, F_SETPIPE_SZ}; use nix::fcntl::{fcntl, F_GETPIPE_SZ, F_SETPIPE_SZ};
use nix::sys::epoll::{epoll_create, epoll_ctl, epoll_wait, EpollEvent, EpollFlags, EpollOp}; use nix::sys::epoll::{Epoll, EpollCreateFlags, EpollEvent, EpollFlags};
use smithay_client_toolkit::data_device_manager::WritePipe; use smithay_client_toolkit::data_device_manager::WritePipe;
use smithay_client_toolkit::reexports::calloop::RegistrationToken; use smithay_client_toolkit::reexports::calloop::RegistrationToken;
use std::cmp::min; use std::cmp::min;
@ -289,15 +289,12 @@ impl DataControlSourceHandler for Environment {
trace!("Num bytes: {}", bytes.len()); trace!("Num bytes: {}", bytes.len());
let mut events = (0..16).map(|_| EpollEvent::empty()).collect::<Vec<_>>(); let mut events = (0..16).map(|_| EpollEvent::empty()).collect::<Vec<_>>();
let mut epoll_event = EpollEvent::new(EpollFlags::EPOLLOUT, 0); let epoll_event = EpollEvent::new(EpollFlags::EPOLLOUT, 0);
let epoll_fd = epoll_create().expect("to get valid file descriptor"); let epoll_fd =
epoll_ctl( Epoll::new(EpollCreateFlags::empty()).expect("to get valid file descriptor");
epoll_fd, epoll_fd
EpollOp::EpollCtlAdd, .add(fd, epoll_event)
fd.as_raw_fd(),
&mut epoll_event,
)
.expect("to send valid epoll operation"); .expect("to send valid epoll operation");
while !bytes.is_empty() { while !bytes.is_empty() {
@ -305,7 +302,9 @@ impl DataControlSourceHandler for Environment {
trace!("Writing {} bytes ({} remain)", chunk.len(), bytes.len()); trace!("Writing {} bytes ({} remain)", chunk.len(), bytes.len());
epoll_wait(epoll_fd, &mut events, 100).expect("Failed to wait to epoll"); epoll_fd
.wait(&mut events, 100)
.expect("Failed to wait to epoll");
match file.write(chunk) { match file.write(chunk) {
Ok(_) => bytes = &bytes[chunk.len()..], Ok(_) => bytes = &bytes[chunk.len()..],