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
11 changes: 5 additions & 6 deletions libwayshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Fn() -> Result<LogicalRegion>>,
cursor_overlay: bool,
) -> Result<DynamicImage> {
self.screenshot_region_capturer(RegionCapturer::Freeze(callback), cursor_overlay)
pub fn screenshot_freeze<F>(&self, callback: F, cursor_overlay: bool) -> Result<DynamicImage>
where
F: Fn() -> Result<LogicalRegion> + 'static,
{
self.screenshot_region_capturer(RegionCapturer::Freeze(Box::new(callback)), cursor_overlay)
}

/// Take a screenshot from one output
Expand Down
4 changes: 2 additions & 2 deletions wayshot/src/wayshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogicalRegion> {
let slurp_output = Command::new("slurp")
.args(slurp_region.split(' '))
Expand All @@ -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 {
Expand Down