Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(windows): use close/minimize instead of hide to prevent DirectComposition ghost artifacts

ManthanNimodiyaa72d2128f45a
diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rs
index 3bc845923..68cc72205 100644
--- a/apps/desktop/src-tauri/src/general_settings.rs
+++ b/apps/desktop/src-tauri/src/general_settings.rs
@@ -85,7 +85,14 @@ pub fn default_studio_recording_quality() -> StudioRecordingQuality {
impl MainWindowRecordingStartBehaviour {
pub fn perform(&self, window: &tauri::WebviewWindow) -> tauri::Result<()> {
match self {
- Self::Close => window.hide(),
+ Self::Close => {
+ // On Windows, hide() leaves the DirectComposition surface composited on screen as
+ // a white ghost box. minimize() releases the surface without leaving an artifact.
+ #[cfg(windows)]
+ return window.minimize();
+ #[cfg(not(windows))]
+ window.hide()
+ }
Self::Minimise => window.minimize(),
}
}
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index cbbd81bc5..97b302ae6 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -3011,11 +3011,15 @@ async fn handle_recording_end(
let _ = window.hide();
}
- // Destroy any target-select overlays that were hidden when recording started
- // so they don't reappear when the main window comes back.
+ // Destroy any target-select overlays so they don't reappear when the main window comes back.
+ // On Windows, hide() leaves the DirectComposition transparency surface composited on screen
+ // (ghost overlay); closing the window releases the surface entirely.
let focus_manager = handle.try_state::<crate::target_select_overlay::WindowFocusManager>();
for (label, window) in handle.webview_windows() {
if let Ok(CapWindowId::TargetSelectOverlay { display_id }) = CapWindowId::from_str(&label) {
+ #[cfg(windows)]
+ let _ = window.close();
+ #[cfg(not(windows))]
hide_overlay(&window);
if let Some(ref fm) = focus_manager {
fm.destroy(&display_id, handle.global_shortcut());
diff --git a/apps/desktop/src-tauri/src/target_select_overlay.rs b/apps/desktop/src-tauri/src/target_select_overlay.rs
index f930a8b4c..f48963b39 100644
--- a/apps/desktop/src-tauri/src/target_select_overlay.rs
+++ b/apps/desktop/src-tauri/src/target_select_overlay.rs
@@ -325,6 +325,11 @@ pub fn close_target_select_overlay_windows(app: &AppHandle) {
for (id, window) in app.webview_windows() {
if let Ok(CapWindowId::TargetSelectOverlay { display_id }) = CapWindowId::from_str(&id) {
saw_overlay = true;
+ // On Windows, hide() leaves the DirectComposition transparency surface composited on
+ // screen (ghost overlay). Closing the window fully releases the surface.
+ #[cfg(windows)]
+ let _ = window.close();
+ #[cfg(not(windows))]
hide_overlay(&window);
if let Some(state) = state.as_ref() {
state.destroy(&display_id, app.global_shortcut());