Documentation
¶
Overview ¶
Package sharepreview is the capture half of wayle-share-preview on top of lys-lib's capture package: turning captured frames into images (the output-transform correction, the preview downscale) and the XDPH window list the share picker reads.
Index ¶
- func FrameImage(f *capture.Frame, t capture.Transform) (*image.RGBA, error)
- func Resize(src *image.RGBA, w, h int) *image.RGBA
- func ResizeToFit(src *image.RGBA, size int) *image.RGBA
- func Transform(img *image.RGBA, t capture.Transform) *image.RGBA
- func TransformInto(dst, src *image.RGBA, t capture.Transform)
- func TransformedSize(w, h int, t capture.Transform) (int, int)
- func WindowThumb(tl Toplevel, size int) (*image.RGBA, error)
- type Toplevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FrameImage ¶
FrameImage converts a captured frame to an image and applies the output transform, the Image::new → into_rgb → transform chain of image.rs. Frames without alpha come out opaque.
func Resize ¶
Resize scales the image to w x h with a triangle (bilinear) filter, image's FilterType::Triangle.
func ResizeToFit ¶
ResizeToFit downscales the image so its smaller dimension is at most size, keeping the aspect ratio - image.rs's resize_to_fit, including its quirks: a portrait image scales when its width exceeds size, a landscape one when its height does, and a square image never scales.
func Transform ¶
Transform applies an output transform to a captured frame the way image.rs's Image::transform does: the 90/270 variants rotate clockwise (image's rotate90/rotate270), and the flipped variants flip vertically first. TransformNormal returns img itself.
func TransformInto ¶
TransformInto writes src with t applied into dst, for a caller that owns dst's memory; dst has src's TransformedSize.
func TransformedSize ¶
TransformedSize is the size of a w x h frame once t is applied.
func WindowThumb ¶
WindowThumb captures a window preview: Hyprland's toplevel-export when XDPH sent the address, otherwise (or when that fails) the ext path matched by class and title. The frame is converted without an output transform and downscaled to size.
Types ¶
type Toplevel ¶
type Toplevel struct {
// ID is the XDPH toplevel id - its own wlr-foreign-toplevel resource
// id, which only XDPH resolves - or a display-only index for
// fallback entries.
ID uint64
// Class and Title are the window's class (app id) and title.
Class, Title string
// WindowAddress is the Hyprland window address when XDPH sent one
// ([HA>]); zero with HasAddress false otherwise.
WindowAddress uint64
HasAddress bool
// Identifier is the stable ext-foreign-toplevel-list identifier of a
// fallback entry, empty for XDPH entries (which use ID).
Identifier string
}
Toplevel is one shareable window (toplevel.rs): an entry of the XDPH_WINDOW_SHARING_LIST xdg-desktop-portal-hyprland hands the share picker, or of the generic ext-foreign-toplevel-list fallback.
func ParseList ¶
ParseList parses an XDPH_WINDOW_SHARING_LIST value (`<id>[HC>]<class>[HT>]<title>[HE>]<address>[HA>]...`, see XDPH's ScreencopyShared.cpp). The address field is optional for older Hyprland releases. Parsing stops at the first malformed entry, keeping what came before, and logs why - toplevel.rs's behavior, including its reading of separators from the start of the remaining text.