Session
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
-
- 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 topointer_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. afterstart_finish
.
- get_restore_token() str | None
Retrieves the restore token of
session
.A restore token will only be available if
XDP_PERSIST_MODE_TRANSIENT
orXDP_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. afterstart_finish
.
- 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 formata(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.
- position,
- 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.
- size,
Unless the session is active, this function returns
NULL
.
- 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 keycodekey – 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
- start(parent: Parent | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *data: Any) None
Starts the session.
When the request is done,
callback
will be called. You can then callstart_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