Reapply support for X11 screenshare (#28160)

Reapplies #27807 after [revert due to not building on
ARM](https://github.com/zed-industries/zed/pull/28141) by updating scap
to include [a fix to its build on
ARM](https://github.com/zed-industries/scap/commit/08f0a01417505cc0990b9931a37e5120db92e0d0)

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
Michael Sloan
2025-04-06 11:25:29 -06:00
committed by GitHub
co-authored by Marshall Bowers
parent 0708d476ca
commit 8cfb9beb17
20 changed files with 618 additions and 47 deletions
+4
View File
@@ -552,6 +552,10 @@ impl Platform for MacPlatform {
.collect()
}
fn is_screen_capture_supported(&self) -> bool {
true
}
fn screen_capture_sources(
&self,
) -> oneshot::Receiver<Result<Vec<Box<dyn ScreenCaptureSource>>>> {
@@ -1,7 +1,7 @@
use crate::{
Pixels, Size,
DevicePixels, ForegroundExecutor, Size,
platform::{ScreenCaptureFrame, ScreenCaptureSource, ScreenCaptureStream},
px, size,
size,
};
use anyhow::{Result, anyhow};
use block::ConcreteBlock;
@@ -48,7 +48,7 @@ const FRAME_CALLBACK_IVAR: &str = "frame_callback";
const SCStreamOutputTypeScreen: NSInteger = 0;
impl ScreenCaptureSource for MacScreenCaptureSource {
fn resolution(&self) -> Result<Size<Pixels>> {
fn resolution(&self) -> Result<Size<DevicePixels>> {
unsafe {
let display_id: CGDirectDisplayID = msg_send![self.sc_display, displayID];
let display_mode_ref = CGDisplayCopyDisplayMode(display_id);
@@ -56,13 +56,17 @@ impl ScreenCaptureSource for MacScreenCaptureSource {
let height = CGDisplayModeGetPixelHeight(display_mode_ref);
CGDisplayModeRelease(display_mode_ref);
Ok(size(px(width as f32), px(height as f32)))
Ok(size(
DevicePixels(width as i32),
DevicePixels(height as i32),
))
}
}
fn stream(
&self,
frame_callback: Box<dyn Fn(ScreenCaptureFrame)>,
_foreground_executor: &ForegroundExecutor,
frame_callback: Box<dyn Fn(ScreenCaptureFrame) + Send>,
) -> oneshot::Receiver<Result<Box<dyn ScreenCaptureStream>>> {
unsafe {
let stream: id = msg_send![class!(SCStream), alloc];