Struct WaylandClipboard
pub struct WaylandClipboard { /* private fields */ }Expand description
wl_data_device + zwp_primary_selection_device_v1 on the app’s own
Wayland connection. The focused client’s connection is required for the
compositor to accept copies; a separate connection cannot substitute.
Prefer Self::from_owned_display so every protocol worker and retained
loader owns the display it uses.
Implementations§
§impl WaylandClipboard
impl WaylandClipboard
pub unsafe fn new(display_ptr: *mut c_void) -> WaylandClipboard
pub unsafe fn new(display_ptr: *mut c_void) -> WaylandClipboard
Attach to the wl_display behind display_ptr.
§Safety
display_ptr must remain live until this value AND every outstanding
loader have finished. A timed-out text read can retain a loader after
this value is dropped. Use Self::from_owned_display when that
independent lifetime cannot be guaranteed.
pub fn from_owned_display(
handle: impl HasDisplayHandle + Send + Sync + 'static,
) -> Option<WaylandClipboard>
pub fn from_owned_display( handle: impl HasDisplayHandle + Send + Sync + 'static, ) -> Option<WaylandClipboard>
Attach while retaining the actual display owner for every worker, including loaders that survive runner close.
Trait Implementations§
§impl ClipboardBackend for WaylandClipboard
impl ClipboardBackend for WaylandClipboard
§fn request_text(&self, target: ClipboardTarget) -> Receiver<Option<String>>
fn request_text(&self, target: ClipboardTarget) -> Receiver<Option<String>>
Request text for an explicit paste. A native transfer may finish after
this call returns; the backend must wake its owner when it answers.
No answer may substitute text from an older selection or focus owner.
§fn set_text(&self, target: ClipboardTarget, text: &str) -> bool
fn set_text(&self, target: ClipboardTarget, text: &str) -> bool
Take ownership of
target and offer text on it. Returns false if
the backend could not.§fn set_rich_text(&self, html: &str, plain: &str) -> bool
fn set_rich_text(&self, html: &str, plain: &str) -> bool
Take the Ctrl+C clipboard and offer formatted text on it:
html as
text/html and plain as its plain-text fallback, both from one
copy, so an app that reads formatting pastes the formatting and every
other app the words. Returns false if the backend could not. Read more§fn set_secret_text(&self, text: &str) -> bool
fn set_secret_text(&self, text: &str) -> bool
Offer
text on the Ctrl+V clipboard marked as a secret: a password,
a one-time code, an enrolment token. Other apps can still paste it as
plain text, but clipboard managers and Tilo’s own history and device
sync are told not to keep it (SECRET_MIME,
PASSWORD_MANAGER_HINT_MIME). Read more§fn text(&self, target: ClipboardTarget) -> Option<String>
fn text(&self, target: ClipboardTarget) -> Option<String>
Read
target as UTF-8. None when it is empty, unavailable, or holds
something that is not text.§fn set_image(&self, width: usize, height: usize, rgba: &[u8]) -> bool
fn set_image(&self, width: usize, height: usize, rgba: &[u8]) -> bool
Offer an RGBA8 image on the clipboard. Optional: the default refuses,
which is appropriate for backends that only carry text.
§fn copy(&self, content: CopyContent<'_>) -> ClipboardCopy
fn copy(&self, content: CopyContent<'_>) -> ClipboardCopy
Start a Ctrl+C copy without waiting for it, and answer its outcome
through the returned
ClipboardCopy. A copy through an app’s own
Wayland connection waits on compositor roundtrips; this lets the UI
thread go on while it does, and wakes the app when it settles. Read more§fn rich_text(&self) -> Option<RichTextOffer>
fn rich_text(&self) -> Option<RichTextOffer>
Read HTML and its plain fallback from one Ctrl+V clipboard offer.
Optional: unsupported backends return
None without reading plain text.
A successful read consumes event-scoped offers; use the captured plain
fallback if decoding refuses the HTML. Never reread to recover a stale
selection, a permission refusal, or an active composition.§fn image(&self) -> Option<ClipboardImage>
fn image(&self) -> Option<ClipboardImage>
The image on the Ctrl+V clipboard, when it holds one: a screenshot,
an image copied in a viewer or a browser. Optional: the default reads
none, which is right for backends that only carry text.
Offer
text only where other processes can read it. Returns false
rather than keeping it in a buffer private to this process, so a
secret is never reported as copied when it was not. The default is
set_text, right for a backend that only reaches a
shared clipboard.§fn reserve_text(&self) -> Option<ReservedCopy>
fn reserve_text(&self) -> Option<ReservedCopy>
Hold a Ctrl+C copy for text that is not known yet: a link the
person’s click asks a host for. A browser copies only inside the
click, so a backend with that rule claims the clipboard now and
fills it once
ReservedCopy::fill hands the text over. None
when this backend copies just as well later, or has no way to claim
the clipboard now; the text is then copied when it arrives.§impl Drop for WaylandClipboard
impl Drop for WaylandClipboard
Auto Trait Implementations§
impl !Freeze for WaylandClipboard
impl !RefUnwindSafe for WaylandClipboard
impl Send for WaylandClipboard
impl Sync for WaylandClipboard
impl Unpin for WaylandClipboard
impl UnsafeUnpin for WaylandClipboard
impl !UnwindSafe for WaylandClipboard
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
Mutably borrows from an owned value. Read more
§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>
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>
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)
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)
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.§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>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
Converts
&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)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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 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>
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