diff --git a/Cargo.lock b/Cargo.lock index 702f506..02e62d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -624,9 +624,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.0" +version = "3.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" +checksum = "c764d619ca78fccbf3069b37bd7af92577f044bb15236036662d79b6559f25b7" [[package]] name = "bytemuck" @@ -4293,7 +4293,7 @@ dependencies = [ [[package]] name = "wlx-capture" version = "0.2.0" -source = "git+https://github.com/galister/wlx-capture#b715303245197ea3bb7b8b5e348f5c26299e3c8a" +source = "git+https://github.com/galister/wlx-capture#af2af8e7c93b0b4414b137eccec23f58fd6098a8" dependencies = [ "ashpd", "drm-fourcc", @@ -4312,7 +4312,7 @@ dependencies = [ [[package]] name = "wlx-overlay-s" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "ash", diff --git a/Cargo.toml b/Cargo.toml index 42f61ee..5676118 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ debug = true [package] name = "wlx-overlay-s" -version = "0.2.0" +version = "0.2.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index 15c7b17..a319669 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,7 +63,7 @@ fn auto_run(running: Arc) { Ok(()) => return, Err(BackendError::NotSupported) => (), Err(e) => { - log::error!("{}", e); + log::error!("{}", e.to_string()); return; } }; @@ -76,7 +76,7 @@ fn auto_run(running: Arc) { Ok(()) => return, Err(BackendError::NotSupported) => (), Err(e) => { - log::error!("{}", e); + log::error!("{}", e.to_string()); return; } }; diff --git a/src/overlays/screen.rs b/src/overlays/screen.rs index 1e22494..2acd66f 100644 --- a/src/overlays/screen.rs +++ b/src/overlays/screen.rs @@ -28,6 +28,7 @@ use { pipewire::{pipewire_select_screen, PipewireCapture}, wayland::{WlxClient, WlxOutput}, wlr_dmabuf::WlrDmabufCapture, + wlr_screencopy::WlrScreencopyCapture, }, }; @@ -254,7 +255,7 @@ impl ScreenRenderer { } #[cfg(feature = "wayland")] - pub fn new_wlr(output: &WlxOutput) -> Option { + pub fn new_wlr_dmabuf(output: &WlxOutput) -> Option { let client = WlxClient::new()?; let capture = WlrDmabufCapture::new(client, output.id); @@ -267,6 +268,20 @@ impl ScreenRenderer { }) } + #[cfg(feature = "wayland")] + pub fn new_wlr_screencopy(output: &WlxOutput) -> Option { + 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")] pub fn new_pw( output: &WlxOutput, @@ -313,7 +328,8 @@ impl OverlayRenderer for ScreenRenderer { } fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> { 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 graphics = app.graphics.clone(); @@ -492,9 +508,16 @@ where let mut capture: Option = 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); - 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() {