WIP: signal handling

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau committed 2021-04-21 11:41:48 +04:00
1 parent 7866b11456
commit 8ed884fc35
6 files changed
+56 -9

No files matched your search

+17 -2
View File
@@ -1,4 +1,4 @@
use glib::{clone, subclass::prelude::*, translate::*, MainContext};
use glib::{clone, subclass::prelude::*, MainContext};
use gtk::{glib, prelude::*};
use once_cell::sync::OnceCell;
@@ -8,8 +8,9 @@ use rdw::DisplayExt;
mod imp {
use super::*;
use futures_util::future::FutureExt;
use gtk::subclass::prelude::*;
use std::os::unix::io::IntoRawFd;
use std::{convert::TryInto, os::unix::io::IntoRawFd};
#[repr(C)]
pub struct RdwDisplayQemuClass {
@@ -140,6 +141,7 @@ mod imp {
MainContext::default().spawn_local(clone!(@weak widget => async move {
let self_ = Self::from_instance(&widget);
let console = self_.console.get().unwrap();
let (rx, wait_tx) = console
.glib_listen()
.await
@@ -206,6 +208,19 @@ mod imp {
Continue(true)
})
);
console.mouse.connect_is_absolute_changed(clone!(@strong widget => @default-panic, move |v| {
widget.set_mouse_absolute(v.map_or(true, |v| v.try_into().unwrap_or(true)));
async move {
}.boxed()
})).await.unwrap();
loop {
if let Err(e) = console.dispatch_signals().await {
log::warn!("Console dispatching error: {}", e);
break;
}
}
}));
}
}
+3 -2
View File
@@ -1,4 +1,3 @@
use std::error::Error;
use gio::ApplicationFlags;
use glib::{clone, MainContext};
use gtk::{gio, glib, prelude::*};
@@ -12,7 +11,9 @@ fn main() {
let app = gtk::Application::new(Some("org.qemu.rdw.demo"), ApplicationFlags::NON_UNIQUE);
let conn: zbus::azync::Connection = Connection::new_session().expect("Failed to connect to DBus").into();
let conn: zbus::azync::Connection = Connection::new_session()
.expect("Failed to connect to DBus")
.into();
app.connect_activate(move |app| {
let window = gtk::ApplicationWindow::new(app);