mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2024-12-22 05:35:20 +00:00
qemu-display: add Listener.Unix.Map
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
fe1742d142
commit
5f4810d994
@ -10,14 +10,11 @@ use zbus::zvariant::Fd;
|
|||||||
use zbus::{zvariant::ObjectPath, Connection};
|
use zbus::{zvariant::ObjectPath, Connection};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
util, ConsoleListener, ConsoleListenerHandler, KeyboardProxy, MouseProxy, MultiTouchProxy,
|
util, ConsoleListener, ConsoleListenerHandler, ConsoleListenerMap, ConsoleListenerMapHandler,
|
||||||
Result,
|
KeyboardProxy, MouseProxy, MultiTouchProxy, Result,
|
||||||
};
|
};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use crate::{
|
use crate::{ConsoleListenerD3d11, ConsoleListenerD3d11Handler};
|
||||||
ConsoleListenerD3d11, ConsoleListenerD3d11Handler, ConsoleListenerMap,
|
|
||||||
ConsoleListenerMapHandler,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[zbus::proxy(default_service = "org.qemu", interface = "org.qemu.Display1.Console")]
|
#[zbus::proxy(default_service = "org.qemu", interface = "org.qemu.Display1.Console")]
|
||||||
pub trait Console {
|
pub trait Console {
|
||||||
@ -122,7 +119,6 @@ impl Console {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
pub async fn set_map_listener<H: ConsoleListenerMapHandler>(&self, handler: H) -> Result<bool> {
|
pub async fn set_map_listener<H: ConsoleListenerMapHandler>(&self, handler: H) -> Result<bool> {
|
||||||
if let Some(l) = &*self.listener.write().unwrap() {
|
if let Some(l) = &*self.listener.write().unwrap() {
|
||||||
return l
|
return l
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use crate::win32::Fd;
|
use crate::win32::Fd;
|
||||||
use derivative::Derivative;
|
use derivative::Derivative;
|
||||||
use std::ops::Drop;
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
|
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
|
||||||
|
use std::{
|
||||||
|
ops::Drop,
|
||||||
|
os::fd::{AsFd, OwnedFd},
|
||||||
|
};
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use zbus::zvariant::Fd;
|
use zbus::zvariant::Fd;
|
||||||
|
|
||||||
@ -33,6 +36,9 @@ pub struct Update {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ScanoutMap {
|
pub struct ScanoutMap {
|
||||||
|
#[cfg(unix)]
|
||||||
|
pub fd: OwnedFd,
|
||||||
|
#[cfg(windows)]
|
||||||
pub handle: u64,
|
pub handle: u64,
|
||||||
pub offset: u32,
|
pub offset: u32,
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
@ -309,7 +315,6 @@ impl<H: ConsoleListenerHandler> Drop for ConsoleListener<H> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait ConsoleListenerMapHandler: 'static + Send + Sync {
|
pub trait ConsoleListenerMapHandler: 'static + Send + Sync {
|
||||||
async fn scanout_map(&mut self, scanout: ScanoutMap);
|
async fn scanout_map(&mut self, scanout: ScanoutMap);
|
||||||
@ -317,12 +322,42 @@ pub trait ConsoleListenerMapHandler: 'static + Send + Sync {
|
|||||||
async fn update_map(&mut self, update: UpdateMap);
|
async fn update_map(&mut self, update: UpdateMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct ConsoleListenerMap<H: ConsoleListenerMapHandler> {
|
pub(crate) struct ConsoleListenerMap<H: ConsoleListenerMapHandler> {
|
||||||
handler: H,
|
handler: H,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[zbus::interface(name = "org.qemu.Display1.Listener.Unix.Map")]
|
||||||
|
impl<H: ConsoleListenerMapHandler> ConsoleListenerMap<H> {
|
||||||
|
async fn scanout_map(
|
||||||
|
&mut self,
|
||||||
|
fd: Fd<'_>,
|
||||||
|
offset: u32,
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
stride: u32,
|
||||||
|
format: u32,
|
||||||
|
) -> zbus::fdo::Result<()> {
|
||||||
|
let map = ScanoutMap {
|
||||||
|
fd: fd.as_fd().try_clone_to_owned().unwrap(),
|
||||||
|
offset,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
stride,
|
||||||
|
format,
|
||||||
|
};
|
||||||
|
self.handler.scanout_map(map).await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_map(&mut self, x: i32, y: i32, w: i32, h: i32) -> zbus::fdo::Result<()> {
|
||||||
|
let up = UpdateMap { x, y, w, h };
|
||||||
|
self.handler.update_map(up).await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[zbus::interface(name = "org.qemu.Display1.Listener.Win32.Map")]
|
#[zbus::interface(name = "org.qemu.Display1.Listener.Win32.Map")]
|
||||||
impl<H: ConsoleListenerMapHandler> ConsoleListenerMap<H> {
|
impl<H: ConsoleListenerMapHandler> ConsoleListenerMap<H> {
|
||||||
@ -354,7 +389,6 @@ impl<H: ConsoleListenerMapHandler> ConsoleListenerMap<H> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
impl<H: ConsoleListenerMapHandler> ConsoleListenerMap<H> {
|
impl<H: ConsoleListenerMapHandler> ConsoleListenerMap<H> {
|
||||||
pub(crate) fn new(handler: H) -> Self {
|
pub(crate) fn new(handler: H) -> Self {
|
||||||
Self { handler }
|
Self { handler }
|
||||||
|
Loading…
Reference in New Issue
Block a user