Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(desktop-gpui): draw glass panes painted last, capture the probe window by area on X11
Richie McIlroyfeb6bff53aac
diff --git a/apps/desktop-gpui/Cargo.toml b/apps/desktop-gpui/Cargo.tomlindex 4bcf0a2bc..17820a1fd 100644--- a/apps/desktop-gpui/Cargo.toml+++ b/apps/desktop-gpui/Cargo.toml@@ -333,6 +333,10 @@ debug = "line-tables-only"[profile.dev.package.cap-gpui-kernels]opt-level = 3+# The glass probe renders the CPU model of every scene it captures.+[profile.dev.package.cap-glass]+opt-level = 3+# Incremental halves a one-line rebuild for about 2 GB of cache, and line tables# cut its codegen and link time; breakpoints and backtraces keep their lines.[profile.dev.package.cap-desktop-gpui]diff --git a/apps/desktop-gpui/glass/presets.json b/apps/desktop-gpui/glass/presets.jsonindex 9953d4dfe..71c9adcb2 100644--- a/apps/desktop-gpui/glass/presets.json+++ b/apps/desktop-gpui/glass/presets.json@@ -1,214 +1,82 @@{- "regular-light": {- "blur_k": 0.19,- "blur_max": 21,- "rim_k": 0.24,- "rim_max": 24,- "bend": -2,- "lens_curve": 0.4,- "poly": [- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0- ],- "opacity": 0.6,- "line": 0,- "line_lit": 0,- "line_width": 1,- "light_angle": -2.3,- "glow": 0,- "glow_width": 4,- "hairline": [- 0.86,- -0.12,- 0.92,- -0.08- ]- },- "regular-dark": {- "blur_k": 0.19,- "blur_max": 21,- "rim_k": 0.24,- "rim_max": 24,- "bend": -2,- "lens_curve": 0.4,- "poly": [- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0- ],- "opacity": 0.6,- "line": 0,- "line_lit": 0,- "line_width": 1,- "light_angle": -2.3,- "glow": 0,- "glow_width": 4,- "hairline": [- 0.86,- -0.12,- 0.92,- -0.08- ]- },- "clear-light": {- "blur_k": 0.19,- "blur_max": 21,- "rim_k": 0.24,- "rim_max": 24,- "bend": -2,- "lens_curve": 0.4,- "poly": [- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0- ],- "opacity": 0.6,- "line": 0,- "line_lit": 0,- "line_width": 1,- "light_angle": -2.3,- "glow": 0,- "glow_width": 4,- "hairline": [- 0.86,- -0.12,- 0.92,- -0.08- ]- },- "clear-dark": {- "blur_k": 0.19,- "blur_max": 21,- "rim_k": 0.24,- "rim_max": 24,- "bend": -2,- "lens_curve": 0.4,- "poly": [- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 1,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0,- 0.0- ],- "opacity": 0.6,- "line": 0,- "line_lit": 0,- "line_width": 1,- "light_angle": -2.3,- "glow": 0,- "glow_width": 4,- "hairline": [- 0.86,- -0.12,- 0.92,- -0.08- ]- }-}\ No newline at end of file+ "regular-light": {+ "blur_k": 0.19,+ "blur_max": 21,+ "rim_k": 0.24,+ "rim_max": 24,+ "bend": -2,+ "lens_curve": 0.4,+ "poly": [+ 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0,+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0+ ],+ "opacity": 0.6,+ "line": 0,+ "line_lit": 0,+ "line_width": 1,+ "light_angle": -2.3,+ "glow": 0,+ "glow_width": 4,+ "hairline": [0.86, -0.12, 0.92, -0.08]+ },+ "regular-dark": {+ "blur_k": 0.19,+ "blur_max": 21,+ "rim_k": 0.24,+ "rim_max": 24,+ "bend": -2,+ "lens_curve": 0.4,+ "poly": [+ 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0,+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0+ ],+ "opacity": 0.6,+ "line": 0,+ "line_lit": 0,+ "line_width": 1,+ "light_angle": -2.3,+ "glow": 0,+ "glow_width": 4,+ "hairline": [0.86, -0.12, 0.92, -0.08]+ },+ "clear-light": {+ "blur_k": 0.19,+ "blur_max": 21,+ "rim_k": 0.24,+ "rim_max": 24,+ "bend": -2,+ "lens_curve": 0.4,+ "poly": [+ 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0,+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0+ ],+ "opacity": 0.6,+ "line": 0,+ "line_lit": 0,+ "line_width": 1,+ "light_angle": -2.3,+ "glow": 0,+ "glow_width": 4,+ "hairline": [0.86, -0.12, 0.92, -0.08]+ },+ "clear-dark": {+ "blur_k": 0.19,+ "blur_max": 21,+ "rim_k": 0.24,+ "rim_max": 24,+ "bend": -2,+ "lens_curve": 0.4,+ "poly": [+ 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0,+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0+ ],+ "opacity": 0.6,+ "line": 0,+ "line_lit": 0,+ "line_width": 1,+ "light_angle": -2.3,+ "glow": 0,+ "glow_width": 4,+ "hairline": [0.86, -0.12, 0.92, -0.08]+ }+}diff --git a/apps/desktop-gpui/patches/zed-glass.patch b/apps/desktop-gpui/patches/zed-glass.patchindex 12d721a63..a42b32020 100644--- a/apps/desktop-gpui/patches/zed-glass.patch+++ b/apps/desktop-gpui/patches/zed-glass.patch@@ -77,7 +77,7 @@ index 6cc3562..6ea0576 100644#[derive(Debug, Copy, Clone)]diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs-index 4299e15..91bee9f 100644+index 4299e15..82cdc92 100644--- a/crates/gpui/src/window.rs+++ b/crates/gpui/src/window.rs@@ -13,7 +13,7 @@ use crate::{@@ -89,7 +89,7 @@ index 4299e15..91bee9f 100644StrikethroughStyle, Style, SubpixelSprite, SubscriberSet, Subscription, SystemWindowTab,SystemWindowTabController, TabStopMap, TaffyLayoutEngine, Task, TextRenderingMode, TextStyle,TextStyleRefinement, ThermalState, TransformationMatrix, Underline, UnderlineStyle,-@@ -4186,6 +4186,19 @@ impl Window {+@@ -4186,10 +4186,29 @@ impl Window {bounds: Bounds<Pixels>,corner_radii: Corners<Pixels>,blur_radius: Pixels,@@ -109,7 +109,17 @@ index 4299e15..91bee9f 100644) {self.invalidator.debug_assert_paint();let scale_factor = self.scale_factor();-@@ -4210,6 +4223,13 @@ impl Window {+ let content_mask = self.content_mask().scale(scale_factor);++ // One layer gives the splitter and the blur the same order, so the++ // renderer paints the blur before the splitter's batch even when++ // nothing else is painted above it. The extra 2px covers glass's++ // hairline.++ let layer_bounds = bounds.scale(scale_factor).dilate(ScaledPixels(2.));++ self.next_frame.scene.push_layer(layer_bounds);+ // Invisible splitter primitive: forces a batch boundary at this order+ // so the renderer can break its render pass exactly here.+ self.next_frame.scene.insert_primitive(Shadow {+@@ -4210,7 +4229,15 @@ impl Window {bounds: bounds.scale(scale_factor),content_mask,corner_radii: corner_radii.scale(scale_factor),@@ -121,8 +131,10 @@ index 4299e15..91bee9f 100644+ ..glass+ },});++ self.next_frame.scene.pop_layer();}+ /// Paint one or more quads into the scene for the next frame at the current stacking context.diff --git a/crates/gpui_macos/build.rs b/crates/gpui_macos/build.rsindex 70e9a0b..79415df 100644--- a/crates/gpui_macos/build.rsdiff --git a/apps/desktop-gpui/src/glass_probe.rs b/apps/desktop-gpui/src/glass_probe.rsindex 40760fee5..2abead04d 100644--- a/apps/desktop-gpui/src/glass_probe.rs+++ b/apps/desktop-gpui/src/glass_probe.rs@@ -241,16 +241,26 @@ fn window_target(window: &Window) -> Option<ScreenCaptureTarget> {})}+/// Cap's own windows are not in its X11 window list, so the probe captures+/// the window's area of the display; it hides every other Cap window first.#[cfg(target_os = "linux")]fn window_target(window: &Window) -> Option<ScreenCaptureTarget> {- use raw_window_handle::{HasWindowHandle, RawWindowHandle};+ use scap_targets::bounds::{LogicalBounds, LogicalPosition, LogicalSize};- let number = match HasWindowHandle::window_handle(window).ok()?.as_raw() {- RawWindowHandle::Xlib(handle) => handle.window as u64,- RawWindowHandle::Xcb(handle) => u64::from(handle.window.get()),- _ => return None,- };- Some(ScreenCaptureTarget::Window {- id: number.to_string().parse().ok()?,+ let display = scap_targets::Display::primary();+ let bounds = window.bounds();+ let origin = display.raw_handle().logical_bounds()?.position();+ Some(ScreenCaptureTarget::Area {+ screen: display.id(),+ bounds: LogicalBounds::new(+ LogicalPosition::new(+ f64::from(f32::from(bounds.origin.x)) - origin.x(),+ f64::from(f32::from(bounds.origin.y)) - origin.y(),+ ),+ LogicalSize::new(+ f64::from(f32::from(bounds.size.width)),+ f64::from(f32::from(bounds.size.height)),+ ),+ ),})}diff --git a/scripts/glass-probe/run.sh b/scripts/glass-probe/run.shindex 82e55fff8..dabac71e9 100755--- a/scripts/glass-probe/run.sh+++ b/scripts/glass-probe/run.sh@@ -25,7 +25,7 @@ env CAP_GPUI_APP_DATA_DIR="$OUT/profile" \"$APP" > "$OUT/app.log" 2>&1 &pid=$!-for _ in $(seq 1 600); do+for _ in $(seq 1 1200); do[ -s "$report" ] && breakkill -0 "$pid" 2>/dev/null || breaksleep 0.5