pub struct OwnedWindow(/* private fields */);Expand description
The single owner of a Window: it deletes the window when dropped.
Nothing else deletes an owned window. The safe layer refuses to delete,
clean away, own, reparent or reorder a window or an object containing one
(see lvgl_rust_external_class_policy), raw code needs unsafe, and
Window has no public delete. A window therefore lives exactly as long
as its owner, which deletes it once.
LVGL can update a window while its owner waits for events. The owner exposes raw pointers for interoperation and uses a session for access. The waker is atomic and needs no session.
Taking ownership of a raw window requires unsafe:
fn adopt(window: core::ptr::NonNull<graphics::Window>) -> graphics::OwnedWindow {
graphics::OwnedWindow::from_raw(window)
}Safe code cannot borrow the window or read events without a session.
fn borrow(window: &graphics::OwnedWindow) {
let _ = &**window;
}fn read(window: &graphics::OwnedWindow) {
window.peek_event();
}Implementations§
Source§impl OwnedWindow
impl OwnedWindow
Sourcepub unsafe fn from_raw(window: NonNull<Window>) -> Self
pub unsafe fn from_raw(window: NonNull<Window>) -> Self
Take ownership of a raw window.
§Safety
window must point to a live window (see Window::new) that
nothing else owns or deletes. LVGL must stay initialized while the owner
exists. Every window created inside it must be deleted first.
Sourcepub fn into_raw(self) -> NonNull<Window>
pub fn into_raw(self) -> NonNull<Window>
Give up ownership without deleting the window. The caller becomes its
owner: it deletes the window once, under the graphics lock, or hands it
back to OwnedWindow::from_raw.
Sourcepub fn as_object_mutable(&mut self) -> *mut lv_obj_t
pub fn as_object_mutable(&mut self) -> *mut lv_obj_t
The window’s LVGL object, for the raw bindings.
pub fn get_identifier(&self) -> usize
pub fn peek_event(&self, _lvgl: &Lvgl) -> Option<Event>
Sourcepub fn pop_event(&mut self, _lvgl: &mut Lvgl) -> Option<Event>
pub fn pop_event(&mut self, _lvgl: &mut Lvgl) -> Option<Event>
See Window::pop_event.
Sourcepub fn dropped_event_count(&self, _lvgl: &Lvgl) -> u32
pub fn dropped_event_count(&self, _lvgl: &Lvgl) -> u32
Sourcepub fn discard_events_for_target(
&mut self,
_lvgl: &mut Lvgl,
target: *mut lv_obj_t,
)
pub fn discard_events_for_target( &mut self, _lvgl: &mut Lvgl, target: *mut lv_obj_t, )
pub fn get_icon<'a>(&'a self, _lvgl: &'a Lvgl) -> (&'a str, Color)
Sourcepub fn set_icon(
&mut self,
_lvgl: &mut Lvgl,
icon_string: &str,
icon_color: Color,
)
pub fn set_icon( &mut self, _lvgl: &mut Lvgl, icon_string: &str, icon_color: Color, )
Set the icon using up to two Unicode scalar values. Text after a NUL is ignored.