pub struct WayshotConnection {
pub conn: Connection,
pub globals: GlobalList,
/* private fields */
}Expand description
Fields§
§conn: Connection§globals: GlobalListImplementations§
Source§impl WayshotConnection
impl WayshotConnection
pub fn new() -> Result<Self>
Sourcepub fn from_connection(conn: Connection) -> Result<Self>
pub fn from_connection(conn: Connection) -> Result<Self>
Recommended if you already have a wayland_client::Connection.
Sourcepub fn from_connection_with_dmabuf(
conn: Connection,
device_path: &str,
) -> Result<Self>
pub fn from_connection_with_dmabuf( conn: Connection, device_path: &str, ) -> Result<Self>
Create a WayshotConnection struct having DMA-BUF support Using this connection is required to make use of the dmabuf functions
§Parameters
- conn: a Wayland connection
- device_path: string pointing to the DRI device that is to be used for creating the DMA-BUFs on. For example: “/dev/dri/renderD128”
Sourcepub fn get_all_outputs(&self) -> &[OutputInfo]
pub fn get_all_outputs(&self) -> &[OutputInfo]
Fetch all accessible wayland outputs.
Sourcepub fn refresh_outputs(&mut self) -> Result<()>
pub fn refresh_outputs(&mut self) -> Result<()>
refresh the outputs, to get new outputs
Sourcepub fn capture_output_frame_shm_fd<T: AsFd>(
&self,
cursor_overlay: i32,
output: &WlOutput,
fd: T,
capture_region: Option<EmbeddedRegion>,
) -> Result<(FrameFormat, FrameGuard)>
pub fn capture_output_frame_shm_fd<T: AsFd>( &self, cursor_overlay: i32, output: &WlOutput, fd: T, capture_region: Option<EmbeddedRegion>, ) -> Result<(FrameFormat, FrameGuard)>
Get a FrameCopy instance with screenshot pixel data for any wl_output object. Data will be written to fd.
Sourcepub unsafe fn bind_output_frame_to_gl_texture(
&self,
cursor_overlay: bool,
output: &WlOutput,
capture_region: Option<EmbeddedRegion>,
) -> Result<()>
pub unsafe fn bind_output_frame_to_gl_texture( &self, cursor_overlay: bool, output: &WlOutput, capture_region: Option<EmbeddedRegion>, ) -> Result<()>
§Safety
Helper function/wrapper that uses the OpenGL extension OES_EGL_image to convert the EGLImage obtained from WayshotConnection::capture_output_frame_eglimage
into a OpenGL texture.
- The caller is supposed to setup everything required for the texture binding. An example call may look like:
gl::BindTexture(gl::TEXTURE_2D, self.gl_texture);
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::LINEAR as i32);
wayshot_conn
.bind_output_frame_to_gl_texture(
true,
&wayshot_conn.get_all_outputs()[0].wl_output,
None)§Parameters
cursor_overlay: A boolean flag indicating whether the cursor should be included in the capture.output: Reference to theWlOutputfrom which the frame is to be captured.capture_region: Optional region specifying a sub-area of the output to capture. IfNone, the entire output is captured.
§Returns
- If the function was found and called, an OK(()), note that this does not necessarily mean that binding was successful, only that the function was called. The caller may check for any OpenGL errors using the standard routes.
- If the function was not found,
Error::EGLImageToTexProcNotFoundErroris returned
Sourcepub fn capture_output_frame_eglimage<'a, T: EGL1_5>(
&self,
egl_instance: &'a Instance<T>,
cursor_overlay: bool,
output: &WlOutput,
capture_region: Option<EmbeddedRegion>,
) -> Result<EGLImageGuard<'a, T>>
pub fn capture_output_frame_eglimage<'a, T: EGL1_5>( &self, egl_instance: &'a Instance<T>, cursor_overlay: bool, output: &WlOutput, capture_region: Option<EmbeddedRegion>, ) -> Result<EGLImageGuard<'a, T>>
Obtain a screencapture in the form of a EGLImage.
The display on which this image is created is obtained from the Wayland Connection.
Uses the dma-buf provisions of the wlr-screencopy copy protocol to avoid VRAM->RAM copies
It returns the captured frame as an EGLImage, wrapped in an EGLImageGuard
for safe handling and cleanup.
§Parameters
egl_instance: Reference to an egl API instance obtained from the khronos_egl crate, which is used to create theEGLImage.cursor_overlay: A boolean flag indicating whether the cursor should be included in the capture.output: Reference to theWlOutputfrom which the frame is to be captured.capture_region: Optional region specifying a sub-area of the output to capture. IfNone, the entire output is captured.
§Returns
If successful, an EGLImageGuard which contains a pointer ‘image’ to the created EGLImage On error, the EGL error code is returned via this crates Error type
Sourcepub fn capture_output_frame_eglimage_on_display<'a, T: EGL1_5>(
&self,
egl_instance: &'a Instance<T>,
egl_display: Display,
cursor_overlay: bool,
output: &WlOutput,
capture_region: Option<EmbeddedRegion>,
) -> Result<EGLImageGuard<'a, T>>
pub fn capture_output_frame_eglimage_on_display<'a, T: EGL1_5>( &self, egl_instance: &'a Instance<T>, egl_display: Display, cursor_overlay: bool, output: &WlOutput, capture_region: Option<EmbeddedRegion>, ) -> Result<EGLImageGuard<'a, T>>
Obtain a screencapture in the form of a EGLImage on the given EGLDisplay.
Uses the dma-buf provisions of the wlr-screencopy copy protocol to avoid VRAM->RAM copies
It returns the captured frame as an EGLImage, wrapped in an EGLImageGuard
for safe handling and cleanup.
§Parameters
egl_instance: Reference to anEGL1_5instance, which is used to create theEGLImage.egl_display: TheEGLDisplayon which the image should be created.cursor_overlay: A boolean flag indicating whether the cursor should be included in the capture.output: Reference to theWlOutputfrom which the frame is to be captured.capture_region: Optional region specifying a sub-area of the output to capture. IfNone, the entire output is captured.
§Returns
If successful, an EGLImageGuard which contains a pointer ‘image’ to the created EGLImage On error, the EGL error code is returned via this crates Error type
Sourcepub fn capture_output_frame_dmabuf(
&self,
cursor_overlay: bool,
output: &WlOutput,
capture_region: Option<EmbeddedRegion>,
) -> Result<(DMAFrameFormat, DMAFrameGuard, BufferObject<()>)>
pub fn capture_output_frame_dmabuf( &self, cursor_overlay: bool, output: &WlOutput, capture_region: Option<EmbeddedRegion>, ) -> Result<(DMAFrameFormat, DMAFrameGuard, BufferObject<()>)>
Obtain a screencapture in the form of a WlBuffer backed by a GBM Bufferobject on the GPU.
Uses the dma-buf provisions of the wlr-screencopy copy protocol to avoid VRAM->RAM copies
The captured frame is returned as a tuple containing the frame format, a guard to manage
the WlBuffer’s cleanup on drop, and the underlying BufferObject.
cursor_overlay: A boolean flag indicating whether the cursor should be included in the capture.output: Reference to theWlOutputfrom which the frame is to be captured.capture_region: Optional region specifying a sub-area of the output to capture. IfNone, the entire output is captured.
§Returns
On success, returns a tuple containing the frame format,
a guard to manage the frame’s lifecycle, and the GPU-backed BufferObject.
§Errors
- Returns
NoDMAStateErrorif the DMA-BUF state is not initialized a the time of initialization of this struct.
pub fn capture_output_frame_get_state_shm( &self, cursor_overlay: i32, output: &WlOutput, capture_region: Option<EmbeddedRegion>, ) -> Result<(CaptureFrameState, EventQueue<CaptureFrameState>, ZwlrScreencopyFrameV1, FrameFormat)>
pub fn capture_frame_copies( &self, output_capture_regions: &[(OutputInfo, Option<EmbeddedRegion>)], cursor_overlay: bool, ) -> Result<Vec<(FrameCopy, FrameGuard, OutputInfo)>>
Sourcepub fn screenshot(
&self,
capture_region: LogicalRegion,
cursor_overlay: bool,
) -> Result<DynamicImage>
pub fn screenshot( &self, capture_region: LogicalRegion, cursor_overlay: bool, ) -> Result<DynamicImage>
Take a screenshot from the specified region.
Sourcepub fn screenshot_freeze<F>(
&self,
callback: F,
cursor_overlay: bool,
) -> Result<DynamicImage>
pub fn screenshot_freeze<F>( &self, callback: F, cursor_overlay: bool, ) -> Result<DynamicImage>
Take a screenshot, overlay the screenshot, run the callback, and then unfreeze the screenshot and return the selected region.
Sourcepub fn screenshot_single_output(
&self,
output_info: &OutputInfo,
cursor_overlay: bool,
) -> Result<DynamicImage>
pub fn screenshot_single_output( &self, output_info: &OutputInfo, cursor_overlay: bool, ) -> Result<DynamicImage>
Take a screenshot from one output
Sourcepub fn screenshot_outputs(
&self,
outputs: &[OutputInfo],
cursor_overlay: bool,
) -> Result<DynamicImage>
pub fn screenshot_outputs( &self, outputs: &[OutputInfo], cursor_overlay: bool, ) -> Result<DynamicImage>
Take a screenshot from all of the specified outputs.
Sourcepub fn screenshot_all(&self, cursor_overlay: bool) -> Result<DynamicImage>
pub fn screenshot_all(&self, cursor_overlay: bool) -> Result<DynamicImage>
Take a screenshot from all accessible outputs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WayshotConnection
impl !RefUnwindSafe for WayshotConnection
impl Send for WayshotConnection
impl Sync for WayshotConnection
impl Unpin for WayshotConnection
impl !UnwindSafe for WayshotConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.