mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-11-26 07:38:55 +00:00
fix(windows): write the clipboard owner marker first (#16695)
The Windows clipboard setter empties the clipboard and writes each format in order, stopping at the first one that fails. With the marker written last, a failure after an earlier format succeeded could leave unmarked content on the clipboard. RustDesk could then read it back as a fresh local copy and return it, causing the controller to empty its clipboard again. For applications such as Excel, that destroys the application's copy state. Write the marker first on Windows so a partial write stays identifiable as RustDesk-owned. Other platforms keep appending it, so their payload order is unchanged. This covers a format failure before the marker is written, not a marker that is written but later missing or unreadable. Refs #16291
This commit is contained in:
1 parent
9382ab2607
commit
8d74ff0e57
1 file changed
+8
-2
+8
-2
@@ -281,10 +281,16 @@ fn do_update_clipboard_(mut to_update_data: Vec<ClipboardData>, side: ClipboardS
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
fn append_owner_marker(mut data: Vec<ClipboardData>, side: ClipboardSide) -> Vec<ClipboardData> {
|
||||
data.push(ClipboardData::Special((
|
||||
let marker = ClipboardData::Special((
|
||||
RUSTDESK_CLIPBOARD_OWNER_FORMAT.to_owned(),
|
||||
side.get_owner_data(),
|
||||
)));
|
||||
));
|
||||
// The Windows setter stops at the first format it fails to write, so a marker placed
|
||||
// last can be skipped, leaving content RustDesk no longer recognizes as its own.
|
||||
#[cfg(target_os = "windows")]
|
||||
data.insert(0, marker);
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
data.push(marker);
|
||||
data
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user