Skip to main content

HostSession

Struct HostSession 

Source
pub struct HostSession { /* private fields */ }
Expand description

The calloop-side session: input proxies plus one capture handle per output.

Implementations§

Source§

impl HostSession

Source

pub fn connect( display: &str, gbm_path: Option<PathBuf>, frame_wake: Sender<usize>, dma_formats: Vec<(u32, Vec<u64>)>, cursor_tx: Sender<CursorJob>, ) -> Result<Self, String>

Connect to display, bring up input devices, enumerate the host’s outputs, and spawn one capture thread per output (idle until [start_capture]) plus the layout-control thread. gbm_path (this process’s render node) enables the zero-copy path; frame_wake is told the output index every time a capture thread queues a frame.

Source

pub fn output_count(&self) -> usize

Source

pub fn has_output_for(&self, display_id: u32) -> bool

True when an active capture on display_id has a host output behind it.

Source

pub fn display_for_output(&self, index: usize) -> Option<u32>

The display captured from host output index, if an active capture sits on it.

Source

pub fn has_queued_frame(&self, index: usize) -> bool

Whether host output index has queued a frame no render has taken yet.

Source

pub fn set_layout(&self, display_id: u32, x: i32, y: i32)

Record where selkies laid out display_id (union coordinates); pushed to the host with the next capture (re)start.

Source

pub fn current_output_size(&self, display_id: u32) -> Option<(i32, i32)>

The current mode of the host output backing display_id (physical pixels), as the host last announced it — what a capture follows when the host keeps its own mode instead of taking the requested one.

Source

pub fn layout_outcome(&self, epoch: u64) -> Option<bool>

The host’s answer to the layout request epoch (as returned by [start_capture]): Some(true) once the host said it applied the request, Some(false) once it said it did not (refusal, no layout management at all — KWin —, or no answer within LAYOUT_DEADLINE), None while still unanswered. Never blocks. Which of the two it is settles nothing on its own, since a host may acknowledge a mode it did not take: the caller polls for either answer, then compares [current_output_size] with what it asked for.

Source

pub fn start_capture( &self, display_id: u32, width: i32, height: i32, zero_copy: bool, paint_cursor: bool, fps: f64, ) -> u64

Aim display_id at widthxheight: assigns every active display its host output (by rank), asks the host for all modes and positions in one atomic configuration, and points the capture threads at their sizes and buffer types; frames gate until the host applies them. zero_copy states whether this display’s encoder imports dmabufs — a CPU consumer needs shm frames it can read, and gets them even on a GPU-capable host. Returns the layout request’s epoch for [layout_outcome]; nothing here waits on the host.

Source

pub fn set_buffer_type(&self, display_id: u32, zero_copy: bool)

Point display_id’s capture at dmabufs (zero_copy) or shm frames without touching its mode or position, which is what an encoder demoted or rebuilt mid-capture needs: the layout is already what the host applied, and re-running it would mode-set the host display again. Idempotent, so a consumer that keeps seeing the wrong buffer type until the capture thread reallocates can call this on every frame.

Source

pub fn set_fps(&self, display_id: u32, fps: f64)

Point display_id’s capture at a new rate: what a portal stream asks the compositor to hold; the Wayland capture protocols are demand-driven and ignore it.

Source

pub fn set_cursor_painting(&self, paint_cursor: bool)

Switch every active capture between host-painted and consumer-drawn cursors (the consumer’s native cursor rendering toggle), keeping geometry and buffer type. Frames already buffered stay valid either way. Idempotent.

Source

pub fn idle_output(&self, display_id: u32)

Park display_id’s capture (its slot leaves the pointer extent). The retained frame and anything still queued go back to the capture pool — an idle output has no consumer for them, and dropping them silently would wedge slots until the next renegotiation.

Source

pub fn alive(&self) -> bool

False once the host connection is gone (the primary connection or the first output’s capture ended): the owner drops the session and reports its captures as stopped, so they are rebuilt against a new connection instead of feeding a dead one.

Source

pub fn release_frame(&self, display_id: u32, frame: HostFrame)

Hand one frame back to the pool (same path the drain/idle releases take).

Source

pub fn try_take_frame(&self, display_id: u32) -> Option<HostFrame>

Newest ready frame for display_id, releasing any staler ones straight back to the pool.

Source

pub fn retain_frame(&self, display_id: u32, frame: HostFrame)

Keep frame as display_id’s current content (releasing the one it replaces).

Source

pub fn with_retained<R>( &self, display_id: u32, f: impl FnOnce(Option<&HostFrame>) -> R, ) -> R

Run f with display_id’s retained (current-content) frame, if any.

Source

pub fn set_keymap(&self, text: &str)

Take selkies’ managed keymap: uploaded verbatim to the virtual keyboard, and the table portal keys resolve their keysyms from.

Source

pub fn key(&self, xkb_keycode: u32, pressed: bool)

Key event in xkb numbering (evdev + 8), matching the seat injectors. The virtual keyboard takes the keycode under selkies’ keymap; the portal takes the keysym that keycode carries at its base level, which the host resolves in its own layout, and the evdev code only for a key without one.

Source

pub fn pointer_motion_abs(&self, x: f64, y: f64)

Source

pub fn pointer_motion_rel(&self, dx: f64, dy: f64)

Relative motion in union-layout units, sent as the host’s own relative motion: the host moves its pointer by the delta and clamps it to its outputs, or, for a pointer-locked client, passes the delta on without moving it. An absolute warp against a position tracked here could not do the second: the locked host pointer stays put, so every warp would read as the whole distance from the lock point.

Source

pub fn pointer_button(&self, btn: u32, pressed: bool)

Source

pub fn pointer_axis(&self, dx: f64, dy: f64)

Wheel scroll: the continuous value plus the discrete step count the seat path reports as v120, so host clients that scroll by notches (terminals, games, GTK list views) see the same steps as in nested mode; a value below one notch stays continuous. The source follows each axis request, which is the axis it applies to on wlroots.

Source§

impl HostSession

Source

pub fn pointer_scroll(&self, dx: f64, dy: f64)

A finger’s scroll by (dx, dy) pixels on the host: smooth, as a finger source ended by pointer_scroll_end, through libei, the portal or the virtual pointer, and in whole wheel notches with the remainder carried on uinput, whose wheels have no other.

Source

pub fn pointer_scroll_end(&self)

The finger lifted: the stop each smooth rung takes; uinput drops what it carried.

Trait Implementations§

Source§

impl Drop for HostSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more