qemu-display: Add a MultiTouch interface implementation

This commit is contained in:
Bilal Elmoussaoui 2024-02-20 13:46:04 +01:00 committed by Marc-André Lureau
parent 912d39dc20
commit 504611a853
3 changed files with 36 additions and 1 deletions

View File

@ -9,7 +9,10 @@ use uds_windows::UnixStream;
use zbus::zvariant::Fd;
use zbus::{zvariant::ObjectPath, Connection};
use crate::{util, ConsoleListener, ConsoleListenerHandler, KeyboardProxy, MouseProxy, Result};
use crate::{
util, ConsoleListener, ConsoleListenerHandler, KeyboardProxy, MouseProxy, MultiTouchProxy,
Result,
};
#[cfg(windows)]
use crate::{
ConsoleListenerD3d11, ConsoleListenerD3d11Handler, ConsoleListenerMap,
@ -58,6 +61,8 @@ pub struct Console {
pub keyboard: KeyboardProxy<'static>,
#[derivative(Debug = "ignore")]
pub mouse: MouseProxy<'static>,
#[derivative(Debug = "ignore")]
pub multi_touch: MultiTouchProxy<'static>,
listener: RwLock<Option<Connection>>,
#[cfg(windows)]
peer_pid: u32,
@ -72,10 +77,15 @@ impl Console {
.build()
.await?;
let mouse = MouseProxy::builder(conn).path(&obj_path)?.build().await?;
let multi_touch = MultiTouchProxy::builder(conn)
.path(&obj_path)?
.build()
.await?;
Ok(Self {
proxy,
keyboard,
mouse,
multi_touch,
listener: RwLock::new(None),
#[cfg(windows)]
peer_pid,

View File

@ -36,6 +36,9 @@ pub use mouse::*;
mod display;
pub use display::*;
mod multi_touch;
pub use multi_touch::*;
#[cfg(unix)]
mod usbredir;
#[cfg(unix)]

View File

@ -0,0 +1,22 @@
use serde::{Deserialize, Serialize};
use zbus::zvariant::Type;
#[repr(u32)]
#[derive(Type, Debug, PartialEq, Copy, Clone, Eq, Serialize, Deserialize)]
pub enum TouchEventKind {
Begin = 0,
Update = 1,
End = 2,
Cancel = 3,
}
#[zbus::proxy(
default_service = "org.qemu",
interface = "org.qemu.Display1.MultiTouch"
)]
pub trait MultiTouch {
fn send_event(&self, kind: TouchEventKind, num_slot: u64, x: f64, y: f64) -> zbus::Result<()>;
#[dbus_proxy(property)]
fn max_slots(&self) -> zbus::Result<i32>;
}