refactor: update smithay-clipboard

This commit is contained in:
Ashley Wulber 2024-03-26 17:32:09 -04:00
parent 4e05e3c657
commit 5bfbaae180
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
9 changed files with 70 additions and 35 deletions

View file

@ -1,5 +1,7 @@
use x11rb::errors::{ConnectError, ConnectionError, ReplyError};
use x11rb::protocol::xproto::Atom;
use x11rb::{
errors::{ConnectError, ConnectionError, ReplyError},
protocol::xproto::Atom,
};
use std::sync::mpsc;

View file

@ -3,17 +3,23 @@ mod error;
pub use error::Error;
use x11rb::connection::Connection as _;
use x11rb::errors::ConnectError;
use x11rb::protocol::xproto::{self, Atom, AtomEnum, EventMask, Window};
use x11rb::protocol::Event;
use x11rb::rust_connection::RustConnection as Connection;
use x11rb::wrapper::ConnectionExt;
use x11rb::{
connection::Connection as _,
errors::ConnectError,
protocol::{
xproto::{self, Atom, AtomEnum, EventMask, Window},
Event,
},
rust_connection::RustConnection as Connection,
wrapper::ConnectionExt,
};
use std::collections::HashMap;
use std::sync::{Arc, RwLock};
use std::thread;
use std::time::{Duration, Instant};
use std::{
collections::HashMap,
sync::{Arc, RwLock},
thread,
time::{Duration, Instant},
};
const POLL_DURATION: std::time::Duration = Duration::from_micros(50);
@ -60,13 +66,16 @@ impl Clipboard {
self.read_selection(self.reader.atoms.clipboard)
}
/// Read the current PRIMARY [`Clipboard`] value.
pub fn read_primary(&self) -> Result<String, Error> {
self.read_selection(self.reader.atoms.primary)
}
fn write_selection(&mut self, selection: Atom, contents: String) -> Result<(), Error> {
fn write_selection(
&mut self,
selection: Atom,
contents: String,
) -> Result<(), Error> {
let target = self.writer.atoms.utf8_string;
self.selections
@ -124,9 +133,13 @@ impl Clipboard {
selection,
target,
property,
x11rb::CURRENT_TIME, // FIXME ^
// Clients should not use CurrentTime for the time argument of a ConvertSelection request.
// Instead, they should use the timestamp of the event that caused the request to be made.
x11rb::CURRENT_TIME, /* FIXME ^
* Clients should not use CurrentTime for
* the time argument of a ConvertSelection
* request.
* Instead, they should use the timestamp
* of the event that caused the request to
* be made. */
)?;
let _ = self.reader.connection.flush()?;
@ -186,8 +199,9 @@ impl Clipboard {
continue;
};
// Note that setting the property argument to None indicates that the
// conversion requested could not be made.
// Note that setting the property argument to None indicates
// that the conversion requested could
// not be made.
if event.property == AtomEnum::NONE.into() {
break;
}