From 3538538562b7caea9f6046a7ecbd31cf0ef63313 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Tue, 1 Apr 2025 22:43:03 -0600 Subject: [PATCH 1/3] Add install of linux deps for building scap with `wayland` feature --- script/linux | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/script/linux b/script/linux index 98ae026896..bc46291023 100755 --- a/script/linux +++ b/script/linux @@ -30,6 +30,8 @@ if [[ -n $apt ]]; then libwayland-dev libx11-xcb-dev libxkbcommon-x11-dev + libdbus-1-dev + libpipewire-0.3-dev libssl-dev libzstd-dev libvulkan1 @@ -78,6 +80,8 @@ if [[ -n $dnf ]] || [[ -n $yum ]]; then wayland-devel libxcb-devel libxkbcommon-x11-devel + dbus-devel + pipewire-devel openssl-devel libzstd-devel vulkan-loader @@ -136,6 +140,7 @@ if [[ -n $zyp ]]; then alsa-devel clang cmake + dbus-1-devel fontconfig-devel gcc gcc-c++ @@ -150,6 +155,7 @@ if [[ -n $zyp ]]; then make mold openssl-devel + pipewire-devel sqlite3-devel tar wayland-devel @@ -175,6 +181,8 @@ if [[ -n $pacman ]]; then libgit2 libxcb libxkbcommon-x11 + dbus + libpipewire openssl zstd pkgconf @@ -203,6 +211,8 @@ if [[ -n $xbps ]]; then fontconfig-devel libxcb-devel libxkbcommon-devel + dbus-devel + pipewire-devel libzstd-devel openssl-devel wayland-devel From e095f83d2abab6197cbef1bd18abbc5bc80cf6b2 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Fri, 4 Apr 2025 14:15:10 -0600 Subject: [PATCH 2/3] Enable use of scap for screen capture on Wayland --- .../gpui/src/platform/linux/wayland/client.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 57d1dcec04..4f9b089615 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -68,7 +68,6 @@ use super::{ display::WaylandDisplay, window::{ImeInput, WaylandWindowStatePtr}, }; - use crate::platform::{PlatformWindow, blade::BladeContext}; use crate::{ AnyWindowHandle, Bounds, Capslock, CursorStyle, DOUBLE_CLICK_INTERVAL, DevicePixels, DisplayId, @@ -666,7 +665,7 @@ impl LinuxClient for WaylandClient { #[cfg(feature = "screen-capture")] fn is_screen_capture_supported(&self) -> bool { - false + true } #[cfg(feature = "screen-capture")] @@ -674,17 +673,10 @@ impl LinuxClient for WaylandClient { &self, ) -> futures::channel::oneshot::Receiver>>> { - // TODO: Get screen capture working on wayland. Be sure to try window resizing as that may - // be tricky. - // - // start_scap_default_target_source() - let (sources_tx, sources_rx) = futures::channel::oneshot::channel(); - sources_tx - .send(Err(anyhow::anyhow!( - "Wayland screen capture not yet implemented." - ))) - .ok(); - sources_rx + // todo! Try window resizing as that may have unexpected results. + crate::platform::scap_screen_capture::start_scap_default_target_source( + &self.0.borrow().common.foreground_executor, + ) } fn open_window( From 4dcb249f7e5c7416712679adb857c97ad05b5a37 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Thu, 10 Jul 2025 17:19:13 -0600 Subject: [PATCH 3/3] Conditionally depend on scap/wayland or scap/x11 features --- Cargo.lock | 98 ++++++++++++++++++++++++++++++++++++++++++ crates/gpui/Cargo.toml | 2 + 2 files changed, 100 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 163cba778a..81df7ea2b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -415,6 +415,16 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "annotate-snippets" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccaf7e9dfbb6ab22c82e473cd1a8a7bd313c19a5b7e40970f3d89ef5a5c9e81e" +dependencies = [ + "unicode-width 0.1.14", + "yansi-term", +] + [[package]] name = "anstream" version = "0.6.18" @@ -2016,6 +2026,7 @@ version = "0.69.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" dependencies = [ + "annotate-snippets", "bitflags 2.9.0", "cexpr", "clang-sys", @@ -3439,6 +3450,15 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "cookie-factory" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" +dependencies = [ + "futures 0.3.31", +] + [[package]] name = "copilot" version = "0.1.0" @@ -9307,6 +9327,34 @@ dependencies = [ "redox_syscall 0.5.11", ] +[[package]] +name = "libspa" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65f3a4b81b2a2d8c7f300643676202debd1b7c929dbf5c9bb89402ea11d19810" +dependencies = [ + "bitflags 2.9.0", + "cc", + "convert_case 0.6.0", + "cookie-factory", + "libc", + "libspa-sys", + "nix 0.27.1", + "nom", + "system-deps", +] + +[[package]] +name = "libspa-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf0d9716420364790e85cbb9d3ac2c950bde16a7dd36f3209b7dfdfc4a24d01f" +dependencies = [ + "bindgen 0.69.5", + "cc", + "system-deps", +] + [[package]] name = "libsqlite3-sys" version = "0.30.1" @@ -10328,6 +10376,17 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.9.0", + "cfg-if", + "libc", +] + [[package]] name = "nix" version = "0.28.0" @@ -11984,6 +12043,34 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pipewire" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08e645ba5c45109106d56610b3ee60eb13a6f2beb8b74f8dc8186cf261788dda" +dependencies = [ + "anyhow", + "bitflags 2.9.0", + "libc", + "libspa", + "libspa-sys", + "nix 0.27.1", + "once_cell", + "pipewire-sys", + "thiserror 1.0.69", +] + +[[package]] +name = "pipewire-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "849e188f90b1dda88fe2bfe1ad31fe5f158af2c98f80fb5d13726c44f3f01112" +dependencies = [ + "bindgen 0.69.5", + "libspa-sys", + "system-deps", +] + [[package]] name = "pkcs1" version = "0.7.5" @@ -14102,8 +14189,10 @@ dependencies = [ "anyhow", "cocoa 0.25.0", "core-graphics-helmer-fork", + "dbus", "log", "objc", + "pipewire", "rand 0.8.5", "screencapturekit", "screencapturekit-sys", @@ -19936,6 +20025,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" +[[package]] +name = "yansi-term" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" +dependencies = [ + "winapi", +] + [[package]] name = "yazi" version = "0.2.1" diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 4e718b4428..80e424029a 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -50,6 +50,7 @@ wayland = [ "filedescriptor", "xkbcommon", "open", + "scap?/wayland", ] x11 = [ "blade-graphics", @@ -66,6 +67,7 @@ x11 = [ "x11-clipboard", "filedescriptor", "open", + "scap?/x11", ] screen-capture = [ "scap",