mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2024-12-22 21:55:19 +00:00
vte: handle input
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
c8b236f092
commit
7431fbab65
@ -1,11 +1,11 @@
|
|||||||
|
use futures::prelude::*;
|
||||||
use glib::{clone, MainContext};
|
use glib::{clone, MainContext};
|
||||||
use qemu_display_listener::Chardev;
|
use qemu_display_listener::Chardev;
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use std::os::unix::net::UnixStream;
|
use std::os::unix::net::UnixStream;
|
||||||
use vte::prelude::*;
|
use vte::prelude::*;
|
||||||
use vte::{glib, gtk, gio};
|
use vte::{gio, glib, gtk};
|
||||||
use zbus::azync::Connection;
|
use zbus::azync::Connection;
|
||||||
use futures::prelude::*;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
@ -23,17 +23,20 @@ fn main() {
|
|||||||
|
|
||||||
MainContext::default().spawn_local(clone!(@strong window => async move {
|
MainContext::default().spawn_local(clone!(@strong window => async move {
|
||||||
let conn = Connection::new_session().await
|
let conn = Connection::new_session().await
|
||||||
.expect("Failed to connect to DBus")
|
.expect("Failed to connect to DBus");
|
||||||
.into();
|
|
||||||
|
|
||||||
if let Ok(c) = Chardev::new(&conn, "serial").await {
|
if let Ok(c) = Chardev::new(&conn, "serial").await {
|
||||||
let (p0, p1) = UnixStream::pair().unwrap();
|
let (p0, p1) = UnixStream::pair().unwrap();
|
||||||
if c.proxy.register(p1.as_raw_fd().into()).await.is_ok() {
|
if c.proxy.register(p1.as_raw_fd().into()).await.is_ok() {
|
||||||
log::info!("ok");
|
log::info!("ok");
|
||||||
|
let ostream = unsafe { gio::UnixOutputStream::with_fd(p0.as_raw_fd()) };
|
||||||
let istream = unsafe { gio::UnixInputStream::take_fd(p0) }
|
let istream = unsafe { gio::UnixInputStream::take_fd(p0) }
|
||||||
.dynamic_cast::<gio::PollableInputStream>()
|
.dynamic_cast::<gio::PollableInputStream>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut read = istream.into_async_read().unwrap();
|
let mut read = istream.into_async_read().unwrap();
|
||||||
|
term.connect_commit(move |_, text, _| {
|
||||||
|
let _res = ostream.write(text.as_bytes(), gio::NONE_CANCELLABLE); // TODO cancellable and error
|
||||||
|
});
|
||||||
loop {
|
loop {
|
||||||
let mut buffer = [0u8; 8192];
|
let mut buffer = [0u8; 8192];
|
||||||
match read.read(&mut buffer[..]).await {
|
match read.read(&mut buffer[..]).await {
|
||||||
|
Loading…
Reference in New Issue
Block a user