fix: retry reading clipboard if data is empty

This commit is contained in:
Ashley Wulber 2026-03-27 11:51:16 -04:00 committed by Jacob Kauffmann
parent cf328771c3
commit 1c1f8fdf6e

View file

@ -3890,6 +3890,24 @@ impl Application for App {
// Use cached clipboard data if available (needed for Wayland popups)
match &self.clipboard_cache {
ClipboardCache::Files(contents) => {
if contents.paths.is_empty() {
return iced::Task::future(tokio::time::sleep(
std::time::Duration::from_millis(300),
))
.discard()
.chain(
clipboard::read_data::<ClipboardPaste>().map(
move |contents_opt| match contents_opt {
Some(contents) => cosmic::action::app(
Message::PasteContents(to.clone(), contents),
),
None => {
cosmic::action::app(Message::PasteImage(to.clone()))
}
},
),
);
}
return self
.update(Message::PasteContents(to.clone(), contents.clone()));
}