From fd1dc155768ac72a98e9b6c1ac09f22a10f5869b Mon Sep 17 00:00:00 2001 From: ClSlaid Date: Sun, 29 Oct 2023 12:07:21 +0800 Subject: [PATCH] patch: re apply time limited api in common clipboard when no content in text clipboard, it will wait forever Signed-off-by: ClSlaid --- libs/clipboard/src/platform/unix/x11.rs | 4 +--- src/common.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/clipboard/src/platform/unix/x11.rs b/libs/clipboard/src/platform/unix/x11.rs index 72fa018e0..9f4c9e4c6 100644 --- a/libs/clipboard/src/platform/unix/x11.rs +++ b/libs/clipboard/src/platform/unix/x11.rs @@ -16,8 +16,6 @@ use super::{encode_path_to_uri, parse_plain_uri_list, SysClipboard}; static X11_CLIPBOARD: OnceCell = OnceCell::new(); -const X11_CLIPBOARD_TIMEOUT: std::time::Duration = std::time::Duration::from_millis(130); - fn get_clip() -> Result<&'static Clipboard, CliprdrError> { X11_CLIPBOARD.get_or_try_init(|| Clipboard::new().map_err(|_| CliprdrError::CliprdrInit)) } @@ -63,7 +61,7 @@ impl X11Clipboard { // NOTE: // # why not use `load_wait` // load_wait is likely to wait forever, which is not what we want - let res = get_clip()?.load(clip, target, prop, X11_CLIPBOARD_TIMEOUT); + let res = get_clip()?.load_wait(clip, target, prop); match res { Ok(res) => Ok(res), Err(x11_clipboard::error::Error::UnexpectedType(_)) => Ok(vec![]), diff --git a/src/common.rs b/src/common.rs index 7435f4c6e..4287d5aa3 100644 --- a/src/common.rs +++ b/src/common.rs @@ -87,7 +87,7 @@ impl ClipboardContext { let clip = self.clip; let prop = self.prop; - const TIMEOUT: std::time::Duration = std::time::Duration::from_millis(100); + const TIMEOUT: std::time::Duration = std::time::Duration::from_millis(120); let text_content = get_clipboard()? .load(clip, self.string_getter, prop, TIMEOUT)