- 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,9 +1,9 @@
use crate::{client::{ClientHandle, Position, ClientEvent}, producer::EventProducer};
use mio::{event::Source, unix::SourceFd};
use std::{os::fd::RawFd, vec::Drain, io::ErrorKind, env};
use std::{os::fd::RawFd, vec::Drain, io::{ErrorKind, self}, env};
use memmap::MmapOptions;
use anyhow::{anyhow, Result};
use tokio::io::unix::AsyncFd;
use std::{
fs::File,
@@ -421,29 +421,12 @@ impl State {
}
}
impl Source for WaylandEventProducer {
fn register(
&mut self,
registry: &mio::Registry,
token: mio::Token,
interests: mio::Interest,
) -> std::io::Result<()> {
SourceFd(&self.state.wayland_fd).register(registry, token, interests)
}
fn reregister(
&mut self,
registry: &mio::Registry,
token: mio::Token,
interests: mio::Interest,
) -> std::io::Result<()> {
SourceFd(&self.state.wayland_fd).reregister(registry, token, interests)
}
fn deregister(&mut self, registry: &mio::Registry) -> std::io::Result<()> {
SourceFd(&self.state.wayland_fd).deregister(registry)
impl AsRawFd for WaylandEventProducer {
fn as_raw_fd(&self) -> RawFd {
self.state.wayland_fd
}
}
impl WaylandEventProducer {
fn read(&mut self) -> bool {
match self.state.read_guard.take().unwrap().read() {
@@ -508,6 +491,10 @@ impl WaylandEventProducer {
impl EventProducer for WaylandEventProducer {
fn get_async_fd(&self) -> io::Result<AsyncFd<RawFd>> {
AsyncFd::new(self.as_raw_fd())
}
fn read_events(&mut self) -> Drain<(ClientHandle, Event)> {
// read events
while self.read() {