COSMIC screencopy v1
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.
zcosmic_screencopy_manager_v1
This object is a manager which offers requests to start capturing from a source.
capture_output(session: new_id<zcosmic_screencopy_session_v1>, output: object<wl_output>, cursor: uint<zcosmic_screencopy_manager_v1.cursor_mode>)
Argument | Type | Description |
---|---|---|
session | new_id<zcosmic_screencopy_session_v1> | |
output | object<wl_output> | |
cursor | uint<zcosmic_screencopy_manager_v1.cursor_mode> |
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_workspace(session: new_id<zcosmic_screencopy_session_v1>, workspace: object<zcosmic_workspace_handle_v1>, output: object<wl_output>, cursor: uint<zcosmic_screencopy_manager_v1.cursor_mode>)
Argument | Type | Description |
---|---|---|
session | new_id<zcosmic_screencopy_session_v1> | |
workspace | object<zcosmic_workspace_handle_v1> | |
output | object<wl_output> | |
cursor | uint<zcosmic_screencopy_manager_v1.cursor_mode> |
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_toplevel(session: new_id<zcosmic_screencopy_session_v1>, toplevel: object<zcosmic_toplevel_handle_v1>, cursor: uint<zcosmic_screencopy_manager_v1.cursor_mode>)
Argument | Type | Description |
---|---|---|
session | new_id<zcosmic_screencopy_session_v1> | |
toplevel | object<zcosmic_toplevel_handle_v1> | |
cursor | uint<zcosmic_screencopy_manager_v1.cursor_mode> |
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>)
Argument | Type | Description |
---|---|---|
mode | uint<zcosmic_screencopy_manager_v1.cursor_mode> |
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.
error { invalid_cursor_mode }
Argument | Value | Description |
---|---|---|
invalid_cursor_mode | 0 | the provided cursor mode is not supported |
Argument | Value | Description |
---|---|---|
embedded | 1 | cursor is rendered embedded Cursors are rendered and embedded into the captured buffer. |
capture | 2 | 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. |
zcosmic_screencopy_session_v1
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 |
---|---|---|
session | new_id<zcosmic_screencopy_session_v1> | |
seat | object<wl_seat> |
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 a buffer to the surface.
commit(options: uint<zcosmic_screencopy_session_v1.options>)
Argument | Type | Description |
---|---|---|
options | uint<zcosmic_screencopy_session_v1.options> |
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()
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 |
---|---|---|
type | uint<zcosmic_screencopy_session_v1.buffer_type> | buffer type |
node | stringallow null | device node |
format | uint | buffer drm format |
width | uint | buffer width |
height | uint | buffer height |
stride | uint | buffer stride |
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()
This event is sent once when all buffer info events have been sent.
transform(transform: int<wl_output.transform>)
Argument | Type | Description |
---|---|---|
transform | int<wl_output.transform> |
This event is sent before the ready event and holds transformations of the source buffer.
Argument | Type | Description |
---|---|---|
x | uint | damaged x coordinates |
y | uint | damaged y coordinates |
width | uint | current width |
height | uint | current height |
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.
cursor_enter(seat: object<wl_seat>, input_type: uint<zcosmic_screencopy_session_v1.input_type>)
Argument | Type | Description |
---|---|---|
seat | object<wl_seat> | |
input_type | uint<zcosmic_screencopy_session_v1.input_type> | input type |
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.
cursor_leave(seat: object<wl_seat>, input_type: uint<zcosmic_screencopy_session_v1.input_type>)
Argument | Type | Description |
---|---|---|
seat | object<wl_seat> | |
input_type | uint<zcosmic_screencopy_session_v1.input_type> | input type |
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 |
---|---|---|
seat | object<wl_seat> | |
input_type | uint<zcosmic_screencopy_session_v1.input_type> | |
position_x | int | position x coordinates |
position_y | int | position y coordinates |
width | int | width of the cursor image |
height | int | height of the cursor image |
hotspot_x | int | hotspot x coordinates |
hotspot_y | int | hotspot y coordinates |
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.
failed(reason: uint<zcosmic_screencopy_session_v1.failure_reason>)
Argument | Type | Description |
---|---|---|
reason | uint<zcosmic_screencopy_session_v1.failure_reason> |
This event indicates that the attempted frame copy has failed.
After receiving this event, the client must destroy the object.
Argument | Type | Description |
---|---|---|
tv_sec_hi | uint | high 32 bits of the seconds part of the timestamp |
tv_sec_lo | uint | low 32 bits of the seconds part of the timestamp |
tv_nsec | uint | nanoseconds part of the timestamp |
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()
Called as soon as the frame is copied, indicating it is available for reading.
error { invalid_cursor_mode }
Argument | Value | Description |
---|---|---|
invalid_cursor_mode | 0 | the provided cursor mode is not supported |
failure_reason { unspec, invalid_buffer, invalid_output, invalid_workspace, invalid_toplevel, invalid_seat, invalid_size }
Argument | Value | Description |
---|---|---|
unspec | 0 | |
invalid_buffer | 1 | |
invalid_output | 2 | |
invalid_workspace | 3 | |
invalid_toplevel | 4 | |
invalid_seat | 5 | |
invalid_size | 6 |
Compositor Support
Copyright
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.