mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 18:51:04 +02:00
refactor(wlr data control): update to new nix epoll bindings
This commit is contained in:
parent
60bb69feec
commit
4e67b73a83
1 changed files with 10 additions and 11 deletions
|
@ -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,23 +289,22 @@ 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(),
|
.expect("to send valid epoll operation");
|
||||||
&mut epoll_event,
|
|
||||||
)
|
|
||||||
.expect("to send valid epoll operation");
|
|
||||||
|
|
||||||
while !bytes.is_empty() {
|
while !bytes.is_empty() {
|
||||||
let chunk = &bytes[..min(pipe_size as usize, bytes.len())];
|
let chunk = &bytes[..min(pipe_size as usize, bytes.len())];
|
||||||
|
|
||||||
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()..],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue