diff --git a/libwayshot/src/lib.rs b/libwayshot/src/lib.rs index b43c8b45..989616c5 100644 --- a/libwayshot/src/lib.rs +++ b/libwayshot/src/lib.rs @@ -1065,12 +1065,11 @@ impl WayshotConnection { /// Take a screenshot, overlay the screenshot, run the callback, and then /// unfreeze the screenshot and return the selected region. - pub fn screenshot_freeze( - &self, - callback: Box Result>, - cursor_overlay: bool, - ) -> Result { - self.screenshot_region_capturer(RegionCapturer::Freeze(callback), cursor_overlay) + pub fn screenshot_freeze(&self, callback: F, cursor_overlay: bool) -> Result + where + F: Fn() -> Result + 'static, + { + self.screenshot_region_capturer(RegionCapturer::Freeze(Box::new(callback)), cursor_overlay) } /// Take a screenshot from one output diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index ca20364b..4f6638d9 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -75,7 +75,7 @@ fn main() -> Result<()> { let image_buffer = if let Some(slurp_args) = cli.slurp { let slurp_region = slurp_args.unwrap_or("".to_string()); wayshot_conn.screenshot_freeze( - Box::new(move || { + move || { || -> Result { let slurp_output = Command::new("slurp") .args(slurp_region.split(' ')) @@ -85,7 +85,7 @@ fn main() -> Result<()> { utils::parse_geometry(&String::from_utf8(slurp_output)?) }() .map_err(|_| libwayshot::Error::FreezeCallbackError) - }), + }, cli.cursor, )? } else if let Some(output_name) = cli.output {