From 3c574a41821170f89f38141a493e127145dbf82d Mon Sep 17 00:00:00 2001 From: fufesou Date: Sun, 21 Jun 2026 17:09:41 +0800 Subject: [PATCH] fix(wayland): clipboard, support ext-data-control (#15366) * fix(wayland): clipboard, support ext-data-control Signed-off-by: fufesou * fix(clipboard): restart stale listener and log join panics Signed-off-by: fufesou * update clipboard-master Signed-off-by: fufesou * refactor(clipboard): remove redundant stale listener cleanup Signed-off-by: fufesou --------- Signed-off-by: fufesou --- Cargo.lock | 15 +++++++-------- src/clipboard.rs | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 46edd8db0..8ec2d4a53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1324,7 +1324,7 @@ dependencies = [ [[package]] name = "clipboard-master" version = "4.0.0-beta.6" -source = "git+https://github.com/rustdesk-org/clipboard-master#ddc39f00a6211959489ae683aa6ae6eedf03a809" +source = "git+https://github.com/rustdesk-org/clipboard-master#7762d74e38db37cfeb6ded88c964b9cdbddfb6db" dependencies = [ "objc", "objc-foundation", @@ -9733,9 +9733,9 @@ dependencies = [ [[package]] name = "wayland-protocols-wlr" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd993de54a40a40fbe5601d9f1fbcaef0aebcc5fda447d7dc8f6dcbaae4f8953" +checksum = "efd94963ed43cf9938a090ca4f7da58eb55325ec8200c3848963e98dc25b78ec" dependencies = [ "bitflags 2.9.1", "wayland-backend", @@ -10838,16 +10838,15 @@ dependencies = [ [[package]] name = "wl-clipboard-rs" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de22eebb1d1e2bad2d970086e96da0e12cde0b411321e5b0f7b2a1f876aa26f" +checksum = "e9651471a32e87d96ef3a127715382b2d11cc7c8bb9822ded8a7cc94072eb0a3" dependencies = [ "libc", "log", "os_pipe", - "rustix 0.38.34", - "tempfile", - "thiserror 1.0.61", + "rustix 1.1.2", + "thiserror 2.0.17", "tree_magic_mini", "wayland-backend", "wayland-client", diff --git a/src/clipboard.rs b/src/clipboard.rs index 1300d72d7..d2a8a6653 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -868,6 +868,7 @@ pub mod clipboard_listener { .unwrap() .insert(name.clone(), tx); + cleanup_stale_listener(&mut listener_lock); if listener_lock.handle.is_none() { log::info!("Start clipboard listener thread"); let handler = Handler { @@ -893,6 +894,24 @@ pub mod clipboard_listener { Ok(()) } + fn cleanup_stale_listener(listener: &mut ClipboardListener) { + if !listener + .handle + .as_ref() + .map(|(_, h)| h.is_finished()) + .unwrap_or(false) + { + return; + } + if let Some((shutdown, h)) = listener.handle.take() { + log::warn!("Cleaning up stale clipboard listener handle"); + if let Err(e) = h.join() { + log::error!("Clipboard listener thread panicked during stale cleanup: {:?}", e); + } + drop(shutdown); + } + } + pub fn unsubscribe(name: &str) { log::info!("Unsubscribe clipboard listener: {}", name); let mut listener_lock = CLIPBOARD_LISTENER.lock().unwrap();