|
|
|
@ -41,6 +41,8 @@ pub enum Error {
|
|
|
|
|
Tauri(#[from] tauri::Error),
|
|
|
|
|
#[error(transparent)]
|
|
|
|
|
SerdeJson(#[from] serde_json::Error),
|
|
|
|
|
#[error(transparent)]
|
|
|
|
|
Glob(#[from] glob::PatternError),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
@ -319,7 +321,7 @@ impl<R: Runtime> WindowExtInternal for Window<R> {
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
pub struct Builder {
|
|
|
|
|
denylist: HashSet<String>,
|
|
|
|
|
denylist: Vec<glob::Pattern>,
|
|
|
|
|
skip_initial_state: HashSet<String>,
|
|
|
|
|
state_flags: StateFlags,
|
|
|
|
|
map_label: Option<Box<LabelMapperFn>>,
|
|
|
|
@ -344,10 +346,16 @@ impl Builder {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Sets a list of windows that shouldn't be tracked and managed by this plugin
|
|
|
|
|
/// for example splash screen windows.
|
|
|
|
|
pub fn with_denylist(mut self, denylist: &[&str]) -> Self {
|
|
|
|
|
self.denylist = denylist.iter().map(|l| l.to_string()).collect();
|
|
|
|
|
self
|
|
|
|
|
/// For example, splash screen windows. It also supports glob patterns for flexible window matching.
|
|
|
|
|
pub fn with_denylist(mut self, denylist: &mut [&str]) -> Result<Self> {
|
|
|
|
|
denylist.sort();
|
|
|
|
|
|
|
|
|
|
let mut denylist_patterns = Vec::new();
|
|
|
|
|
for pattern in denylist {
|
|
|
|
|
denylist_patterns.push(glob::Pattern::new(&pattern)?);
|
|
|
|
|
}
|
|
|
|
|
self.denylist = denylist_patterns;
|
|
|
|
|
Ok(self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Adds the given window label to a list of windows to skip initial state restore.
|
|
|
|
@ -413,8 +421,11 @@ impl Builder {
|
|
|
|
|
.map(|map| map(window.label()))
|
|
|
|
|
.unwrap_or_else(|| window.label());
|
|
|
|
|
|
|
|
|
|
if self.denylist.contains(label) {
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for pattern in &self.denylist {
|
|
|
|
|
if pattern.matches(label) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !self.skip_initial_state.contains(label) {
|
|
|
|
|