Skip to content

Commit 8086e75

Browse files
committed
Suppress spurious x11_clipboard Error::Owner errors
The x11_clipboard::Clipboard::store() method has a racy ownership check that is causing spurious warnings to be emitted in alacritty [0]. x11_clipboard is unwilling to accept a fix for the issue [1], citing "maintenance mode". Let's do the next best thing and ignore the error in our clipboard wrapper: for our intents and purposes this variant serves no purpose, because it only detects clipboard ownership changes *after* contents have already been stored, at which point the job could equally well be considered done. [0] alacritty/alacritty#6978 [1] quininer/x11-clipboard#53 Fixes: alacritty/alacritty#6978 Signed-off-by: Daniel Müller <deso@posteo.net>
1 parent c429615 commit 8086e75

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/x11_clipboard.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::marker::PhantomData;
1616
use std::time::Duration;
1717

1818
use x11_clipboard::Atom;
19+
use x11_clipboard::error::Error;
1920
use x11_clipboard::{Atoms, Clipboard as X11Clipboard};
2021

2122
use crate::common::*;
@@ -67,6 +68,14 @@ where
6768
}
6869

6970
fn set_contents(&mut self, data: String) -> Result<()> {
70-
Ok(self.0.store(S::atom(&self.0.setter.atoms), self.0.setter.atoms.utf8_string, data)?)
71+
self.0
72+
.store(S::atom(&self.0.setter.atoms), self.0.setter.atoms.utf8_string, data)
73+
.or_else(|err| match err {
74+
// The `Owner` error can be spurious, caused by a racy
75+
// ownership check. The "store" will still have
76+
// happened, so it is safe to ignore.
77+
Error::Owner => Ok(()),
78+
e => Err(e.into()),
79+
})
7180
}
7281
}

0 commit comments

Comments
 (0)