- manual eventloop now replaced by asycn-await using the tokio runtime
- dns no longer blocks the event loop
- simplifies logic
- makes xdg-desktop-portal easier to integrate
This commit is contained in:
Ferdinand Schober
2023-10-11 14:52:18 +02:00
committed by GitHub
parent d4d6f05802
commit ab2514e508
13 changed files with 453 additions and 565 deletions

View File

@@ -1,5 +1,11 @@
use mio::event::Source;
use std::{error::Error, vec::Drain};
use std::error::Error;
#[cfg(unix)]
use std::{io, os::fd::RawFd, vec::Drain};
#[cfg(unix)]
use tokio::io::unix::AsyncFd;
use crate::{client::{ClientHandle, ClientEvent}, event::Event};
use crate::backend::producer;
@@ -49,15 +55,24 @@ pub fn create() -> Result<Box<dyn EventProducer>, Box<dyn Error>> {
}
}
pub trait EventProducer: Source {
pub trait EventProducer {
/// notify event producer of configuration changes
fn notify(&mut self, event: ClientEvent);
/// release mouse
fn release(&mut self);
/// unix only
#[cfg(unix)]
fn get_async_fd(&self) -> io::Result<AsyncFd<RawFd>>;
/// read an event
/// this function must be invoked to retrieve an Event after
/// the eventfd indicates a pending Event
#[cfg(unix)]
fn read_events(&mut self) -> Drain<(ClientHandle, Event)>;
/// release mouse
fn release(&mut self);
#[cfg(not(unix))]
fn get_wait_channel(&mut self) -> Option<tokio::sync::mpsc::Receiver<(ClientHandle, Event)>>;
}