fix: clipboard, cmd ipc (#9270)
1. Send raw contents if `content_len` > 1024*3. 2. Send raw contents if it is not empty. 3. Try read clipboard again if no data from cm. Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
4150036589
commit
26ebd0deb9
@ -95,6 +95,10 @@ impl Handler {
|
|||||||
log::error!("Failed to read clipboard from cm: {}", e);
|
log::error!("Failed to read clipboard from cm: {}", e);
|
||||||
}
|
}
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
|
// Skip sending empty clipboard data.
|
||||||
|
// Maybe there's something wrong reading the clipboard data in cm, but no error msg is returned.
|
||||||
|
// The clipboard data should not be empty, the last line will try again to get the clipboard data.
|
||||||
|
if !data.is_empty() {
|
||||||
let mut msg = Message::new();
|
let mut msg = Message::new();
|
||||||
let multi_clipboards = MultiClipboards {
|
let multi_clipboards = MultiClipboards {
|
||||||
clipboards: data
|
clipboards: data
|
||||||
@ -117,6 +121,7 @@ impl Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
check_clipboard(&mut self.ctx, ClipboardSide::Host, false)
|
check_clipboard(&mut self.ctx, ClipboardSide::Host, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,10 +498,10 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
|||||||
let (content, next_raw) = {
|
let (content, next_raw) = {
|
||||||
// TODO: find out a better threshold
|
// TODO: find out a better threshold
|
||||||
if content_len > 1024 * 3 {
|
if content_len > 1024 * 3 {
|
||||||
(c.content, false)
|
|
||||||
} else {
|
|
||||||
raw_contents.extend(c.content);
|
raw_contents.extend(c.content);
|
||||||
(bytes::Bytes::new(), true)
|
(bytes::Bytes::new(), true)
|
||||||
|
} else {
|
||||||
|
(c.content, false)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
main_data.push(ClipboardNonFile {
|
main_data.push(ClipboardNonFile {
|
||||||
@ -515,8 +515,10 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
allow_err!(self.stream.send(&Data::ClipboardNonFile(Some(("".to_owned(), main_data)))).await);
|
allow_err!(self.stream.send(&Data::ClipboardNonFile(Some(("".to_owned(), main_data)))).await);
|
||||||
|
if !raw_contents.is_empty() {
|
||||||
allow_err!(self.stream.send_raw(raw_contents.into()).await);
|
allow_err!(self.stream.send_raw(raw_contents.into()).await);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
allow_err!(self.stream.send(&Data::ClipboardNonFile(Some((format!("{}", e), vec![])))).await);
|
allow_err!(self.stream.send(&Data::ClipboardNonFile(Some((format!("{}", e), vec![])))).await);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user