pub struct HostSession { /* private fields */ }Expand description
The calloop-side session: input proxies plus one capture handle per output.
Implementations§
Source§impl HostSession
impl HostSession
Sourcepub 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>
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.
pub fn output_count(&self) -> usize
Sourcepub fn has_output_for(&self, display_id: u32) -> bool
pub fn has_output_for(&self, display_id: u32) -> bool
True when an active capture on display_id has a host output behind it.
Sourcepub fn display_for_output(&self, index: usize) -> Option<u32>
pub fn display_for_output(&self, index: usize) -> Option<u32>
The display captured from host output index, if an active capture sits on it.
Sourcepub fn has_queued_frame(&self, index: usize) -> bool
pub fn has_queued_frame(&self, index: usize) -> bool
Whether host output index has queued a frame no render has taken yet.
Sourcepub fn set_layout(&self, display_id: u32, x: i32, y: i32)
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.
Sourcepub fn current_output_size(&self, display_id: u32) -> Option<(i32, i32)>
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.
Sourcepub fn layout_outcome(&self, epoch: u64) -> Option<bool>
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.
Sourcepub fn start_capture(
&self,
display_id: u32,
width: i32,
height: i32,
zero_copy: bool,
paint_cursor: bool,
fps: f64,
) -> u64
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.
Sourcepub fn set_buffer_type(&self, display_id: u32, zero_copy: bool)
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.
Sourcepub fn set_fps(&self, display_id: u32, fps: f64)
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.
Sourcepub fn set_cursor_painting(&self, paint_cursor: bool)
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.
Sourcepub fn idle_output(&self, display_id: u32)
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.
Sourcepub fn alive(&self) -> bool
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.
Sourcepub fn release_frame(&self, display_id: u32, frame: HostFrame)
pub fn release_frame(&self, display_id: u32, frame: HostFrame)
Hand one frame back to the pool (same path the drain/idle releases take).
Sourcepub fn try_take_frame(&self, display_id: u32) -> Option<HostFrame>
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.
Sourcepub fn retain_frame(&self, display_id: u32, frame: HostFrame)
pub fn retain_frame(&self, display_id: u32, frame: HostFrame)
Keep frame as display_id’s current content (releasing the one it
replaces).
Sourcepub fn with_retained<R>(
&self,
display_id: u32,
f: impl FnOnce(Option<&HostFrame>) -> R,
) -> R
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.
Sourcepub fn set_keymap(&self, text: &str)
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.
Sourcepub fn key(&self, xkb_keycode: u32, pressed: bool)
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.
pub fn pointer_motion_abs(&self, x: f64, y: f64)
Sourcepub fn pointer_motion_rel(&self, dx: f64, dy: f64)
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.
Sourcepub fn pointer_axis(&self, dx: f64, dy: f64)
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
impl HostSession
Sourcepub fn pointer_scroll(&self, dx: f64, dy: f64)
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.
Sourcepub fn pointer_scroll_end(&self)
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
impl Drop for HostSession
Auto Trait Implementations§
impl !Freeze for HostSession
impl !RefUnwindSafe for HostSession
impl !Send for HostSession
impl !Sync for HostSession
impl !UnwindSafe for HostSession
impl Unpin for HostSession
impl UnsafeUnpin for HostSession
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> 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