@@ -167,17 +167,6 @@ fn get_preferences(
167167 preferences
168168}
169169
170- #[ cfg( feature = "_macos-accessibility" ) ]
171- fn get_shared_workspace ( ) -> Retained < NSWorkspace > {
172- // SAFETY:
173- // * `sharedWorkspace` is safe to access from any thread.
174- // Source: <https://developer.apple.com/documentation/appkit/nsworkspace/1530344-sharedworkspace>
175- // * Doesn't take any raw pointers.
176- // * Has no documented preconditions.
177- // * Has no documented exceptions.
178- unsafe { NSWorkspace :: sharedWorkspace ( ) }
179- }
180-
181170#[ cfg( feature = "color-scheme" ) ]
182171fn to_color_scheme ( appearance : & NSAppearance ) -> ColorScheme {
183172 let light = unsafe { NSAppearanceNameAqua } ;
@@ -193,9 +182,8 @@ fn to_color_scheme(appearance: &NSAppearance) -> ColorScheme {
193182
194183#[ cfg( feature = "contrast" ) ]
195184fn get_contrast ( ) -> Contrast {
196- let workspace = get_shared_workspace ( ) ;
197- // SAFETY: Similar as for `get_shared_workspace()`.
198- let increase_contrast = unsafe { workspace. accessibilityDisplayShouldIncreaseContrast ( ) } ;
185+ let workspace = NSWorkspace :: sharedWorkspace ( ) ;
186+ let increase_contrast = workspace. accessibilityDisplayShouldIncreaseContrast ( ) ;
199187 if increase_contrast {
200188 Contrast :: More
201189 } else {
@@ -205,9 +193,8 @@ fn get_contrast() -> Contrast {
205193
206194#[ cfg( feature = "reduced-motion" ) ]
207195fn get_reduced_motion ( ) -> ReducedMotion {
208- let workspace = get_shared_workspace ( ) ;
209- // SAFETY: Similar as for `get_shared_workspace()`.
210- let reduce_motion = unsafe { workspace. accessibilityDisplayShouldReduceMotion ( ) } ;
196+ let workspace = NSWorkspace :: sharedWorkspace ( ) ;
197+ let reduce_motion = workspace. accessibilityDisplayShouldReduceMotion ( ) ;
211198 if reduce_motion {
212199 ReducedMotion :: Reduce
213200 } else {
@@ -217,9 +204,8 @@ fn get_reduced_motion() -> ReducedMotion {
217204
218205#[ cfg( feature = "reduced-transparency" ) ]
219206fn get_reduced_transparency ( ) -> ReducedTransparency {
220- let workspace = get_shared_workspace ( ) ;
221- // SAFETY: Similar as for `get_shared_workspace()`.
222- let reduce_motion = unsafe { workspace. accessibilityDisplayShouldReduceTransparency ( ) } ;
207+ let workspace = NSWorkspace :: sharedWorkspace ( ) ;
208+ let reduce_motion = workspace. accessibilityDisplayShouldReduceTransparency ( ) ;
223209 if reduce_motion {
224210 ReducedTransparency :: Reduce
225211 } else {
@@ -229,26 +215,26 @@ fn get_reduced_transparency() -> ReducedTransparency {
229215
230216#[ cfg( feature = "accent-color" ) ]
231217fn get_accent_color ( ) -> AccentColor {
232- let color = unsafe { NSColor :: controlAccentColor ( ) } ;
218+ let color = NSColor :: controlAccentColor ( ) ;
233219 AccentColor ( to_srgb ( & color) )
234220}
235221
236222#[ cfg( feature = "accent-color" ) ]
237223fn to_srgb ( color : & NSColor ) -> Option < Srgba > {
238- let srgb = unsafe { NSColorSpace :: sRGBColorSpace ( ) } ;
239- let color_in_srgb = unsafe { color. colorUsingColorSpace ( & srgb) } ?;
224+ let srgb = NSColorSpace :: sRGBColorSpace ( ) ;
225+ let color_in_srgb = color. colorUsingColorSpace ( & srgb) ?;
240226 // We have to cast because on 32-bit platforms, `CGFloat` = f32.
241227 Some ( Srgba {
242- red : unsafe { color_in_srgb. redComponent ( ) } as _ ,
243- green : unsafe { color_in_srgb. greenComponent ( ) } as _ ,
244- blue : unsafe { color_in_srgb. blueComponent ( ) } as _ ,
245- alpha : unsafe { color_in_srgb. alphaComponent ( ) } as _ ,
228+ red : color_in_srgb. redComponent ( ) as _ ,
229+ green : color_in_srgb. greenComponent ( ) as _ ,
230+ blue : color_in_srgb. blueComponent ( ) as _ ,
231+ alpha : color_in_srgb. alphaComponent ( ) as _ ,
246232 } )
247233}
248234
249235#[ cfg( feature = "double-click-interval" ) ]
250236fn get_double_click_interval ( ) -> DoubleClickInterval {
251237 // NSTimeInterval: A number of seconds.
252- let interval = unsafe { NSEvent :: doubleClickInterval ( ) } ;
238+ let interval = NSEvent :: doubleClickInterval ( ) ;
253239 DoubleClickInterval ( Duration :: try_from_secs_f64 ( interval) . ok ( ) )
254240}
0 commit comments