reference count capture (#209)

* reference count capture

Multiple captures can now be created at the same position.
Captures at the same position are reference counted.

* update testcase

will be required by #200 / #164
This commit is contained in:
Ferdinand Schober
2024-10-05 21:22:28 +02:00
committed by GitHub
parent ab1b45ff45
commit 5b1dc4ccf8
8 changed files with 270 additions and 238 deletions

View File

@@ -8,7 +8,7 @@ use futures_core::Stream;
use input_event::PointerEvent;
use tokio::time::{self, Instant, Interval};
use super::{Capture, CaptureError, CaptureEvent, CaptureHandle, Position};
use super::{Capture, CaptureError, CaptureEvent, Position};
pub struct DummyInputCapture {
start: Option<Instant>,
@@ -34,11 +34,11 @@ impl Default for DummyInputCapture {
#[async_trait]
impl Capture for DummyInputCapture {
async fn create(&mut self, _handle: CaptureHandle, _pos: Position) -> Result<(), CaptureError> {
async fn create(&mut self, _pos: Position) -> Result<(), CaptureError> {
Ok(())
}
async fn destroy(&mut self, _handle: CaptureHandle) -> Result<(), CaptureError> {
async fn destroy(&mut self, _pos: Position) -> Result<(), CaptureError> {
Ok(())
}
@@ -55,7 +55,7 @@ const FREQUENCY_HZ: f64 = 1.0;
const RADIUS: f64 = 100.0;
impl Stream for DummyInputCapture {
type Item = Result<(CaptureHandle, CaptureEvent), CaptureError>;
type Item = Result<(Position, CaptureEvent), CaptureError>;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let current = ready!(self.interval.poll_tick(cx));
@@ -81,6 +81,6 @@ impl Stream for DummyInputCapture {
}))
}
};
Poll::Ready(Some(Ok((0, event))))
Poll::Ready(Some(Ok((Position::Left, event))))
}
}