Louvre  v2.12.0-1
C++ library for Wayland compositors
Public Member Functions | List of all members
LScreenshotRequest Class Reference

Request to capture an LOutput frame. More...

Public Member Functions

LClientclient () const noexcept
 Client requesting to take the screenshot. More...
 
const LRectrect () const noexcept
 Rect within the output requested to be captured. More...
 
void accept (bool accept) noexcept
 Respond to the screenshot request. More...
 
Protocols::ScreenCopy::RScreenCopyFrame & resource () const noexcept
 Wayland resource associated with the screenshot request. More...
 

Detailed Description

Request to capture an LOutput frame.

Clients using the Wlr Screencopy protocol can request to capture a specific region of an LOutput.

The LScreenshotRequest class represents a single frame wanted to be captured, and must be handled within an LOutput::paintGL() event.
This means that for screencasting, clients make a new LScreenshotRequest for each paintGL event.
If a request is accepted within a paintGL event, Louvre later copies the rendered frame to the client's buffer.

Note
All requests are initially denied unless accept(true) is called and no custom buffer is set for direct scanout (see LOutput::setCustomScanoutBuffer()).

Within a paintGL event, the LOutput::screenshotRequests() vector contains the requests made for the current frame being rendered, which can be more than one if multiple clients are requesting to capture it.

Note
It's recommended to use LCompositor::globalsFilter() to permit only a single well-known client to use this protocol, such as the xdg-desktop-portal-wlr.

Member Function Documentation

◆ client()

LClient * client ( ) const
noexcept

Client requesting to take the screenshot.

◆ rect()

const LRect & rect ( ) const
noexcept

Rect within the output requested to be captured.

Coordinates are in surface coordinates relative to the output's position.

◆ accept()

void accept ( bool  accept)
noexcept

Respond to the screenshot request.

Parameters
acceptBoolean value indicating whether to allow the capture (true) or deny it (false). It can be called multiple times with different responses, but only the last one before LOutput::paintGL() finishes is considered. If never called within LOutput::paintGL(), the capture is denied.
Note
Only call this method within a LOutput::paintGL() event.

◆ resource()

Protocols::ScreenCopy::RScreenCopyFrame& resource ( ) const
inlinenoexcept

Wayland resource associated with the screenshot request.