1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Latchshot is a lightweight yet intelligent window-aware screenshot tool.
//!
//! Latchshot keeps scene discovery, frame capture, interactive selection, and
//! image output as separate steps. Applications can use the complete built-in
//! flow or replace individual steps through [`SceneReader`], [`FrameCapture`],
//! and [`Selector`].
//!
//! # Interactive screenshot
//!
//! Capture the desktop before opening the overlay so the selection is made
//! against a frozen frame. The frame returned by [`overlay::select`] is the
//! same frame to which the selected logical geometry refers.
//!
//! ```no_run
//! use anyhow::Result;
//! use latchshot::output::{Target, write_to_targets};
//! use latchshot::overlay::select;
//! use latchshot::{Compositor, FrameCapture, Selection, SelectionResult, WaylandCapture};
//!
//! fn main() -> Result<()> {
//! let compositor = Compositor::detect().unwrap_or(Compositor::Generic);
//! let mut compositor = compositor.connect()?;
//! let mut scene = compositor.scene()?;
//!
//! let mut capture = WaylandCapture::connect()?;
//! let frame = capture.capture(&scene)?;
//! compositor.refine_scene(&mut scene, &frame)?;
//!
//! let (result, frame) = select(scene, frame, true)?;
//! let selection = match result {
//! SelectionResult::Selected(selection) => selection,
//! SelectionResult::Cancelled => return Ok(()),
//! };
//! let region = match selection {
//! Selection::Window(region) | Selection::Region(region) => region,
//! };
//!
//! write_to_targets(
//! &frame.crop(region),
//! &[Target::File("screenshot.png".into())],
//! )?;
//! Ok(())
//! }
//! ```
//!
//! For a custom frontend, drive [`Selector`] with pointer events and use
//! [`DesktopFrame::crop`] once it returns a [`SelectionResult`].
pub use AnimatedRect;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub