There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(electron): use CG* instead of NS* (#11668)
pengx17ee15b364d10d
diff --git a/packages/frontend/native/media_capture/src/macos/screen_capture_kit.rs b/packages/frontend/native/media_capture/src/macos/screen_capture_kit.rsindex 2481d89fa2..c98de4ab9a 100644--- a/packages/frontend/native/media_capture/src/macos/screen_capture_kit.rs+++ b/packages/frontend/native/media_capture/src/macos/screen_capture_kit.rs@@ -42,36 +42,33 @@ use crate::{};#[repr(C)]-#[derive(Debug, Copy, Clone)]-struct NSSize {+struct CGSize {width: f64,height: f64,}#[repr(C)]-#[derive(Debug, Copy, Clone)]-struct NSPoint {+struct CGPoint {x: f64,y: f64,}#[repr(C)]-#[derive(Debug, Copy, Clone)]-struct NSRect {- origin: NSPoint,- size: NSSize,+struct CGRect {+ origin: CGPoint,+ size: CGSize,}-unsafe impl Encode for NSSize {- const ENCODING: Encoding = Encoding::Struct("NSSize", &[f64::ENCODING, f64::ENCODING]);+unsafe impl Encode for CGSize {+ const ENCODING: Encoding = Encoding::Struct("CGSize", &[f64::ENCODING, f64::ENCODING]);}-unsafe impl Encode for NSPoint {- const ENCODING: Encoding = Encoding::Struct("NSPoint", &[f64::ENCODING, f64::ENCODING]);+unsafe impl Encode for CGPoint {+ const ENCODING: Encoding = Encoding::Struct("CGPoint", &[f64::ENCODING, f64::ENCODING]);}-unsafe impl Encode for NSRect {- const ENCODING: Encoding = Encoding::Struct("NSRect", &[<NSPoint>::ENCODING, <NSSize>::ENCODING]);+unsafe impl Encode for CGRect {+ const ENCODING: Encoding = Encoding::Struct("CGRect", &[<CGPoint>::ENCODING, <CGSize>::ENCODING]);}static RUNNING_APPLICATIONS: LazyLock<@@ -250,7 +247,7 @@ impl Application {}let resized_image: *mut AnyObject =- msg_send![resized_image, initWithSize: NSSize { width: 64.0, height: 64.0 }];+ msg_send![resized_image, initWithSize: CGSize { width: 64.0, height: 64.0 }];if resized_image.is_null() {return Ok(Buffer::from(Vec::<u8>::new()));}@@ -258,16 +255,24 @@ impl Application {let _: () = msg_send![resized_image, lockFocus];// Define drawing rectangle for 64x64 image- let draw_rect = NSRect {- origin: NSPoint { x: 0.0, y: 0.0 },- size: NSSize {+ let draw_rect = CGRect {+ origin: CGPoint { x: 0.0, y: 0.0 },+ size: CGSize {width: 64.0,height: 64.0,},};+ let from_rect = CGRect {+ origin: CGPoint { x: 0.0, y: 0.0 },+ size: CGSize {+ width: 0.0,+ height: 0.0,+ },+ };+// Draw the original icon into draw_rect (using NSCompositingOperationCopy = 2)- let _: () = msg_send![icon, drawInRect: draw_rect, fromRect: NSRect { origin: NSPoint { x: 0.0, y: 0.0 }, size: NSSize { width: 0.0, height: 0.0 } }, operation: 2, fraction: 1.0];+ let _: () = msg_send![icon, drawInRect: draw_rect, fromRect: from_rect, operation: 2u64, fraction: 1.0];let _: () = msg_send![resized_image, unlockFocus];// Get TIFF representation from the downsized image@@ -314,14 +319,14 @@ impl Application {// Get PNG data with propertieslet png_data: *mut AnyObject =- msg_send![bitmap, representationUsingType: 4, properties: properties]; // 4 = PNG+ msg_send![bitmap, representationUsingType: 4u64, properties: properties]; // 4 = PNGif png_data.is_null() {return Ok(Buffer::from(Vec::<u8>::new()));}// Get bytes from NSData- let bytes: *const u8 = msg_send![png_data, bytes];+ let bytes: *const libc::c_void = msg_send![png_data, bytes];let length: usize = msg_send![png_data, length];if bytes.is_null() {@@ -329,7 +334,7 @@ impl Application {}// Copy bytes into a Vec<u8> instead of using the original memory- let data = std::slice::from_raw_parts(bytes, length).to_vec();+ let data = std::slice::from_raw_parts(bytes as *const u8, length).to_vec();Ok(Buffer::from(data))}});