Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions libwayshot/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,6 @@ pub struct CaptureFrameState {
pub(crate) session_done: bool,
}

impl CaptureFrameState {
pub(crate) fn dmabuf_formats(&self) -> &[DMAFrameFormat] {
&self.dmabuf_formats
}
}

impl Dispatch<ZwpLinuxDmabufV1, ()> for CaptureFrameState {
fn event(
_frame: &mut Self,
Expand Down Expand Up @@ -311,12 +305,16 @@ impl Dispatch<ExtImageCopyCaptureSessionV1, ()> for CaptureFrameState {
set_format.format = format;
}
ext_image_copy_capture_session_v1::Event::DmabufFormat { format, .. } => {
let mut width = 0;
let mut height = 0;
if !state.formats.is_empty() {
let format = state.formats[0];
width = format.size.width;
height = format.size.height;
}
state.dmabuf_formats.push(DMAFrameFormat {
format,
size: Size {
width: 0,
height: 0,
},
size: Size { width, height },
});
}
ext_image_copy_capture_session_v1::Event::Done => {
Expand Down
55 changes: 9 additions & 46 deletions libwayshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,22 +595,15 @@ impl WayshotConnection {
target: &WayshotTarget,
capture_region: Option<EmbeddedRegion>,
) -> Result<(DMAFrameFormat, DMAFrameGuard, BufferObject<()>)> {
let WayshotTarget::Screen(output) = target else {
return Err(Error::Unsupported(
"ext-image-copy support is on road, so here we restrict it on WlOutput".to_owned(),
));
};
match &self.dmabuf_state {
Some(dmabuf_state) => {
// FIXME: now it won't work on ext-image-copy
let (state, event_queue, frame) = self
.capture_output_frame_get_state_wlr_dmabuf_tmp(
cursor_overlay as i32,
output,
capture_region,
)?;
//self.capture_target_frame_get_state(cursor_overlay, target, capture_region)?;
let frame_format = state.dmabuf_formats()[0];
let (state, event_queue, frame) =
self.capture_target_frame_get_state(cursor_overlay, target, capture_region)?;
if state.dmabuf_formats.is_empty() {
return Err(Error::NoSupportedBufferFormat);
}

let frame_format = state.dmabuf_formats[0];
tracing::trace!("Selected frame buffer format: {:#?}", frame_format);
let gbm = &dmabuf_state.gbmdev;
let bo = gbm.create_buffer_object::<()>(
Expand Down Expand Up @@ -731,7 +724,7 @@ impl WayshotConnection {
.unwrap_or(Options::PaintCursors);
let session = manager.create_session(&source, options, &qh, ());
let frame = session.create_frame(&qh, ());
while state.formats.is_empty() {
while !state.session_done {
event_queue.blocking_dispatch(&mut state)?;
}
tracing::trace!(
Expand Down Expand Up @@ -801,36 +794,6 @@ impl WayshotConnection {
}
}

// NOTE: because in 0.4.0, the dmabuf cannot work on ext-image-copy
// So here force it go to the wlr-screencopy
// Will be deleted in the feature
fn capture_output_frame_get_state_wlr_dmabuf_tmp(
&self,
cursor_overlay: i32,
output: &WlOutput,
capture_region: Option<EmbeddedRegion>,
) -> Result<(
CaptureFrameState,
EventQueue<CaptureFrameState>,
WayshotFrame,
)> {
let state = CaptureFrameState {
formats: Vec::new(),
dmabuf_formats: Vec::new(),
state: None,
buffer_done: AtomicBool::new(false),
toplevels: Vec::new(),
session_done: false,
};
let event_queue = self.conn.new_event_queue::<CaptureFrameState>();
self.capture_output_frame_get_state_wlr(
state,
event_queue,
cursor_overlay,
output,
capture_region,
)
}
// This API is exposed to provide users with access to window manager (WM)
// information. For instance, enabling Vulkan in wlroots alters the display
// format. Consequently, using PipeWire to capture streams without knowing
Expand Down Expand Up @@ -1608,7 +1571,7 @@ impl WayshotConnection {
};
let session = manager.create_session(&source, options, &qh, ());
let frame = session.create_frame(&qh, ());
while state.formats.is_empty() {
while !state.session_done {
event_queue.blocking_dispatch(&mut state)?;
}

Expand Down