#![doc(
html_logo_url = "https://raw.githubusercontent.com/VimYoung/Spell/main/spell-framework/assets/spell_trans.png"
)]
#![doc(
html_favicon_url = "https://raw.githubusercontent.com/VimYoung/Spell/main/spell-framework/assets/spell_trans.ico"
)]
#![doc = include_str!("../docs/entry.md")]
#![warn(missing_docs)]
mod configure;
#[cfg(docsrs)]
mod dummy_skia_docs;
mod event_macros;
pub mod forge;
#[cfg(feature = "i-slint-renderer-skia")]
#[cfg(not(docsrs))]
#[doc(hidden)]
mod skia_non_docs;
pub mod slint_adapter;
pub mod vault;
pub mod wayland_adapter;
pub mod layer_properties {
pub use crate::configure::{Dimension, WindowConf, WindowConfBuilder};
pub mod internal {
pub use smithay_client_toolkit::{
reexports::client::{QueueHandle, protocol::wl_surface::WlSurface},
shell::xdg::popup::Popup,
};
}
pub use smithay_client_toolkit::shell::wlr_layer::{
Anchor as LayerAnchor, KeyboardInteractivity as BoardType, Layer as LayerType,
};
pub mod popup {
pub use crate::configure::{PopupConf, PopupCore};
pub use smithay_client_toolkit::reexports::protocols::xdg::shell::client::xdg_positioner::{
Anchor as PopupAnchor,
Gravity as PopupGravity
};
}
}
pub mod macro_internal {
pub use crate::vault::set_notification;
pub use paste::paste;
pub use smithay_client_toolkit::reexports::calloop::{
Interest, Mode, PostAction, generic::Generic,
};
pub use tracing::{info, span::Span, warn};
}
use smithay_client_toolkit::{
reexports::client::{QueueHandle, protocol::wl_surface::WlSurface},
shell::xdg::popup::Popup,
};
use std::error::Error;
use tracing::{Level, span, trace};
use crate::{configure::PopupCore, slint_adapter::SpellSkiaWinAdapter, wayland_adapter::SpellWin};
pub trait IpcController {
fn get_type(&self, key: &str) -> String;
fn change_val(&self, key: &str, val: &str);
fn custom_command(&self, _command: &str) {}
}
pub trait SpellAssociatedNew: std::fmt::Debug {
fn on_call(&mut self) -> Result<(), Box<dyn Error>>;
fn get_span(&self) -> span::Span {
span!(Level::INFO, "unnamed-widget")
}
fn is_locked(&self) -> bool {
true
}
}
pub trait PopupSlint {
fn create_new(settings: PopupCore) -> Self
where
Self: Sized;
fn converter_popup(&self, wl_surface: &WlSurface, qh: &QueueHandle<SpellWin>);
fn inner(&self) -> &Popup;
fn first_configure(&self) -> bool;
fn adapter(&self) -> &std::rc::Rc<SpellSkiaWinAdapter>;
}
pub fn cast_spell_inner<S: SpellAssociatedNew>(mut waywindow: S) -> Result<(), Box<dyn Error>> {
let span = waywindow.get_span();
let _gaurd = span.enter();
trace!("{:?}", &waywindow);
while waywindow.is_locked() {
waywindow.on_call()?
}
Ok(())
}
pub fn cast_spells_new(
mut windows: Vec<Box<dyn SpellAssociatedNew>>,
) -> Result<(), Box<dyn Error>> {
loop {
for win in windows.iter_mut() {
let span = win.get_span().clone();
let _gaurd = span.enter();
win.on_call()?;
}
}
}