@@ -196,6 +196,7 @@ pub const BACKGROUND_IMAGE_EXTENSIONS: [&str; 6] = ["jpg", "jpeg", "png", "gif",
196196pub const CURRENT_DESKTOP_BACKGROUND_BASENAME : & str = "current-desktop-background" ;
197197/// `recording.rs:92-93`.
198198const DESKTOP_BACKGROUND_MAX_DIMENSION : u32 = 2560 ;
199+ #[ cfg( target_os = "macos" ) ]
199200const DESKTOP_BACKGROUND_JPEG_QUALITY : u8 = 82 ;
200201
201202/// The sidebar's fallback border/shadow objects. The UI's numbers, **not**
@@ -1953,30 +1954,33 @@ pub(crate) fn decode_wallpaper_thumbnail(id: &str) -> Option<Arc<RenderImage>> {
19531954/// re-encoding to JPEG at quality 82. The `sips` path matters -- macOS ships
19541955/// HEIC wallpapers the `image` crate cannot decode.
19551956fn write_desktop_background_snapshot ( source : & Path , output : & Path ) -> Result < ( ) , String > {
1956- let needs_downscale = image:: image_dimensions ( source) . is_ok_and ( |( width, height) | {
1957- width > DESKTOP_BACKGROUND_MAX_DIMENSION || height > DESKTOP_BACKGROUND_MAX_DIMENSION
1958- } ) ;
1959-
1960- let mut command = std:: process:: Command :: new ( "sips" ) ;
1961- command
1962- . arg ( "-s" )
1963- . arg ( "format" )
1964- . arg ( "jpeg" )
1965- . arg ( "-s" )
1966- . arg ( "formatOptions" )
1967- . arg ( DESKTOP_BACKGROUND_JPEG_QUALITY . to_string ( ) ) ;
1968- if needs_downscale {
1969- command
1970- . arg ( "-Z" )
1971- . arg ( DESKTOP_BACKGROUND_MAX_DIMENSION . to_string ( ) ) ;
1972- }
1973- if let Ok ( output_status) = command. arg ( source) . arg ( "--out" ) . arg ( output) . output ( )
1974- && output_status. status . success ( )
1957+ #[ cfg( target_os = "macos" ) ]
19751958 {
1976- return Ok ( ( ) ) ;
1959+ let needs_downscale = image:: image_dimensions ( source) . is_ok_and ( |( width, height) | {
1960+ width > DESKTOP_BACKGROUND_MAX_DIMENSION || height > DESKTOP_BACKGROUND_MAX_DIMENSION
1961+ } ) ;
1962+
1963+ let mut command = std:: process:: Command :: new ( "sips" ) ;
1964+ command
1965+ . arg ( "-s" )
1966+ . arg ( "format" )
1967+ . arg ( "jpeg" )
1968+ . arg ( "-s" )
1969+ . arg ( "formatOptions" )
1970+ . arg ( DESKTOP_BACKGROUND_JPEG_QUALITY . to_string ( ) ) ;
1971+ if needs_downscale {
1972+ command
1973+ . arg ( "-Z" )
1974+ . arg ( DESKTOP_BACKGROUND_MAX_DIMENSION . to_string ( ) ) ;
1975+ }
1976+ if let Ok ( output_status) = command. arg ( source) . arg ( "--out" ) . arg ( output) . output ( )
1977+ && output_status. status . success ( )
1978+ {
1979+ return Ok ( ( ) ) ;
1980+ }
19771981 }
19781982
1979- let decoded = cap_gpui_kernels:: codec:: open_image ( source)
1983+ let decoded = cap_gpui_kernels:: codec:: decode_image_file ( source)
19801984 . map_err ( |err| format ! ( "failed to decode desktop background: {err}" ) ) ?;
19811985 let decoded = if decoded. width ( ) > DESKTOP_BACKGROUND_MAX_DIMENSION
19821986 || decoded. height ( ) > DESKTOP_BACKGROUND_MAX_DIMENSION
@@ -2426,6 +2430,13 @@ impl EditorWindow {
24262430 }
24272431 Err ( error) => {
24282432 tracing:: error!( "couldn't import your desktop wallpaper: {error}" ) ;
2433+ cx. spawn ( async move |_, _| {
2434+ crate :: platform:: alert_dialog (
2435+ "Couldn't import your desktop wallpaper" ,
2436+ & error,
2437+ ) ;
2438+ } )
2439+ . detach ( ) ;
24292440 }
24302441 }
24312442 cx. notify ( ) ;
0 commit comments