Session#

class Session(**properties: Any)#

Superclasses: Object

A representation of long-lived screencast portal interactions.

The XdpSession object is used to represent portal interactions with the screencast or remote desktop portals that extend over multiple portal calls.

To find out what kind of session an XdpSession object represents and whether it is still active, you can use get_session_type and get_session_state.

All sessions start in an initial state. They can be made active by calling start, and ended by calling close.

Methods#

class Session
close() None#

Closes the session.

connect_to_eis() int#

Connect this XdpRemoteDesktopSession to an EIS implementation and return the fd. This fd can be passed into ei_setup_backend_fd(). See the libei documentation for details.

This call must be issued before start(). If successful, all input event emulation must be handled via the EIS connection and calls to pointer_motion() etc. are silently ignored.

get_devices() DeviceType#

Obtains the devices that the user selected.

Unless the session is active, this function returns XDP_DEVICE_NONE.

get_persist_mode() PersistMode#

Retrieves the effective persist mode of session.

May only be called after session is successfully started, i.e. after start_finish.

get_restore_token() str | None#

Retrieves the restore token of session.

A restore token will only be available if XDP_PERSIST_MODE_TRANSIENT or XDP_PERSIST_MODE_PERSISTENT was passed when creating the screencast session.

Remote desktop sessions cannot be restored.

May only be called after session is successfully started, i.e. after start_finish.

get_selection_mime_types() list[str]#

Get the currently advertised mime types of the current clipboard selection owner.

get_session_state() SessionState#

Obtains information about the state of the session that is represented by session.

get_session_type() SessionType#

Obtains information about the type of session that is represented by session.

get_streams() Variant#

Obtains the streams that the user selected.

The information in the returned Variant has the format a(ua{sv}). Each item in the array is describing a stream. The first member is the pipewire node ID, the second is a dictionary of stream properties, including:

  • position, (ii): a tuple consisting of the position (x, y) in the compositor

    coordinate space. Note that the position may not be equivalent to a position in a pixel coordinate space. Only available for monitor streams.

  • size, (ii): a tuple consisting of (width, height). The size represents the size

    of the stream as it is displayed in the compositor coordinate space. Note that this size may not be equivalent to a size in a pixel coordinate space. The size may differ from the size of the stream.

Unless the session is active, this function returns NULL.

is_clipboard_enabled() bool#

Returns TRUE if the session has enabled clipboard integration.

is_selection_owned_by_session() bool#

Return TRUE if the most recently received clipboard selection owner is the selection of this session.

keyboard_key(keysym: bool, key: int, state: KeyState) None#

Changes the state of the key to state.

May only be called on a remote desktop session with XDP_DEVICE_KEYBOARD access.

Parameters:
  • keysym – whether to interpret key as a keysym instead of a keycode

  • key – the keysym or keycode to change

  • state – the new state

open_pipewire_remote() int#

Opens a file descriptor to the pipewire remote where the screencast streams are available.

The file descriptor should be used to create a pw_remote object, by using pw_remote_connect_fd(). Only the screencast stream nodes will be available from this pipewire node.

pointer_axis(finish: bool, dx: float, dy: float) None#

The axis movement from a smooth scroll device, such as a touchpad. When applicable, the size of the motion delta should be equivalent to the motion vector of a pointer motion done using the same advice.

May only be called on a remote desktop session with XDP_DEVICE_POINTER access.

Parameters:
  • finish – whether this is the last in a series of related events

  • dx – relative axis movement on the X axis

  • dy – relative axis movement on the Y axis

pointer_axis_discrete(axis: DiscreteAxis, steps: int) None#

The axis movement from a discrete scroll device.

May only be called on a remote desktop session with XDP_DEVICE_POINTER access.

Parameters:
  • axis – the axis to change

  • steps – number of steps scrolled

pointer_button(button: int, state: ButtonState) None#

Changes the state of the button to state.

May only be called on a remote desktop session with XDP_DEVICE_POINTER access.

Parameters:
  • button – the button

  • state – the new state

pointer_motion(dx: float, dy: float) None#

Moves the pointer from its current position.

May only be called on a remote desktop session with XDP_DEVICE_POINTER access.

Parameters:
  • dx – relative horizontal movement

  • dy – relative vertical movement

pointer_position(stream: int, x: float, y: float) None#

Moves the pointer to a new position in the given streams logical coordinate space.

May only be called on a remote desktop session with XDP_DEVICE_POINTER access.

Parameters:
  • stream – the node ID of the pipewire stream the position is relative to

  • x – new X position

  • y – new Y position

request_clipboard() None#

Requests clipboard integration on the session.

selection_read(mime_type: str) int#

Request to read the contents of the current clipboard selection in the passed mime type format. On success a file descriptor is returned, which can be read from to retrieve the clipboard selection content.

Parameters:

mime_type – a string containing the requested mime type

selection_write(serial: int) int#

Retrieve a file descriptor to write the content of the clipboard selection to. The content should be formatted according to the mime type of the mime type passed via the selection_transfer that carried the passed serial number.

Parameters:

serial – a serial number

selection_write_done(serial: int, success: bool) None#

Notify whether a clipboard selection write operation associated with the passed serial was successful or not.

Parameters:
  • serial – a serial number

  • success – TRUE if the transfer was successful

set_selection(mime_types: str) None#

Set the clipboard selection to advertise support for the passed list of mime types.

When some entity in the windowing system requests to retrieve the contents of the selection, the selection_transfer signal is emitted. In response to this, the caller of this function must respond by calling selection_write with the serial number passed via the mentioned signal.

Parameters:

mime_types – A NULL terminated array of mime type strings.

async start(self, parent: Parent | None = None) bool#

This is the awaitable version of start().

Parameters:

parent – parent window information

start(parent: Parent | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, data: Any = None) None#

Starts the session.

When the request is done, callback will be called. You can then call start_finish to get the results.

Parameters:
  • parent – parent window information

  • cancellable – optional Cancellable

  • callback – a callback to call when the request is done

  • data – data to pass to callback

start_finish(result: AsyncResult) bool#

Finishes the session-start request.

Parameters:

result – a AsyncResult

touch_down(stream: int, slot: int, x: float, y: float) None#

Notify about a new touch down event.

The (x, y) position represents the new touch point position in the streams logical coordinate space.

May only be called on a remote desktop session with XDP_DEVICE_TOUCHSCREEN access.

Parameters:
  • stream – the node ID of the pipewire stream the position is relative to

  • slot – touch slot where the touch point appeared

  • x – new X position

  • y – new Y position

touch_position(stream: int, slot: int, x: float, y: float) None#

Notify about a new touch motion event.

The (x, y) position represents where the touch point position in the streams logical coordinate space moved.

May only be called on a remote desktop session with XDP_DEVICE_TOUCHSCREEN access.

Parameters:
  • stream – the node ID of the pipewire stream the position is relative to

  • slot – touch slot that is changing position

  • x – new X position

  • y – new Y position

touch_up(slot: int) None#

Notify about a new touch up event.

May only be called on a remote desktop session with XDP_DEVICE_TOUCHSCREEN access.

Parameters:

slot – touch slot that changed

Signals#

class Session.signals
closed() None#

Emitted when a session is closed externally.

selection_owner_changed(object: list[str], p0: bool) None#
Parameters:
  • object

  • p0

selection_transfer(object: str, p0: int) None#
Parameters:
  • object

  • p0