COSMIC screencopy v1

screen content capturing on client buffers

This protocol allows clients to ask the compositor to copy part of the screen content to a client buffer.

Warning! The protocol described in this file is experimental and backward incompatible changes may be made. Backward compatible changes may be added together with the corresponding interface version bump. Backward incompatible changes are done by bumping the version number in the protocol and interface names and resetting the interface version. Once the protocol is to be declared stable, the 'z' prefix and the version number in the protocol and interface names are removed and the interface version number is reset.

manager to inform clients and begin capturing

This object is a manager which offers requests to start capturing from a source.

capture an output

Create a capturing session for an output.

It is a protocol error to request a cursor mode that was not previously advertised by the compositor (see `supported_cursor_mode` event).

capture a workspace

Create a capturing session for an entire workspace.

An output must be provided that has previously been associated with the given workspace through an `output_enter` event (see cosmic-workspace-unstable-v1).

If the provided output is not associated with the workspace at the time this request is send, the capture will failed with `invalid_output` until a new association is established.

It is a protocol error to request a cursor mode that was not previously advertised by the compositor (see `supported_cursor_mode` event).

capture an output

Create a capturing session for a toplevel.

It is a protocol error to request a cursor mode that was not previously advertised by the compositor (see `supported_cursor_mode` event).

supported_cursor_mode(mode: uint<zcosmic_screencopy_manager_v1.cursor_mode>)
Advertised supported cursor modes

Immediately after initialization of the zcosmic_screencopy_manager_v1 global, it will send supported_cursor_mode events to notify the client about supported cursor modes.

Argument
Value
Description
invalid_cursor_mode0
the provided cursor mode is not supported
cursor_mode { hidden, embedded, capture } 
Argument
Value
Description
hidden0
cursor is hidden

Cursors are not rendered and its contents won't be send by the compositor in any form.

embedded1
cursor is rendered embedded

Cursors are rendered and embedded into the captured buffer.

capture2
cursor is rendered separately

Cursors are not rendered, but can be received an additional buffers using the `capture_cursor` request of the `zcosmic_screencopy_session_v1` interface.


a capture session

This object represents a session that's being captured.

After a screencopy session is created, buffer_info events will be emitted from the compositor to tell the client which buffer types and formats are supported for reading from the surface.

When the client knows all the buffer attributes, it can create a buffer, attach it to the screencopy surface using the "attach_buffer" request, set the buffer damage using the "damage_buffer" request and then call the "commit" request.

After "commit" has been called, the next time that a buffer is committed by the compositor, the contents of that buffer will be copied to the one committed to the screencopy session. A series of events will be generated, ending with the "ready" event, which means that the buffer is ready to be used and a buffer may be committed to the surface again.

The "failed" event may be sent at any time. When this happens, the client must destroy the session. Depending on the failure reason, the client can create a new session to replace it.

capture_cursor(session: new_id<zcosmic_screencopy_session_v1>, seat: object<wl_seat>)
Argument
Type
Description
sessionnew_id<zcosmic_screencopy_session_v1>
seatobject<wl_seat>
create sub-session to capture cursor

Creates a sub-session used to capture the cursor of a given seat. Using this request, when the server did not indicate support through a `supported_cursor_mode` event with the value `capture` is a protocol error.

The sub-session will not generate cursor_enter or cursor_leave events. It will generate a single cursor_info event for the captured seat, if the cursor previously entered the session, or no cursor_info event. The event will be identical to the matching cursor_info event generated on the main session.

The buffer_info provided by the compositor can be different to the supported buffers for the main session and can also be different for each captured seat.

Sub-session will never send a `commit_time` or `ready` event, but are considered ready and displayed in tandem with their main-session.

attach_buffer(buffer: object<wl_buffer>, node: string, age: uint)
Argument
Type
Description
bufferobject<wl_buffer>
nodestringallow null
device node
ageuint
attach buffer to surface

Attach a buffer to the surface.

commit session

Commit the screencopy session.

The frame will be copied to the session. A ready event is generated when the buffer is ready.

If the "on_damage" flag is set, the compositor should wait sending new frames to the client until there is damage.

destroy()
delete this object

Destroys the surface. This request can be sent at any time by the client.

buffer_info(type: uint<zcosmic_screencopy_session_v1.buffer_type>, node: string, format: uint, width: uint, height: uint, stride: uint)
Argument
Type
Description
typeuint<zcosmic_screencopy_session_v1.buffer_type>
buffer type
nodestringallow null
device node
formatuint
buffer drm format
widthuint
buffer width
heightuint
buffer height
strideuint
buffer stride
buffer information

Provides information about buffer parameters that need to be used for the main image. This event is sent for every supported buffer type after the session is created.

The stride parameter is invalid for dmabuf and may be set to 0.

init_done()
session initialisation done

This event is sent once when all buffer info events have been sent.

Argument
Type
Description
transformint<wl_output.transform>
carries the transform

This event is sent before the ready event and holds transformations of the source buffer.

damage(x: uint, y: uint, width: uint, height: uint)
Argument
Type
Description
xuint
damaged x coordinates
yuint
damaged y coordinates
widthuint
current width
heightuint
current height
carries the coordinates of the damaged region

This event is sent before the ready event. It may be generated multiple times for each commit.

The arguments describe a box around an area that has changed since the last ready event.

These coordinates originate in the upper left corner of the buffer.

Argument
Type
Description
seatobject<wl_seat>
input_typeuint<zcosmic_screencopy_session_v1.input_type>
input type
cursor entered surface

Sent when a cursor enters the captured surface. It shall be generated before the "cursor_info" event when and only when a cursor enters the surface.

Argument
Type
Description
seatobject<wl_seat>
input_typeuint<zcosmic_screencopy_session_v1.input_type>
input type
cursor left surface

Sent when a cursor leaves the captured surface. No "cursor_info" event is generated for for the given cursor.

cursor_info(seat: object<wl_seat>, input_type: uint<zcosmic_screencopy_session_v1.input_type>, position_x: int, position_y: int, width: int, height: int, hotspot_x: int, hotspot_y: int)
Argument
Type
Description
seatobject<wl_seat>
input_typeuint<zcosmic_screencopy_session_v1.input_type>
position_xint
position x coordinates
position_yint
position y coordinates
widthint
width of the cursor image
heightint
height of the cursor image
hotspot_xint
hotspot x coordinates
hotspot_yint
hotspot y coordinates
cursor specific information

This event is generated for each cursor buffer that was attached to the session and for which the cursor is currently focused in the session. It is generated once for each cursor buffer before the ready event.

Cursors outside the surface do not get captured and no event will be generated for them.

If the cursor image has changed, the cursor buffer will have been updated and the "has_damage" argument will be set to 1; otherwise 0.

The given position is the position of the cursor's hotspot and it is relative to the main buffer's top left corner in transformed buffer pixel coordinates.

The hotspot coordinates are relative to the cursor buffers upper left corner.

commit failed

This event indicates that the attempted frame copy has failed.

After receiving this event, the client must destroy the object.

commit_time(tv_sec_hi: uint, tv_sec_lo: uint, tv_nsec: uint)
Argument
Type
Description
tv_sec_hiuint
high 32 bits of the seconds part of the timestamp
tv_sec_louint
low 32 bits of the seconds part of the timestamp
tv_nsecuint
nanoseconds part of the timestamp
indicates the commit time of the frame

This event indicates the time at which the frame is committed to be scanned out in system monotonic time.

The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples, each component being an unsigned 32-bit value. Whole seconds are in tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo, and the additional fractional part in tv_nsec as nanoseconds. Hence, for valid timestamps tv_nsec must be in [0, 999999999].

ready()
indicates frame is available for reading

Called as soon as the frame is copied, indicating it is available for reading.

Argument
Value
Description
invalid_cursor_mode0
the provided cursor mode is not supported
options { on_damage } 
Argument
Value
Description
on_damage1
buffer_type { wl_shm, dmabuf } 
Argument
Value
Description
wl_shm0
dmabuf1

Compositor Support

No compositor support found

Copyright © 2021-2022 Andri Yngvason Copyright © 2022 Victoria Brekenfeld

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.