pub struct PortalSession {Show 13 fields
conn: Connection,
screencast: Proxy<'static>,
remote: Option<Proxy<'static>>,
session: OwnedObjectPath,
pub streams: Vec<PortalStream>,
pub devices: u32,
pub cursor_mode: u32,
pub restore_token: Option<String>,
pub rd_version: u32,
kde: bool,
pub mutter: bool,
armed: bool,
notify_tx: OnceLock<Sender<(&'static str, Box<dyn FnOnce(&Proxy<'static>) + Send>)>>,
}Expand description
A started portal session: its streams, the devices it may drive, and the token that restores it without a dialog.
Fields§
§conn: Connection§screencast: Proxy<'static>§remote: Option<Proxy<'static>>§session: OwnedObjectPath§streams: Vec<PortalStream>§devices: u32§cursor_mode: u32§restore_token: Option<String>§rd_version: u32RemoteDesktop interface version, 0 when the session drives no input. ConnectToEIS
exists from version 2.
kde: boolKDE’s backend serves the session: it reads a smooth scroll’s vertical axis negated.
mutter: boolMutter’s remote-desktop service runs on the session bus, which every GNOME backend hands
input to: it reads NotifyPointerMotionAbsolute in the stream’s pixels, which
xdg-desktop-portal-gnome passes the spec’s logical point on as.
armed: boolWhether dropping the session closes it on the portal: not while open still runs it
inside its zbus::block_on, which a second one inside would panic on.
notify_tx: OnceLock<Sender<(&'static str, Box<dyn FnOnce(&Proxy<'static>) + Send>)>>The input thread’s queue, from the first Notify* call on.
Implementations§
Source§impl PortalSession
impl PortalSession
Sourcepub fn open(
capture: bool,
devices: u32,
cursor_mode: u32,
restore_token: Option<&str>,
) -> Result<Self, String>
pub fn open( capture: bool, devices: u32, cursor_mode: u32, restore_token: Option<&str>, ) -> Result<Self, String>
Open and start a session. devices (DEVICE_* bits) selects what input the session
drives — zero opens a plain ScreenCast session; capture asks for every monitor as its
own stream with cursor_mode (CURSOR_*), downgraded to what the portal offers. The
call returns once the portal (and any dialog it shows) has answered; a session the
portal created before a later step failed is closed before the error returns.
Sourceasync fn connect(devices: u32, cursor_mode: u32) -> Result<Self, String>
async fn connect(devices: u32, cursor_mode: u32) -> Result<Self, String>
The session bus and the portal interfaces a session with devices speaks to, before
any session exists.
Sourceasync fn start(
&mut self,
capture: bool,
devices: u32,
restore_token: Option<&str>,
) -> Result<(), String>
async fn start( &mut self, capture: bool, devices: u32, restore_token: Option<&str>, ) -> Result<(), String>
Create the session, select its sources and devices, and start it (open).
Sourcepub fn probe() -> Result<(), String>
pub fn probe() -> Result<(), String>
Whether a ScreenCast portal answers on the session bus; the error says which step did not, since a bus nobody listens on and a portal without a backend read the same.
Sourceasync fn request(
&self,
method: &str,
options: HashMap<&'_ str, Variant<'_>>,
call: impl AsyncFnOnce(&HashMap<&'_ str, Variant<'_>>) -> Result<OwnedObjectPath>,
) -> Result<(u32, HashMap<String, OwnedVariant>), String>
async fn request( &self, method: &str, options: HashMap<&'_ str, Variant<'_>>, call: impl AsyncFnOnce(&HashMap<&'_ str, Variant<'_>>) -> Result<OwnedObjectPath>, ) -> Result<(u32, HashMap<String, OwnedVariant>), String>
A method whose result arrives as a Response on a request object: subscribe to the
request path the handle token names before the call call makes with the completed
options, then wait for the answer.
Sourcepub fn eis_capable(&self) -> bool
pub fn eis_capable(&self) -> bool
Whether this session can hand out an EIS socket: a RemoteDesktop session (input was
granted) on a backend new enough to carry ConnectToEIS.
Sourcepub fn connect_to_eis(&self) -> Result<OwnedFd, String>
pub fn connect_to_eis(&self) -> Result<OwnedFd, String>
The EIS socket for this session’s seat. A backend that answers hands input over libei
from here on and refuses the Notify* methods, so this is called once, at open, and
only when the injector is committed to.
Sourcepub fn open_pipewire_remote(&self) -> Result<OwnedFd, String>
pub fn open_pipewire_remote(&self) -> Result<OwnedFd, String>
The PipeWire connection the streams live on, opened by the portal with the node permissions of this session.
Sourcefn notify<B>(&self, method: &'static str, args: B)
fn notify<B>(&self, method: &'static str, args: B)
Queue a Notify* call for the input thread, started by the first.
Sourcepub fn pointer_motion_abs(&self, node: u32, x: f64, y: f64)
pub fn pointer_motion_abs(&self, node: u32, x: f64, y: f64)
Absolute pointer motion in the logical coordinate space of the stream node, the size
it announced: the portal frontend refuses a point outside that size.
pub fn pointer_motion(&self, dx: f64, dy: f64)
Button by evdev code.
Sourcepub fn pointer_axis(&self, dx: f64, dy: f64, finish: bool)
pub fn pointer_axis(&self, dx: f64, dy: f64, finish: bool)
Smooth scroll by logical pixels, positive down and right as on wl_pointer; finish
closes the scroll series. KDE’s backend negates the vertical axis it is handed and drops
finish (xdg-desktop-portal-kde’s requestPointerAxis, 5.27 through master), where
GNOME’s passes both on, so it is handed the axis negated.
Sourcepub fn pointer_axis_discrete(&self, axis: u32, steps: i32)
pub fn pointer_axis_discrete(&self, axis: u32, steps: i32)
Wheel steps: axis 0 vertical, 1 horizontal.
pub fn keysym(&self, keysym: i32, pressed: bool)
Source§impl PortalSession
impl PortalSession
Trait Implementations§
Source§impl Drop for PortalSession
impl Drop for PortalSession
Auto Trait Implementations§
impl !Freeze for PortalSession
impl !RefUnwindSafe for PortalSession
impl !UnwindSafe for PortalSession
impl Send for PortalSession
impl Sync for PortalSession
impl Unpin for PortalSession
impl UnsafeUnpin for PortalSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more