@@ -103,198 +103,6 @@ impl SCContentFilter {
103103 SCContentFilterBuilder :: new ( )
104104 }
105105
106- /// Creates a new content filter (deprecated - use builder pattern)
107- ///
108- /// # Deprecated
109- /// Use the builder pattern instead:
110- /// ```no_run
111- /// # use screencapturekit::prelude::*;
112- /// # fn example() -> Result<(), Box<dyn std::error::Error>> {
113- /// # let content = SCShareableContent::get()?;
114- /// # let display = &content.displays()[0];
115- /// let filter = SCContentFilter::build()
116- /// .display(display)
117- /// .exclude_windows(&[])
118- /// .build();
119- /// # Ok(())
120- /// # }
121- /// ```
122- #[ deprecated( since = "1.0.0" , note = "Use SCContentFilter::build() instead" ) ]
123- #[ must_use]
124- pub fn new ( ) -> Self {
125- Self ( std:: ptr:: null ( ) )
126- }
127-
128- /// Creates a content filter with a desktop independent window (deprecated)
129- ///
130- /// # Deprecated
131- /// Use the builder pattern instead:
132- /// ```no_run
133- /// # use screencapturekit::prelude::*;
134- /// # fn example() -> Result<(), Box<dyn std::error::Error>> {
135- /// # let content = SCShareableContent::get()?;
136- /// # let window = &content.windows()[0];
137- /// let filter = SCContentFilter::build()
138- /// .window(window)
139- /// .build();
140- /// # Ok(())
141- /// # }
142- /// ```
143- #[ deprecated( since = "1.0.0" , note = "Use SCContentFilter::build().window().build() instead" ) ]
144- #[ must_use]
145- pub fn with_desktop_independent_window ( self , window : & SCWindow ) -> Self {
146- // Drop the old filter if any
147- if !self . 0 . is_null ( ) {
148- unsafe { ffi:: sc_content_filter_release ( self . 0 ) ; }
149- }
150- std:: mem:: forget ( self ) ; // Prevent double-free
151-
152- unsafe {
153- let filter = ffi:: sc_content_filter_create_with_desktop_independent_window ( window. as_ptr ( ) ) ;
154- Self ( filter)
155- }
156- }
157-
158- /// Creates a content filter with a display, excluding specific windows (deprecated)
159- ///
160- /// # Deprecated
161- /// Use the builder pattern instead:
162- /// ```no_run
163- /// # use screencapturekit::prelude::*;
164- /// # fn example() -> Result<(), Box<dyn std::error::Error>> {
165- /// # let content = SCShareableContent::get()?;
166- /// # let display = &content.displays()[0];
167- /// # let window = &content.windows()[0];
168- /// // Capture entire display
169- /// let filter = SCContentFilter::build()
170- /// .display(display)
171- /// .exclude_windows(&[])
172- /// .build();
173- ///
174- /// // Or exclude specific windows
175- /// let filter = SCContentFilter::build()
176- /// .display(display)
177- /// .exclude_windows(&[window])
178- /// .build();
179- /// # Ok(())
180- /// # }
181- /// ```
182- #[ deprecated( since = "1.0.0" , note = "Use SCContentFilter::build().display().exclude_windows().build() instead" ) ]
183- #[ must_use]
184- pub fn with_display_excluding_windows (
185- self ,
186- display : & SCDisplay ,
187- excluding_windows : & [ & SCWindow ] ,
188- ) -> Self {
189- // Drop the old filter if any
190- if !self . 0 . is_null ( ) {
191- unsafe { ffi:: sc_content_filter_release ( self . 0 ) ; }
192- }
193- std:: mem:: forget ( self ) ; // Prevent double-free
194- unsafe {
195- let window_ptrs: Vec < * const c_void > = excluding_windows
196- . iter ( )
197- . map ( |w| w. as_ptr ( ) )
198- . collect ( ) ;
199-
200- let filter = if window_ptrs. is_empty ( ) {
201- ffi:: sc_content_filter_create_with_display_excluding_windows (
202- display. as_ptr ( ) ,
203- std:: ptr:: null ( ) ,
204- 0 ,
205- )
206- } else {
207- // FFI expects isize for array length (Objective-C NSInteger)
208- #[ allow( clippy:: cast_possible_wrap) ]
209- ffi:: sc_content_filter_create_with_display_excluding_windows (
210- display. as_ptr ( ) ,
211- window_ptrs. as_ptr ( ) ,
212- window_ptrs. len ( ) as isize ,
213- )
214- } ;
215-
216- Self ( filter)
217- }
218- }
219-
220- /// Creates a content filter with a display, including specific windows (deprecated)
221- #[ deprecated( since = "1.0.0" , note = "Use SCContentFilter::build().display().include_windows().build() instead" ) ]
222- #[ must_use]
223- pub fn with_display_including_windows (
224- self ,
225- display : & SCDisplay ,
226- including_windows : & [ & SCWindow ] ,
227- ) -> Self {
228- // Drop the old filter if any
229- if !self . 0 . is_null ( ) {
230- unsafe { ffi:: sc_content_filter_release ( self . 0 ) ; }
231- }
232- std:: mem:: forget ( self ) ; // Prevent double-free
233- unsafe {
234- let window_ptrs: Vec < * const c_void > = including_windows
235- . iter ( )
236- . map ( |w| w. as_ptr ( ) )
237- . collect ( ) ;
238-
239- let filter = if window_ptrs. is_empty ( ) {
240- ffi:: sc_content_filter_create_with_display_including_windows (
241- display. as_ptr ( ) ,
242- std:: ptr:: null ( ) ,
243- 0 ,
244- )
245- } else {
246- // FFI expects isize for array length (Objective-C NSInteger)
247- #[ allow( clippy:: cast_possible_wrap) ]
248- ffi:: sc_content_filter_create_with_display_including_windows (
249- display. as_ptr ( ) ,
250- window_ptrs. as_ptr ( ) ,
251- window_ptrs. len ( ) as isize ,
252- )
253- } ;
254-
255- Self ( filter)
256- }
257- }
258-
259- /// Creates a content filter with a display, including applications and excepting specific windows (deprecated)
260- #[ deprecated( since = "1.0.0" , note = "Use SCContentFilter::build().display().include_applications().build() instead" ) ]
261- #[ must_use]
262- pub fn with_display_including_applications_excepting_windows (
263- self ,
264- display : & SCDisplay ,
265- applications : & [ & SCRunningApplication ] ,
266- excepting_windows : & [ & SCWindow ] ,
267- ) -> Self {
268- // Drop the old filter if any
269- if !self . 0 . is_null ( ) {
270- unsafe { ffi:: sc_content_filter_release ( self . 0 ) ; }
271- }
272- std:: mem:: forget ( self ) ; // Prevent double-free
273- unsafe {
274- let app_ptrs: Vec < * const c_void > = applications
275- . iter ( )
276- . map ( |a| a. as_ptr ( ) )
277- . collect ( ) ;
278-
279- let window_ptrs: Vec < * const c_void > = excepting_windows
280- . iter ( )
281- . map ( |w| w. as_ptr ( ) )
282- . collect ( ) ;
283-
284- // FFI expects isize for array lengths (Objective-C NSInteger)
285- #[ allow( clippy:: cast_possible_wrap) ]
286- let filter = ffi:: sc_content_filter_create_with_display_including_applications_excepting_windows (
287- display. as_ptr ( ) ,
288- if app_ptrs. is_empty ( ) { std:: ptr:: null ( ) } else { app_ptrs. as_ptr ( ) } ,
289- app_ptrs. len ( ) as isize ,
290- if window_ptrs. is_empty ( ) { std:: ptr:: null ( ) } else { window_ptrs. as_ptr ( ) } ,
291- window_ptrs. len ( ) as isize ,
292- ) ;
293-
294- Self ( filter)
295- }
296- }
297-
298106 /// Returns the raw pointer to the content filter
299107 pub ( crate ) fn as_ptr ( & self ) -> * const c_void {
300108 self . 0
0 commit comments