@@ -5,17 +5,23 @@ use serde_alias::serde_alias;
55use ts_rs:: TS ;
66
77#[ derive( Clone , Debug , Eq , PartialEq , Serialize , Deserialize , JsonSchema , TS ) ]
8- #[ serde( rename_all = "snake_case" ) ]
98#[ ts( repr( enum = name) ) ]
109pub enum AppExtraFlag {
10+ /// Mark this app as non interactive window.
11+ #[ serde( alias = "no-interactive" ) ]
12+ NoInteractive ,
1113 /// Start the app in the center of the screen as floating in the wm.
12- Float ,
13- /// Force manage this app in the wm.
14- Force ,
14+ #[ serde( alias = "float" , alias = "wm-float" ) ]
15+ WmFloat ,
16+ /// Forces the management of this app in the wm. (only if it is interactable and not pinned)
17+ #[ serde( alias = "force" , alias = "wm-force" ) ]
18+ WmForce ,
1519 /// Unmanage this app in the wm.
16- Unmanage ,
20+ #[ serde( alias = "unmanage" , alias = "wm-unmanage" ) ]
21+ WmUnmanage ,
1722 /// Pin this app in all the virtual desktops in the wm.
18- Pinned ,
23+ #[ serde( alias = "pinned" , alias = "vd-pinned" ) ]
24+ VdPinned ,
1925 #[ serde( other) ]
2026 Unknown ,
2127}
@@ -78,7 +84,7 @@ pub struct AppIdentifierCache {
7884}
7985
8086impl AppIdentifier {
81- pub fn perform_cache ( & mut self ) {
87+ pub fn prepare ( & mut self ) {
8288 if matches ! ( self . matching_strategy, MatchingStrategy :: Regex ) {
8389 let result = Regex :: new ( & self . id ) ;
8490 if let Ok ( re) = result {
@@ -89,8 +95,8 @@ impl AppIdentifier {
8995 self . cache . uppercased_id = Some ( self . id . to_uppercase ( ) ) ;
9096 }
9197
92- self . and . iter_mut ( ) . for_each ( |i| i. perform_cache ( ) ) ;
93- self . or . iter_mut ( ) . for_each ( |i| i. perform_cache ( ) ) ;
98+ self . and . iter_mut ( ) . for_each ( |i| i. prepare ( ) ) ;
99+ self . or . iter_mut ( ) . for_each ( |i| i. prepare ( ) ) ;
94100 }
95101
96102 pub fn uppercased_id ( & self ) -> & str {
@@ -174,3 +180,48 @@ pub struct AppConfig {
174180 #[ serde( default ) ]
175181 pub is_bundled : bool ,
176182}
183+
184+ impl AppConfig {
185+ pub fn prepare ( & mut self ) {
186+ self . identifier . prepare ( ) ;
187+ }
188+ }
189+
190+ #[ derive( Debug , Default , Clone ) ]
191+ pub struct AppsConfigurationList ( Vec < AppConfig > ) ;
192+
193+ impl AppsConfigurationList {
194+ pub fn prepare ( & mut self ) {
195+ self . 0 . iter_mut ( ) . for_each ( |config| config. prepare ( ) ) ;
196+ }
197+
198+ pub fn search ( & self , title : & str , class : & str , exe : & str , path : & str ) -> Option < & AppConfig > {
199+ self . 0
200+ . iter ( )
201+ . find ( |& config| config. identifier . validate ( title, class, exe, path) )
202+ }
203+
204+ pub fn iter ( & self ) -> impl Iterator < Item = & AppConfig > {
205+ self . 0 . iter ( )
206+ }
207+
208+ pub fn clear ( & mut self ) {
209+ self . 0 . clear ( ) ;
210+ }
211+
212+ pub fn len ( & self ) -> usize {
213+ self . 0 . len ( )
214+ }
215+
216+ pub fn is_empty ( & self ) -> bool {
217+ self . 0 . is_empty ( )
218+ }
219+
220+ pub fn extend ( & mut self , configs : Vec < AppConfig > ) {
221+ self . 0 . extend ( configs) ;
222+ }
223+
224+ pub fn as_slice ( & self ) -> & [ AppConfig ] {
225+ & self . 0
226+ }
227+ }
0 commit comments