Update dependencies (#56)

update wayland-client + reis
This commit is contained in:
Ferdinand Schober
2023-12-22 14:50:12 +01:00
committed by GitHub
parent 65a12735e2
commit fed8e02d9f
6 changed files with 455 additions and 322 deletions

695
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@ lto = "fat"
tempfile = "3.8" tempfile = "3.8"
trust-dns-resolver = "0.23" trust-dns-resolver = "0.23"
memmap = "0.7" memmap = "0.7"
toml = "0.7" toml = "0.8"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
anyhow = "1.0.71" anyhow = "1.0.71"
log = "0.4.20" log = "0.4.20"
@@ -29,10 +29,10 @@ futures = "0.3.28"
clap = { version="4.4.11", features = ["derive"] } clap = { version="4.4.11", features = ["derive"] }
[target.'cfg(all(unix, not(target_os="macos")))'.dependencies] [target.'cfg(all(unix, not(target_os="macos")))'.dependencies]
wayland-client = { version="0.30.2", optional = true } wayland-client = { version="0.31.1", optional = true }
wayland-protocols = { version="0.30.0", features=["client", "staging", "unstable"], optional = true } wayland-protocols = { version="0.31.0", features=["client", "staging", "unstable"], optional = true }
wayland-protocols-wlr = { version="0.1.0", features=["client"], optional = true } wayland-protocols-wlr = { version="0.2.0", features=["client"], optional = true }
wayland-protocols-misc = { version="0.1.0", features=["client"], optional = true } wayland-protocols-misc = { version="0.2.0", features=["client"], optional = true }
x11 = { version = "2.21.0", features = ["xlib", "xtest"], optional = true } x11 = { version = "2.21.0", features = ["xlib", "xtest"], optional = true }
ashpd = { version = "0.6.2", default-features = false, features = ["tokio"], optional = true } ashpd = { version = "0.6.2", default-features = false, features = ["tokio"], optional = true }
reis = { git = "https://github.com/ids1024/reis", features = [ "tokio" ], optional = true } reis = { git = "https://github.com/ids1024/reis", features = [ "tokio" ], optional = true }
@@ -41,6 +41,7 @@ libc = { version="0.2.148", optional = true }
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
gtk = { package = "gtk4", version = "0.7.2", features = ["v4_6"], optional = true } gtk = { package = "gtk4", version = "0.7.2", features = ["v4_6"], optional = true }
adw = { package = "libadwaita", version = "0.5.2", features = ["v1_1"], optional = true } adw = { package = "libadwaita", version = "0.5.2", features = ["v1_1"], optional = true }
async-channel = { version = "2.1.1", optional = true }
[target.'cfg(target_os="macos")'.dependencies] [target.'cfg(target_os="macos")'.dependencies]
core-graphics = { version = "0.23", features = ["highsierra"] } core-graphics = { version = "0.23", features = ["highsierra"] }
@@ -57,4 +58,4 @@ wayland = ["dep:wayland-client", "dep:wayland-protocols", "dep:wayland-protocols
x11 = ["dep:x11"] x11 = ["dep:x11"]
xdg_desktop_portal = ["dep:ashpd"] xdg_desktop_portal = ["dep:ashpd"]
libei = ["dep:reis", "dep:ashpd", "dep:libc" ] libei = ["dep:reis", "dep:ashpd", "dep:libc" ]
gtk = ["dep:gtk", "dep:adw"] gtk = ["dep:gtk", "dep:adw", "dep:async-channel"]

View File

@@ -193,7 +193,7 @@ impl EventConsumer for LibeiConsumer {
}; };
let event = match event { let event = match event {
PendingRequestResult::Request(result) => result, PendingRequestResult::Request(result) => result,
PendingRequestResult::ProtocolError(e) => { PendingRequestResult::ParseError(e) => {
return Err(anyhow!("libei protocol violation: {e}")) return Err(anyhow!("libei protocol violation: {e}"))
} }
PendingRequestResult::InvalidObject(e) => return Err(anyhow!("invalid object {e}")), PendingRequestResult::InvalidObject(e) => return Err(anyhow!("invalid object {e}")),

View File

@@ -3,8 +3,7 @@ use crate::consumer::EventConsumer;
use async_trait::async_trait; use async_trait::async_trait;
use std::collections::HashMap; use std::collections::HashMap;
use std::io; use std::io;
use std::os::fd::OwnedFd; use std::os::fd::{AsFd, OwnedFd};
use std::os::unix::prelude::AsRawFd;
use wayland_client::backend::WaylandError; use wayland_client::backend::WaylandError;
use wayland_client::WEnum; use wayland_client::WEnum;
@@ -95,7 +94,7 @@ impl State {
// TODO: use server side keymap // TODO: use server side keymap
if let Some((format, fd, size)) = self.keymap.as_ref() { if let Some((format, fd, size)) = self.keymap.as_ref() {
keyboard.keymap(*format, fd.as_raw_fd(), *size); keyboard.keymap(*format, fd.as_fd(), *size);
} else { } else {
panic!("no keymap"); panic!("no keymap");
} }

View File

@@ -10,7 +10,7 @@ use std::{
collections::VecDeque, collections::VecDeque,
env, env,
io::{self, ErrorKind}, io::{self, ErrorKind},
os::fd::{OwnedFd, RawFd}, os::fd::{AsFd, OwnedFd, RawFd},
pin::Pin, pin::Pin,
task::{ready, Context, Poll}, task::{ready, Context, Poll},
}; };
@@ -145,7 +145,7 @@ impl Window {
draw(&mut file, (width, height)); draw(&mut file, (width, height));
let pool = g let pool = g
.shm .shm
.create_pool(file.as_raw_fd(), (width * height * 4) as i32, qh, ()); .create_pool(file.as_fd(), (width * height * 4) as i32, qh, ());
let buffer = pool.create_buffer( let buffer = pool.create_buffer(
0, 0,
width as i32, width as i32,
@@ -324,7 +324,7 @@ impl WaylandEventProducer {
queue.flush()?; queue.flush()?;
// prepare reading wayland events // prepare reading wayland events
let read_guard = queue.prepare_read()?; let read_guard = queue.prepare_read().unwrap(); // there can not yet be events to dispatch
let wayland_fd = read_guard.connection_fd().try_clone_to_owned().unwrap(); let wayland_fd = read_guard.connection_fd().try_clone_to_owned().unwrap();
std::mem::drop(read_guard); std::mem::drop(read_guard);
@@ -366,7 +366,15 @@ impl WaylandEventProducer {
log::debug!("{:#?}", i.1); log::debug!("{:#?}", i.1);
} }
let read_guard = queue.prepare_read()?; let read_guard = loop {
match queue.prepare_read() {
Some(r) => break r,
None => {
queue.dispatch_pending(&mut state)?;
continue;
}
}
};
state.read_guard = Some(read_guard); state.read_guard = Some(read_guard);
let inner = AsyncFd::new(Inner { queue, state })?; let inner = AsyncFd::new(Inner { queue, state })?;
@@ -484,16 +492,20 @@ impl Inner {
} }
} }
fn prepare_read(&mut self) { fn prepare_read(&mut self) -> io::Result<()> {
match self.queue.prepare_read() { loop {
Ok(r) => self.state.read_guard = Some(r), match self.queue.prepare_read() {
Err(WaylandError::Io(e)) => { None => match self.queue.dispatch_pending(&mut self.state) {
log::error!("error preparing read from wayland socket: {e}") Ok(_) => continue,
Err(DispatchError::Backend(WaylandError::Io(e))) => return Err(e),
Err(e) => panic!("failed to dispatch wayland events: {e}"),
},
Some(r) => {
self.state.read_guard = Some(r);
break Ok(());
}
} }
Err(WaylandError::Protocol(e)) => { }
panic!("wayland Protocol violation: {e}")
}
};
} }
fn dispatch_events(&mut self) { fn dispatch_events(&mut self) {
@@ -579,7 +591,10 @@ impl Stream for WaylandEventProducer {
// read events // read events
while inner.read() { while inner.read() {
// prepare next read // prepare next read
inner.prepare_read(); match inner.prepare_read() {
Ok(_) => {}
Err(e) => return Poll::Ready(Some(Err(e))),
}
} }
// dispatch the events // dispatch the events
@@ -589,7 +604,10 @@ impl Stream for WaylandEventProducer {
inner.flush_events(); inner.flush_events();
// prepare for the next read // prepare for the next read
inner.prepare_read(); match inner.prepare_read() {
Ok(_) => {}
Err(e) => return Poll::Ready(Some(Err(e))),
}
} }
// clear read readiness for tokio read guard // clear read readiness for tokio read guard

View File

@@ -14,7 +14,7 @@ use adw::Application;
use gtk::{ use gtk::{
gdk::Display, gdk::Display,
gio::{SimpleAction, SimpleActionGroup}, gio::{SimpleAction, SimpleActionGroup},
glib::{clone, MainContext, Priority}, glib::clone,
prelude::*, prelude::*,
subclass::prelude::ObjectSubclassIsExt, subclass::prelude::ObjectSubclassIsExt,
CssProvider, IconTheme, CssProvider, IconTheme,
@@ -81,7 +81,7 @@ fn build_ui(app: &Application) {
}; };
log::debug!("connected to lan-mouse-socket"); log::debug!("connected to lan-mouse-socket");
let (sender, receiver) = MainContext::channel::<FrontendNotify>(Priority::default()); let (sender, receiver) = async_channel::bounded(10);
gio::spawn_blocking(move || { gio::spawn_blocking(move || {
match loop { match loop {
@@ -105,7 +105,7 @@ fn build_ui(app: &Application) {
// parse json // parse json
let json = str::from_utf8(&buf).unwrap(); let json = str::from_utf8(&buf).unwrap();
match serde_json::from_str(json) { match serde_json::from_str(json) {
Ok(notify) => sender.send(notify).unwrap(), Ok(notify) => sender.send_blocking(notify).unwrap(),
Err(e) => log::error!("{e}"), Err(e) => log::error!("{e}"),
} }
} { } {
@@ -116,8 +116,9 @@ fn build_ui(app: &Application) {
let window = Window::new(app); let window = Window::new(app);
window.imp().stream.borrow_mut().replace(tx); window.imp().stream.borrow_mut().replace(tx);
receiver.attach(None, clone!(@weak window => @default-return glib::ControlFlow::Break, glib::spawn_future_local(clone!(@weak window => async move {
move |notify| { loop {
let notify = receiver.recv().await.unwrap();
match notify { match notify {
FrontendNotify::NotifyClientCreate(client, hostname, port, position) => { FrontendNotify::NotifyClientCreate(client, hostname, port, position) => {
window.new_client(client, hostname, port, position, false); window.new_client(client, hostname, port, position, false);
@@ -158,9 +159,8 @@ fn build_ui(app: &Application) {
window.imp().set_port(port); window.imp().set_port(port);
} }
} }
glib::ControlFlow::Continue
} }
)); }));
let action_request_client_update = let action_request_client_update =
SimpleAction::new("request-client-update", Some(&u32::static_variant_type())); SimpleAction::new("request-client-update", Some(&u32::static_variant_type()));