Skip to content

Commit 29e780d

Browse files
committed
WIP cursor stream
1 parent b99ea99 commit 29e780d

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/wayland/cursor_stream.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use cosmic_client_toolkit::screencopy::CaptureSession;
2+
use std::{
3+
pin::Pin,
4+
task::{Context, Poll},
5+
};
6+
7+
// TODO wake stream when we get formats?
8+
pub struct CursorStream {
9+
// TODO formats
10+
pub(super) capture_session: CaptureSession,
11+
}
12+
13+
impl futures::stream::Stream for CursorStream {
14+
type Item = image::RgbaImage;
15+
16+
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<image::RgbaImage>> {
17+
todo!()
18+
}
19+
}

src/wayland/mod.rs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub use cosmic_client_toolkit::screencopy::{CaptureSource, Rect};
5353

5454
use crate::buffer;
5555

56+
mod cursor_stream;
5657
mod gbm_devices;
5758
mod toplevel;
5859
mod workspaces;
@@ -243,28 +244,14 @@ impl Session {
243244
receiver.await.unwrap()
244245
}
245246

246-
// XXX also need way to get formats?
247-
pub async fn capture_cursor_wl_buffer(
248-
&self,
249-
buffer: &wl_buffer::WlBuffer,
250-
buffer_damage: &[Rect],
251-
) -> Result<Option<Frame>, WEnum<FailureReason>> {
247+
// Should only be called once
248+
fn cursor_stream(&self) -> Option<cursor_stream::CursorStream> {
252249
let Some((_, capture_session)) = &self.0.capture_cursor_session else {
253-
return Ok(None);
250+
return None;
254251
};
255-
let (sender, receiver) = oneshot::channel();
256-
capture_session.capture(
257-
buffer,
258-
buffer_damage,
259-
&self.0.wayland_helper.inner.qh,
260-
FrameData {
261-
frame_data: Default::default(),
262-
sender: Mutex::new(Some(sender)),
263-
},
264-
);
265-
self.0.wayland_helper.inner.conn.flush().unwrap();
266-
267-
receiver.await.unwrap().map(Some)
252+
Some(cursor_stream::CursorStream {
253+
capture_session: capture_session.clone(),
254+
})
268255
}
269256
}
270257

0 commit comments

Comments
 (0)