Add basic ico support (#40822)
Closes https://github.com/zed-industries/zed/discussions/40763 <img width="867" height="1088" alt="Screenshot 2025-10-21 at 23 14 47" src="https://github.com/user-attachments/assets/d691fb2a-afc6-4445-a335-054ef164e0d3" /> Also improves error handling on image open failure: <img width="864" height="1083" alt="Screenshot 2025-10-21 at 23 14 30" src="https://github.com/user-attachments/assets/d5388b61-995f-441b-b375-ad5136d1533b" /> Release Notes: - Added basic ico support, improved unsupported image handling
This commit is contained in:
@@ -86,6 +86,7 @@ x11rb::atom_manager! {
|
||||
SVG__MIME: ImageFormat::mime_type(ImageFormat::Svg ).as_bytes(),
|
||||
BMP__MIME: ImageFormat::mime_type(ImageFormat::Bmp ).as_bytes(),
|
||||
TIFF_MIME: ImageFormat::mime_type(ImageFormat::Tiff).as_bytes(),
|
||||
ICO__MIME: ImageFormat::mime_type(ImageFormat::Ico ).as_bytes(),
|
||||
|
||||
// This is just some random name for the property on our window, into which
|
||||
// the clipboard owner writes the data we requested.
|
||||
@@ -1003,6 +1004,7 @@ impl Clipboard {
|
||||
ImageFormat::Svg => self.inner.atoms.SVG__MIME,
|
||||
ImageFormat::Bmp => self.inner.atoms.BMP__MIME,
|
||||
ImageFormat::Tiff => self.inner.atoms.TIFF_MIME,
|
||||
ImageFormat::Ico => self.inner.atoms.ICO__MIME,
|
||||
};
|
||||
let data = vec![ClipboardData {
|
||||
bytes: image.bytes,
|
||||
|
||||
@@ -1607,6 +1607,7 @@ impl From<ImageFormat> for UTType {
|
||||
ImageFormat::Gif => Self::gif(),
|
||||
ImageFormat::Bmp => Self::bmp(),
|
||||
ImageFormat::Svg => Self::svg(),
|
||||
ImageFormat::Ico => Self::ico(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1645,6 +1646,11 @@ impl UTType {
|
||||
Self(unsafe { ns_string("public.svg-image") })
|
||||
}
|
||||
|
||||
pub fn ico() -> Self {
|
||||
// https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/ico
|
||||
Self(unsafe { ns_string("com.microsoft.ico") })
|
||||
}
|
||||
|
||||
pub fn tiff() -> Self {
|
||||
// https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/tiff
|
||||
Self(unsafe { NSPasteboardTypeTIFF }) // This is a rare case where there's a built-in NSPasteboardType
|
||||
|
||||
Reference in New Issue
Block a user