@@ -6,38 +6,26 @@ use tokio::sync::RwLock;
66use tracing:: { debug, info, trace, warn} ;
77
88#[ cfg( target_os = "macos" ) ]
9- #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
9+ #[ derive( Debug , Default , Clone , Copy , PartialEq , Eq ) ]
1010pub enum PanelState {
11+ #[ default]
1112 None ,
1213 Creating ,
1314 Ready ,
1415 Destroying ,
1516}
1617
17- #[ cfg( target_os = "macos" ) ]
18- impl Default for PanelState {
19- fn default ( ) -> Self {
20- Self :: None
21- }
22- }
23-
2418#[ cfg( target_os = "macos" ) ]
2519#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
2620pub enum PanelWindowType {
2721 Camera ,
28- Main ,
29- TargetSelectOverlay ,
30- InProgressRecording ,
3122}
3223
3324#[ cfg( target_os = "macos" ) ]
3425impl std:: fmt:: Display for PanelWindowType {
3526 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3627 match self {
3728 Self :: Camera => write ! ( f, "Camera" ) ,
38- Self :: Main => write ! ( f, "Main" ) ,
39- Self :: TargetSelectOverlay => write ! ( f, "TargetSelectOverlay" ) ,
40- Self :: InProgressRecording => write ! ( f, "InProgressRecording" ) ,
4129 }
4230 }
4331}
@@ -107,7 +95,6 @@ impl PanelManager {
10795 window_type, op_id
10896 ) ;
10997 Some ( PanelOperationGuard {
110- window_type,
11198 operation_id : op_id,
11299 completed : false ,
113100 } )
@@ -136,87 +123,6 @@ impl PanelManager {
136123 }
137124 }
138125
139- pub async fn try_begin_show (
140- & self ,
141- window_type : PanelWindowType ,
142- ) -> Option < PanelOperationGuard > {
143- let mut panels = self . panels . write ( ) . await ;
144- let entry = panels. entry ( window_type) . or_default ( ) ;
145-
146- match entry. state {
147- PanelState :: Ready => {
148- let op_id = self
149- . operation_counter
150- . fetch_add ( 1 , std:: sync:: atomic:: Ordering :: SeqCst ) ;
151- debug ! (
152- "Panel {}: beginning show operation (op_id={})" ,
153- window_type, op_id
154- ) ;
155- Some ( PanelOperationGuard {
156- window_type,
157- operation_id : op_id,
158- completed : true ,
159- } )
160- }
161- PanelState :: None => {
162- debug ! ( "Panel {}: show blocked - window doesn't exist" , window_type) ;
163- None
164- }
165- PanelState :: Creating => {
166- debug ! (
167- "Panel {}: show blocked - currently creating (op_id={})" ,
168- window_type, entry. operation_id
169- ) ;
170- None
171- }
172- PanelState :: Destroying => {
173- debug ! (
174- "Panel {}: show blocked - currently destroying (op_id={})" ,
175- window_type, entry. operation_id
176- ) ;
177- None
178- }
179- }
180- }
181-
182- pub async fn try_begin_destroy (
183- & self ,
184- window_type : PanelWindowType ,
185- ) -> Option < PanelOperationGuard > {
186- let mut panels = self . panels . write ( ) . await ;
187- let entry = panels. entry ( window_type) . or_default ( ) ;
188-
189- match entry. state {
190- PanelState :: Ready | PanelState :: Creating => {
191- let op_id = self
192- . operation_counter
193- . fetch_add ( 1 , std:: sync:: atomic:: Ordering :: SeqCst ) ;
194- entry. state = PanelState :: Destroying ;
195- entry. operation_id = op_id;
196- debug ! (
197- "Panel {}: beginning destroy operation (op_id={})" ,
198- window_type, op_id
199- ) ;
200- Some ( PanelOperationGuard {
201- window_type,
202- operation_id : op_id,
203- completed : false ,
204- } )
205- }
206- PanelState :: None => {
207- debug ! ( "Panel {}: destroy skipped - already destroyed" , window_type) ;
208- None
209- }
210- PanelState :: Destroying => {
211- debug ! (
212- "Panel {}: destroy blocked - already destroying (op_id={})" ,
213- window_type, entry. operation_id
214- ) ;
215- None
216- }
217- }
218- }
219-
220126 pub async fn mark_ready ( & self , window_type : PanelWindowType , operation_id : u64 ) {
221127 let mut panels = self . panels . write ( ) . await ;
222128 if let Some ( entry) = panels. get_mut ( & window_type) {
@@ -235,24 +141,6 @@ impl PanelManager {
235141 }
236142 }
237143
238- pub async fn mark_destroyed ( & self , window_type : PanelWindowType , operation_id : u64 ) {
239- let mut panels = self . panels . write ( ) . await ;
240- if let Some ( entry) = panels. get_mut ( & window_type) {
241- if entry. operation_id == operation_id && entry. state == PanelState :: Destroying {
242- entry. state = PanelState :: None ;
243- info ! (
244- "Panel {}: marked destroyed (op_id={})" ,
245- window_type, operation_id
246- ) ;
247- } else {
248- warn ! (
249- "Panel {}: mark_destroyed ignored - state mismatch (current state={:?}, current op={}, requested op={})" ,
250- window_type, entry. state, entry. operation_id, operation_id
251- ) ;
252- }
253- }
254- }
255-
256144 pub async fn force_reset ( & self , window_type : PanelWindowType ) {
257145 let mut panels = self . panels . write ( ) . await ;
258146 if let Some ( entry) = panels. get_mut ( & window_type) {
@@ -293,7 +181,6 @@ impl PanelManager {
293181
294182#[ cfg( target_os = "macos" ) ]
295183pub struct PanelOperationGuard {
296- pub window_type : PanelWindowType ,
297184 pub operation_id : u64 ,
298185 completed : bool ,
299186}
@@ -303,10 +190,6 @@ impl PanelOperationGuard {
303190 pub fn mark_completed ( & mut self ) {
304191 self . completed = true ;
305192 }
306-
307- pub fn is_completed ( & self ) -> bool {
308- self . completed
309- }
310193}
311194
312195#[ cfg( target_os = "macos" ) ]
0 commit comments