:right-sidebar: True Session =================================================================== .. currentmodule:: gi.repository.Xdp .. class:: Session(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.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 :obj:`~gi.repository.Session.get_session_type` and :obj:`~gi.repository.Session.get_session_state`\. All sessions start in an initial state. They can be made active by calling :obj:`~gi.repository.Session.start`\, and ended by calling :obj:`~gi.repository.Session.close`\. Methods ------- .. rst-class:: interim-class .. class:: Session :no-index: .. method:: close() -> None Closes the session. .. method:: 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 :func:`~gi.repository.Xdp.Session.start`. If successful, all input event emulation must be handled via the EIS connection and calls to :func:`~gi.repository.Xdp.Session.pointer_motion` etc. are silently ignored. .. method:: get_devices() -> ~gi.repository.Xdp.DeviceType Obtains the devices that the user selected. Unless the session is active, this function returns ``XDP_DEVICE_NONE``\. .. method:: get_persist_mode() -> ~gi.repository.Xdp.PersistMode Retrieves the effective persist mode of ``session``\. May only be called after ``session`` is successfully started, i.e. after :obj:`~gi.repository.Session.start_finish`\. .. method:: 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 :obj:`~gi.repository.Session.start_finish`\. .. method:: get_session_state() -> ~gi.repository.Xdp.SessionState Obtains information about the state of the session that is represented by ``session``\. .. method:: get_session_type() -> ~gi.repository.Xdp.SessionType Obtains information about the type of session that is represented by ``session``\. .. method:: get_streams() -> ~gi.repository.GLib.Variant Obtains the streams that the user selected. The information in the returned :obj:`~gi.repository.GLib.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``\. .. method:: keyboard_key(keysym: bool, key: int, state: ~gi.repository.Xdp.KeyState) -> None Changes the state of the key to ``state``\. May only be called on a remote desktop session with ``XDP_DEVICE_KEYBOARD`` access. :param keysym: whether to interpret ``key`` as a keysym instead of a keycode :param key: the keysym or keycode to change :param state: the new state .. method:: 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. .. method:: 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. :param finish: whether this is the last in a series of related events :param dx: relative axis movement on the X axis :param dy: relative axis movement on the Y axis .. method:: pointer_axis_discrete(axis: ~gi.repository.Xdp.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. :param axis: the axis to change :param steps: number of steps scrolled .. method:: pointer_button(button: int, state: ~gi.repository.Xdp.ButtonState) -> None Changes the state of the button to ``state``\. May only be called on a remote desktop session with ``XDP_DEVICE_POINTER`` access. :param button: the button :param state: the new state .. method:: 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. :param dx: relative horizontal movement :param dy: relative vertical movement .. method:: 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. :param stream: the node ID of the pipewire stream the position is relative to :param x: new X position :param y: new Y position .. method:: start(parent: ~gi.repository.Xdp.Parent | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, data: ~typing.Any = None) -> None Starts the session. When the request is done, ``callback`` will be called. You can then call :obj:`~gi.repository.Session.start_finish` to get the results. :param parent: parent window information :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` :param callback: a callback to call when the request is done :param data: data to pass to ``callback`` .. method:: start_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes the session-start request. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: 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. :param stream: the node ID of the pipewire stream the position is relative to :param slot: touch slot where the touch point appeared :param x: new X position :param y: new Y position .. method:: 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. :param stream: the node ID of the pipewire stream the position is relative to :param slot: touch slot that is changing position :param x: new X position :param y: new Y position .. method:: 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. :param slot: touch slot that changed Signals ------- .. rst-class:: interim-class .. class:: Session.signals :no-index: .. method:: closed() -> None The type of the None singleton.