wlr-screencopy, though it doesnt work

This commit is contained in:
galister
2024-02-20 22:33:50 +01:00
parent e7b415ae4e
commit e2ca33ca76
4 changed files with 34 additions and 11 deletions

8
Cargo.lock generated
View File

@@ -624,9 +624,9 @@ dependencies = [
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.15.0" version = "3.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" checksum = "c764d619ca78fccbf3069b37bd7af92577f044bb15236036662d79b6559f25b7"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
@@ -4293,7 +4293,7 @@ dependencies = [
[[package]] [[package]]
name = "wlx-capture" name = "wlx-capture"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/galister/wlx-capture#b715303245197ea3bb7b8b5e348f5c26299e3c8a" source = "git+https://github.com/galister/wlx-capture#af2af8e7c93b0b4414b137eccec23f58fd6098a8"
dependencies = [ dependencies = [
"ashpd", "ashpd",
"drm-fourcc", "drm-fourcc",
@@ -4312,7 +4312,7 @@ dependencies = [
[[package]] [[package]]
name = "wlx-overlay-s" name = "wlx-overlay-s"
version = "0.2.0" version = "0.2.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ash", "ash",

View File

@@ -4,7 +4,7 @@ debug = true
[package] [package]
name = "wlx-overlay-s" name = "wlx-overlay-s"
version = "0.2.0" version = "0.2.1"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -63,7 +63,7 @@ fn auto_run(running: Arc<AtomicBool>) {
Ok(()) => return, Ok(()) => return,
Err(BackendError::NotSupported) => (), Err(BackendError::NotSupported) => (),
Err(e) => { Err(e) => {
log::error!("{}", e); log::error!("{}", e.to_string());
return; return;
} }
}; };
@@ -76,7 +76,7 @@ fn auto_run(running: Arc<AtomicBool>) {
Ok(()) => return, Ok(()) => return,
Err(BackendError::NotSupported) => (), Err(BackendError::NotSupported) => (),
Err(e) => { Err(e) => {
log::error!("{}", e); log::error!("{}", e.to_string());
return; return;
} }
}; };

View File

@@ -28,6 +28,7 @@ use {
pipewire::{pipewire_select_screen, PipewireCapture}, pipewire::{pipewire_select_screen, PipewireCapture},
wayland::{WlxClient, WlxOutput}, wayland::{WlxClient, WlxOutput},
wlr_dmabuf::WlrDmabufCapture, wlr_dmabuf::WlrDmabufCapture,
wlr_screencopy::WlrScreencopyCapture,
}, },
}; };
@@ -254,7 +255,7 @@ impl ScreenRenderer {
} }
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
pub fn new_wlr(output: &WlxOutput) -> Option<ScreenRenderer> { pub fn new_wlr_dmabuf(output: &WlxOutput) -> Option<ScreenRenderer> {
let client = WlxClient::new()?; let client = WlxClient::new()?;
let capture = WlrDmabufCapture::new(client, output.id); let capture = WlrDmabufCapture::new(client, output.id);
@@ -267,6 +268,20 @@ impl ScreenRenderer {
}) })
} }
#[cfg(feature = "wayland")]
pub fn new_wlr_screencopy(output: &WlxOutput) -> Option<ScreenRenderer> {
let client = WlxClient::new()?;
let capture = WlrScreencopyCapture::new(client, output.id);
Some(ScreenRenderer {
name: output.name.clone(),
capture: Box::new(capture),
pipeline: None,
last_view: None,
extent: extent_from_res(output.size),
})
}
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
pub fn new_pw( pub fn new_pw(
output: &WlxOutput, output: &WlxOutput,
@@ -313,7 +328,8 @@ impl OverlayRenderer for ScreenRenderer {
} }
fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> { fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> {
if !self.capture.ready() { if !self.capture.ready() {
let allow_dmabuf = &*app.session.config.capture_method != "pw_fallback"; let allow_dmabuf = &*app.session.config.capture_method != "pw_fallback"
&& &*app.session.config.capture_method != "screencopy";
let drm_formats = DRM_FORMATS.get_or_init({ let drm_formats = DRM_FORMATS.get_or_init({
let graphics = app.graphics.clone(); let graphics = app.graphics.clone();
@@ -492,9 +508,16 @@ where
let mut capture: Option<ScreenRenderer> = None; let mut capture: Option<ScreenRenderer> = None;
if &*session.config.capture_method == "auto" && wl.maybe_wlr_dmabuf_mgr.is_some() { if (&*session.config.capture_method == "auto" || &*session.config.capture_method == "dmabuf")
&& wl.maybe_wlr_dmabuf_mgr.is_some()
{
log::info!("{}: Using Wlr DMA-Buf", &output.name); log::info!("{}: Using Wlr DMA-Buf", &output.name);
capture = ScreenRenderer::new_wlr(output); capture = ScreenRenderer::new_wlr_dmabuf(output);
}
if &*session.config.capture_method == "screencopy" && wl.maybe_wlr_screencopy_mgr.is_some() {
log::info!("{}: Using Wlr Screencopy Wl-SHM", &output.name);
capture = ScreenRenderer::new_wlr_screencopy(output);
} }
if capture.is_none() { if capture.is_none() {