@@ -41,6 +41,8 @@ pub enum Error {
41
41
Tauri ( #[ from] tauri:: Error ) ,
42
42
#[ error( transparent) ]
43
43
SerdeJson ( #[ from] serde_json:: Error ) ,
44
+ #[ error( transparent) ]
45
+ Glob ( #[ from] glob:: PatternError ) ,
44
46
}
45
47
46
48
pub type Result < T > = std:: result:: Result < T , Error > ;
@@ -319,7 +321,7 @@ impl<R: Runtime> WindowExtInternal for Window<R> {
319
321
320
322
#[ derive( Default ) ]
321
323
pub struct Builder {
322
- denylist : HashSet < String > ,
324
+ denylist : Vec < glob :: Pattern > ,
323
325
skip_initial_state : HashSet < String > ,
324
326
state_flags : StateFlags ,
325
327
map_label : Option < Box < LabelMapperFn > > ,
@@ -344,10 +346,16 @@ impl Builder {
344
346
}
345
347
346
348
/// Sets a list of windows that shouldn't be tracked and managed by this plugin
347
- /// for example splash screen windows.
348
- pub fn with_denylist ( mut self , denylist : & [ & str ] ) -> Self {
349
- self . denylist = denylist. iter ( ) . map ( |l| l. to_string ( ) ) . collect ( ) ;
350
- self
349
+ /// For example, splash screen windows. It also supports glob patterns for flexible window matching.
350
+ pub fn with_denylist ( mut self , denylist : & mut [ & str ] ) -> Result < Self > {
351
+ denylist. sort ( ) ;
352
+
353
+ let mut denylist_patterns = Vec :: new ( ) ;
354
+ for pattern in denylist {
355
+ denylist_patterns. push ( glob:: Pattern :: new ( & pattern) ?) ;
356
+ }
357
+ self . denylist = denylist_patterns;
358
+ Ok ( self )
351
359
}
352
360
353
361
/// Adds the given window label to a list of windows to skip initial state restore.
@@ -413,8 +421,11 @@ impl Builder {
413
421
. map ( |map| map ( window. label ( ) ) )
414
422
. unwrap_or_else ( || window. label ( ) ) ;
415
423
416
- if self . denylist . contains ( label) {
417
- return ;
424
+
425
+ for pattern in & self . denylist {
426
+ if pattern. matches ( label) {
427
+ return ;
428
+ }
418
429
}
419
430
420
431
if !self . skip_initial_state . contains ( label) {
0 commit comments