Skip to main content

HostSession

Struct HostSession 

Source
pub struct HostSession {
Show 17 fields conn: Connection, vk: Option<ZwpVirtualKeyboardV1>, keyboard: Mutex<HostKeyboardState>, vptr: Option<ZwlrVirtualPointerV1>, uinput: Option<Pair>, portal: Option<Arc<PortalCtl>>, geoms: Vec<OutputGeom>, ctrl_tx: Sender<CtrlMsg>, ctrl_wake: OwnedFd, outputs: Vec<OutputHandle>, layout: Mutex<BTreeMap<u32, LayoutSlot>>, order: Vec<usize>, sizes: Arc<Mutex<Vec<(i32, i32)>>>, layouts: Arc<Mutex<LayoutLedger>>, alive: Arc<AtomicBool>, scroll_carry: Mutex<(f64, f64)>, pointer_at: Mutex<(f64, f64)>,
}
Expand description

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

Fields§

§conn: Connection§vk: Option<ZwpVirtualKeyboardV1>§keyboard: Mutex<HostKeyboardState>§vptr: Option<ZwlrVirtualPointerV1>§uinput: Option<Pair>

Kernel input devices, taken where /dev/uinput can serve them and the compositor offers neither libei nor a virtual keyboard or pointer, ahead of the portal’s own methods.

§portal: Option<Arc<PortalCtl>>

The portal session when frames or an input device come through xdg-desktop-portal.

§geoms: Vec<OutputGeom>

Output geometry by rank, pairing portal streams with outputs.

§ctrl_tx: Sender<CtrlMsg>§ctrl_wake: OwnedFd§outputs: Vec<OutputHandle>§layout: Mutex<BTreeMap<u32, LayoutSlot>>§order: Vec<usize>

Rank -> registry index, for looking a display’s host output up in sizes.

§sizes: Arc<Mutex<Vec<(i32, i32)>>>§layouts: Arc<Mutex<LayoutLedger>>§alive: Arc<AtomicBool>§scroll_carry: Mutex<(f64, f64)>

A finger’s scroll the uinput wheels have not taken yet, in pixels (pointer_scroll).

§pointer_at: Mutex<(f64, f64)>

The union-layout point the last absolute motion went to, whose output’s scale a finger’s scroll is taken by (pointer_scroll).

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

fn output_index_for(&self, display_id: u32) -> Option<usize>

The host output backing display_id: active display ids map onto host outputs by ascending rank (selkies ids are sparse — ‘display2’ is id 2).

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

fn send_apply(&self, slots: Vec<LayoutSlot>) -> u64

Number a layout request and hand it to the control thread.

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

fn drop_buffered_frames(&self, idx: usize)

Drop every buffered frame for an output: a buffer-type change or a parked output leaves them without a consumer. The slots go straight back to the pool; dropping them silently would wedge a slot until the next renegotiation.

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 is_portal(&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. Whether the frames come from a portal’s stream, whose compositor drives it on buffers of its own.

Source

pub fn alive(&self) -> bool

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 detach_retained(&self, display_id: u32)

Under portal capture, swap the software frame retained for display_id for a copy of its pixels and give the stream its buffer back: a compositor driving its stream (KWin) sends no cursor update while short of buffers, and a still screen would hold one for as long as it stands. A GPU frame is copied on the GPU (detach_retained_gpu).

Source

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

retain_frame, handing the frame it replaces to the caller instead of the host: an encode in flight may still read it.

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

fn with_portal(&self, f: impl FnOnce(&PortalSession))

Run f with the portal session while one is live.

Source

fn portal_ei(&self) -> Option<Arc<PortalLive>>

The live portal session’s libei injector, while one is up: input takes it over the portal’s Notify* methods where the backend granted an EIS socket.

Source

fn extent(&self) -> (i32, i32)

Union-layout bounding box of every active, output-backed display (the virtual-pointer extent, matching the space selkies injects in).

Source

fn portal_target(&self, x: f64, y: f64) -> Option<PortalPoint>

The portal stream under a union-layout point and where the point lands on it: the active display whose slot holds the point (else the nearest slot), paired with its stream by rank.

Source

fn active_slots(&self) -> Vec<LayoutSlot>

The active, output-backed displays’ slots, by rank.

Source

fn scale_at(&self, x: f64, y: f64) -> f64

The scale of the host output under a union-layout point: its display’s capture size over the logical size the portal’s stream announces for it, else the output’s mode over its integer scale.

Source

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

Absolute motion to a union-layout point, the physical space selkies injects in. libei takes it in the compositor’s logical space, where EIS regions lie: the stream’s position plus the point in its logical size. A union layout with no stream position to place it by goes as it is, which is that space on an unscaled host.

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 of the stream on the host, in the logical pixels of the output under the pointer as the nested compositor takes it: 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