Skip to main content

SpellLock

Struct SpellLock 

Source
pub struct SpellLock { /* private fields */ }
Expand description

SpellLock is a struct which represents a window lock. It can be run and initialised on a custom lockscreen implementation with slint. Know limitations include the abscence to verify from fingerprints and unideal issues on multi-monitor setup. You can add the path of binary of your lock in your compositor config and idle manager config to use the program. It will be linked to spell-cli directly in coming releases.

§Example

Here is a minimal example of rust side, for complete code of slint, check the codebase of young-shell.

use spell_framework::cast_spell;
use std::{error::Error, sync::{Arc, RwLock}};
use slint::ComponentHandle;
use spell_framework::{layer_properties::ForeignController, wayland_adapter::SpellLock};
slint::include_modules!();

fn main() -> Result<(), Box<dyn Error>> {
    let lock = SpellLock::invoke_lock_spell();
    let lock_ui = LockScreen::new().unwrap();
    let looop_handle = lock.get_handler();
    lock_ui.on_check_pass({
        let lock_handle = lock_ui.as_weak();
        move |string_val| {
            let lock_handle_a = lock_handle.clone().unwrap();
            let lock_handle_b = lock_handle.clone().unwrap();
            looop_handle.unlock(
                None,
                string_val.to_string(),
                Box::new(move || {
                    lock_handle_a.set_lock_error(true);
                }),
                Box::new(move || {
                    lock_handle_b.set_is_lock_activated(false);
                }),
            );
        }
    });
    lock_ui.set_is_lock_activated(true);
    cast_spell(
        lock,
        None,
        None::<fn(Arc<RwLock<Box<dyn ForeignController>>>)>,
    )
}

Implementations§

Source§

impl SpellLock

Source

pub fn invoke_lock_spell() -> Self

This function creates an instance of SpellLock which can be combined with slint windows to create a lockscreen.

Source

pub fn get_handler(&self) -> LockHandle

Provides a lockscreen handler used to invoke the unlock callback with the user entered password.For more details view LockHandle.

Trait Implementations§

Source§

impl CompositorHandler for SpellLock

Source§

fn scale_factor_changed( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _surface: &WlSurface, _new_factor: i32, )

The surface has either been moved into or out of an output and the output has a different scale factor.
Source§

fn transform_changed( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _surface: &WlSurface, _new_transform: Transform, )

The surface has either been moved into or out of an output and the output has different transform.
Source§

fn frame( &mut self, _conn: &Connection, qh: &QueueHandle<Self>, _surface: &WlSurface, _time: u32, )

A frame callback has been completed. Read more
Source§

fn surface_enter( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _surface: &WlSurface, _output: &WlOutput, )

The surface has entered an output.
Source§

fn surface_leave( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _surface: &WlSurface, _output: &WlOutput, )

The surface has left an output.
Source§

impl Debug for SpellLock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Dispatch<ExtSessionLockManagerV1, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ExtSessionLockManagerV1, event: <ExtSessionLockManagerV1 as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<ExtSessionLockSurfaceV1, SessionLockSurfaceData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ExtSessionLockSurfaceV1, event: <ExtSessionLockSurfaceV1 as Proxy>::Event, data: &SessionLockSurfaceData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<ExtSessionLockV1, SessionLockData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ExtSessionLockV1, event: <ExtSessionLockV1 as Proxy>::Event, data: &SessionLockData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlCallback, WlSurface> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlCallback, event: <WlCallback as Proxy>::Event, data: &WlSurface, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlCompositor, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlCompositor, event: <WlCompositor as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlKeyboard, KeyboardData<SpellLock>> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlKeyboard, event: <WlKeyboard as Proxy>::Event, data: &KeyboardData<SpellLock>, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlOutput, OutputData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlOutput, event: <WlOutput as Proxy>::Event, data: &OutputData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlPointer, PointerData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlPointer, event: <WlPointer as Proxy>::Event, data: &PointerData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlRegistry, GlobalListContents> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlRegistry, event: <WlRegistry as Proxy>::Event, data: &GlobalListContents, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlSeat, SeatData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlSeat, event: <WlSeat as Proxy>::Event, data: &SeatData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlShm, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlShm, event: <WlShm as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WlSurface, SurfaceData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WlSurface, event: <WlSurface as Proxy>::Event, data: &SurfaceData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WpCursorShapeDeviceV1, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WpCursorShapeDeviceV1, event: <WpCursorShapeDeviceV1 as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<WpCursorShapeManagerV1, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &WpCursorShapeManagerV1, event: <WpCursorShapeManagerV1 as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<ZxdgOutputManagerV1, GlobalData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ZxdgOutputManagerV1, event: <ZxdgOutputManagerV1 as Proxy>::Event, data: &GlobalData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl Dispatch<ZxdgOutputV1, OutputData> for SpellLock

Source§

fn event( state: &mut Self, proxy: &ZxdgOutputV1, event: <ZxdgOutputV1 as Proxy>::Event, data: &OutputData, conn: &Connection, qhandle: &QueueHandle<Self>, )

Called when an event from the server is processed Read more
Source§

fn event_created_child( opcode: u16, qhandle: &QueueHandle<Self>, ) -> Arc<dyn ObjectData>

Method used to initialize the user-data of objects created by events Read more
Source§

impl KeyboardHandler for SpellLock

Source§

fn enter( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _surface: &WlSurface, _serial: u32, _raw: &[u32], _keysyms: &[Keysym], )

The keyboard has entered a surface. Read more
Source§

fn leave( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _surface: &WlSurface, _serial: u32, )

The keyboard has left a surface. Read more
Source§

fn press_key( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _serial: u32, event: KeyEvent, )

A key has been pressed on the keyboard. Read more
Source§

fn release_key( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _serial: u32, event: KeyEvent, )

A key has been released. Read more
Source§

fn update_modifiers( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _serial: u32, _modifiers: Modifiers, _raw_modifiers: RawModifiers, _layout: u32, )

Keyboard modifiers have been updated. Read more
Source§

fn repeat_key( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _serial: u32, _event: KeyEvent, )

A key has been previously pressed and is now repeating. Read more
Source§

fn update_repeat_info( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _info: RepeatInfo, )

The keyboard has updated the rate and delay between repeating key inputs. Read more
Source§

fn update_keymap( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _keymap: Keymap<'_>, )

Keyboard keymap has been updated. Read more
Source§

impl OutputHandler for SpellLock

Source§

fn output_state(&mut self) -> &mut OutputState

Source§

fn new_output( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _output: WlOutput, )

A new output has been advertised.
Source§

fn update_output( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _output: WlOutput, )

An existing output has changed.
Source§

fn output_destroyed( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _output: WlOutput, )

An output is no longer advertised. Read more
Source§

impl PointerHandler for SpellLock

Source§

fn pointer_frame( &mut self, _conn: &Connection, qh: &QueueHandle<Self>, _pointer: &WlPointer, events: &[PointerEvent], )

One or more pointer events are available. Read more
Source§

impl ProvidesRegistryState for SpellLock

Source§

fn registry(&mut self) -> &mut RegistryState

Returns a mutable reference to the registry state.
Source§

fn runtime_add_global( &mut self, conn: &Connection, qh: &QueueHandle<Self>, name: u32, interface: &str, version: u32, )

Called when a new global has been advertised by the compositor. Read more
Source§

fn runtime_remove_global( &mut self, conn: &Connection, qh: &QueueHandle<Self>, name: u32, interface: &str, )

Called when a global has been destroyed by the compositor.
Source§

impl SeatHandler for SpellLock

Source§

fn seat_state(&mut self) -> &mut SeatState

Source§

fn new_seat(&mut self, _: &Connection, _: &QueueHandle<Self>, _: WlSeat)

A new seat has been created. Read more
Source§

fn new_capability( &mut self, _conn: &Connection, qh: &QueueHandle<Self>, seat: WlSeat, capability: Capability, )

A new capability is available on the seat. Read more
Source§

fn remove_capability( &mut self, _conn: &Connection, _: &QueueHandle<Self>, _: WlSeat, capability: Capability, )

A capability has been removed from the seat. Read more
Source§

fn remove_seat(&mut self, _: &Connection, _: &QueueHandle<Self>, _: WlSeat)

A seat has been removed. Read more
Source§

impl SessionLockHandler for SpellLock

Source§

fn locked( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _session_lock: SessionLock, )

The session lock is active, and the client may create lock surfaces.
Source§

fn finished( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _session_lock: SessionLock, )

Session lock is not active and should be destroyed. Read more
Source§

fn configure( &mut self, _conn: &Connection, qh: &QueueHandle<Self>, _surface: SessionLockSurface, _configure: SessionLockSurfaceConfigure, _serial: u32, )

Compositor has requested size for surface.
Source§

impl ShmHandler for SpellLock

Source§

fn shm_state(&mut self) -> &mut Shm

Source§

impl SpellAssociated for SpellLock

Source§

fn on_call( &mut self, _: Option<State>, _: Option<Box<dyn FnMut(State)>>, _: Span, ) -> Result<(), Box<dyn Error>>

Source§

fn get_span(&self) -> Span

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
Source§

impl<T> Downcast for T
where T: Any,

Source§

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.
Source§

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.
Source§

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.
Source§

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.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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, 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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more