pub struct ScreenLocker { /* private fields */ }Expand description
Fullscreen lock screen with password authentication.
Implementations§
Source§impl ScreenLocker
impl ScreenLocker
Sourcepub fn new(screen_width: usize, screen_height: usize) -> Self
pub fn new(screen_width: usize, screen_height: usize) -> Self
Create a new screen locker in the Unlocked state.
Sourcepub fn is_locked(&self) -> bool
pub fn is_locked(&self) -> bool
Returns true if the screen is in any locked/authenticating state.
Sourcepub fn handle_key(&mut self, key: u8, current_tick: u64) -> LockAction
pub fn handle_key(&mut self, key: u8, current_tick: u64) -> LockAction
Process a key press while the lock screen is active.
key is an ASCII byte (printable characters, Enter=0x0D,
Backspace=0x08, Escape=0x1B). Returns a LockAction indicating what
happened.
Sourcepub fn attempt_auth(&mut self, current_tick: u64) -> bool
pub fn attempt_auth(&mut self, current_tick: u64) -> bool
Attempt to authenticate with the current password buffer contents.
On success: resets failure count, transitions to AuthSuccess.
On failure: increments failed_attempts; if >= max_attempts, sets
a lockout timer.
Returns true on successful authentication.
Sourcepub fn check_idle_timeout(&mut self, current_tick: u64) -> bool
pub fn check_idle_timeout(&mut self, current_tick: u64) -> bool
Check whether the idle timeout has elapsed since the last activity.
Returns true if the screen should be locked due to inactivity.
Only meaningful when the screen is currently unlocked.
Sourcepub fn record_activity(&mut self, current_tick: u64)
pub fn record_activity(&mut self, current_tick: u64)
Record user activity (resets the idle timer).
Sourcepub fn tick(&mut self, current_tick: u64)
pub fn tick(&mut self, current_tick: u64)
Advance internal animation timers. Call once per frame or per tick.
Toggles cursor blink state every CURSOR_BLINK_TICKS ticks.
Also auto-transitions from AuthSuccess to Unlocked after a brief delay.
Sourcepub fn set_idle_timeout(&mut self, ticks: u64)
pub fn set_idle_timeout(&mut self, ticks: u64)
Set the idle timeout in ticks. Pass 0 to disable auto-lock.
Sourcepub fn set_max_attempts(&mut self, n: u32)
pub fn set_max_attempts(&mut self, n: u32)
Set the maximum number of failed attempts before lockout.
Sourcepub fn set_lock_message(&mut self, msg: &'static str)
pub fn set_lock_message(&mut self, msg: &'static str)
Set the display message shown on the lock screen.
Sourcepub fn set_user_name(&mut self, name: &'static str)
pub fn set_user_name(&mut self, name: &'static str)
Set the username displayed on the lock screen.
Sourcepub fn set_screen_size(&mut self, width: usize, height: usize)
pub fn set_screen_size(&mut self, width: usize, height: usize)
Update screen dimensions (e.g., on resolution change).
Sourcepub fn render_to_buffer(
&self,
buffer: &mut [u32],
buf_width: usize,
buf_height: usize,
current_tick: u64,
)
pub fn render_to_buffer( &self, buffer: &mut [u32], buf_width: usize, buf_height: usize, current_tick: u64, )
Render the lock screen into a u32 pixel buffer.
buffer is buf_width * buf_height elements in 0xAARRGGBB layout.
The caller is responsible for blitting this buffer to the framebuffer
(with any necessary RGB/BGR conversion).