mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-21 20:20:55 +03:00
wire frontend
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use std::io;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
@@ -27,15 +26,15 @@ impl Default for DummyInputCapture {
|
||||
|
||||
#[async_trait]
|
||||
impl InputCapture for DummyInputCapture {
|
||||
async fn create(&mut self, _handle: CaptureHandle, _pos: Position) -> io::Result<()> {
|
||||
async fn create(&mut self, _handle: CaptureHandle, _pos: Position) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn destroy(&mut self, _handle: CaptureHandle) -> io::Result<()> {
|
||||
async fn destroy(&mut self, _handle: CaptureHandle) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn release(&mut self) -> io::Result<()> {
|
||||
async fn release(&mut self) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{fmt::Display, io};
|
||||
use std::fmt::Display;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures_core::Stream;
|
||||
@@ -98,13 +98,13 @@ pub trait InputCapture:
|
||||
Stream<Item = Result<(CaptureHandle, Event), CaptureError>> + Unpin
|
||||
{
|
||||
/// create a new client with the given id
|
||||
async fn create(&mut self, id: CaptureHandle, pos: Position) -> io::Result<()>;
|
||||
async fn create(&mut self, id: CaptureHandle, pos: Position) -> Result<(), CaptureError>;
|
||||
|
||||
/// destroy the client with the given id, if it exists
|
||||
async fn destroy(&mut self, id: CaptureHandle) -> io::Result<()>;
|
||||
async fn destroy(&mut self, id: CaptureHandle) -> Result<(), CaptureError>;
|
||||
|
||||
/// release mouse
|
||||
async fn release(&mut self) -> io::Result<()>;
|
||||
async fn release(&mut self) -> Result<(), CaptureError>;
|
||||
|
||||
/// destroy the input acpture
|
||||
async fn terminate(&mut self) -> Result<(), CaptureError>;
|
||||
|
||||
@@ -37,10 +37,9 @@ use once_cell::sync::Lazy;
|
||||
|
||||
use input_event::{Event, KeyboardEvent, PointerEvent};
|
||||
|
||||
use crate::error::{CaptureError, ReisConvertEventStreamError};
|
||||
|
||||
use super::{
|
||||
error::LibeiCaptureCreationError, CaptureHandle, InputCapture as LanMouseInputCapture, Position,
|
||||
error::{CaptureError, LibeiCaptureCreationError, ReisConvertEventStreamError},
|
||||
CaptureHandle, InputCapture as LanMouseInputCapture, Position,
|
||||
};
|
||||
|
||||
/* there is a bug in xdg-remote-desktop-portal-gnome / mutter that
|
||||
@@ -648,7 +647,7 @@ fn to_input_events(ei_event: EiEvent) -> Events {
|
||||
|
||||
#[async_trait]
|
||||
impl<'a> LanMouseInputCapture for LibeiInputCapture<'a> {
|
||||
async fn create(&mut self, handle: CaptureHandle, pos: Position) -> io::Result<()> {
|
||||
async fn create(&mut self, handle: CaptureHandle, pos: Position) -> Result<(), CaptureError> {
|
||||
let _ = self
|
||||
.notify_capture
|
||||
.send(CaptureEvent::Create(handle, pos))
|
||||
@@ -656,7 +655,7 @@ impl<'a> LanMouseInputCapture for LibeiInputCapture<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn destroy(&mut self, handle: CaptureHandle) -> io::Result<()> {
|
||||
async fn destroy(&mut self, handle: CaptureHandle) -> Result<(), CaptureError> {
|
||||
let _ = self
|
||||
.notify_capture
|
||||
.send(CaptureEvent::Destroy(handle))
|
||||
@@ -664,7 +663,7 @@ impl<'a> LanMouseInputCapture for LibeiInputCapture<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn release(&mut self) -> io::Result<()> {
|
||||
async fn release(&mut self) -> Result<(), CaptureError> {
|
||||
let _ = self.notify_capture_session.send(ReleaseCaptureEvent).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -25,15 +25,15 @@ impl Stream for MacOSInputCapture {
|
||||
|
||||
#[async_trait]
|
||||
impl InputCapture for MacOSInputCapture {
|
||||
async fn create(&mut self, _id: CaptureHandle, _pos: Position) -> io::Result<()> {
|
||||
async fn create(&mut self, _id: CaptureHandle, _pos: Position) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn destroy(&mut self, _id: CaptureHandle) -> io::Result<()> {
|
||||
async fn destroy(&mut self, _id: CaptureHandle) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn release(&mut self) -> io::Result<()> {
|
||||
async fn release(&mut self) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -566,23 +566,23 @@ impl Inner {
|
||||
|
||||
#[async_trait]
|
||||
impl InputCapture for WaylandInputCapture {
|
||||
async fn create(&mut self, handle: CaptureHandle, pos: Position) -> io::Result<()> {
|
||||
async fn create(&mut self, handle: CaptureHandle, pos: Position) -> Result<(), CaptureError> {
|
||||
self.add_client(handle, pos);
|
||||
let inner = self.0.get_mut();
|
||||
inner.flush_events()
|
||||
Ok(inner.flush_events()?)
|
||||
}
|
||||
|
||||
async fn destroy(&mut self, handle: CaptureHandle) -> io::Result<()> {
|
||||
async fn destroy(&mut self, handle: CaptureHandle) -> Result<(), CaptureError> {
|
||||
self.delete_client(handle);
|
||||
let inner = self.0.get_mut();
|
||||
inner.flush_events()
|
||||
Ok(inner.flush_events()?)
|
||||
}
|
||||
|
||||
async fn release(&mut self) -> io::Result<()> {
|
||||
async fn release(&mut self) -> Result<(), CaptureError> {
|
||||
log::debug!("releasing pointer");
|
||||
let inner = self.0.get_mut();
|
||||
inner.state.ungrab();
|
||||
inner.flush_events()
|
||||
Ok(inner.flush_events()?)
|
||||
}
|
||||
|
||||
async fn terminate(&mut self) -> Result<(), CaptureError> {
|
||||
|
||||
@@ -65,7 +65,7 @@ unsafe fn signal_message_thread(event_type: EventType) {
|
||||
|
||||
#[async_trait]
|
||||
impl InputCapture for WindowsInputCapture {
|
||||
async fn create(&mut self, handle: CaptureHandle, pos: Position) -> io::Result<()> {
|
||||
async fn create(&mut self, handle: CaptureHandle, pos: Position) -> Result<(), CaptureError> {
|
||||
unsafe {
|
||||
{
|
||||
let mut requests = REQUEST_BUFFER.lock().unwrap();
|
||||
@@ -76,7 +76,7 @@ impl InputCapture for WindowsInputCapture {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn destroy(&mut self, handle: CaptureHandle) -> io::Result<()> {
|
||||
async fn destroy(&mut self, handle: CaptureHandle) -> Result<(), CaptureError> {
|
||||
unsafe {
|
||||
{
|
||||
let mut requests = REQUEST_BUFFER.lock().unwrap();
|
||||
@@ -87,7 +87,7 @@ impl InputCapture for WindowsInputCapture {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn release(&mut self) -> io::Result<()> {
|
||||
async fn release(&mut self) -> Result<(), CaptureError> {
|
||||
unsafe { signal_message_thread(EventType::Release) };
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use std::io;
|
||||
use std::task::Poll;
|
||||
|
||||
use async_trait::async_trait;
|
||||
@@ -22,15 +21,15 @@ impl X11InputCapture {
|
||||
|
||||
#[async_trait]
|
||||
impl InputCapture for X11InputCapture {
|
||||
async fn create(&mut self, _id: CaptureHandle, _pos: Position) -> io::Result<()> {
|
||||
async fn create(&mut self, _id: CaptureHandle, _pos: Position) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn destroy(&mut self, _id: CaptureHandle) -> io::Result<()> {
|
||||
async fn destroy(&mut self, _id: CaptureHandle) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn release(&mut self) -> io::Result<()> {
|
||||
async fn release(&mut self) -> Result<(), CaptureError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user