Add rustfmt.toml
Add rustfmt.toml that is being used by projects under smithay's umbrella.
This commit is contained in:
parent
7fc533d55f
commit
597086c42c
8 changed files with 29 additions and 84 deletions
12
src/env.rs
12
src/env.rs
|
|
@ -20,11 +20,7 @@ impl SmithayClipboard {
|
|||
let mut seats = SeatHandler::new();
|
||||
let data_device_manager = DataDeviceHandler::init(&mut seats);
|
||||
let primary_selection_manager = PrimarySelectionHandler::init(&mut seats);
|
||||
Self {
|
||||
seats,
|
||||
primary_selection_manager,
|
||||
data_device_manager,
|
||||
}
|
||||
Self { seats, primary_selection_manager, data_device_manager }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,13 +40,11 @@ impl PrimarySelectionHandling for SmithayClipboard {
|
|||
seat: &WlSeat,
|
||||
f: F,
|
||||
) -> Result<(), ()> {
|
||||
self.primary_selection_manager
|
||||
.with_primary_selection(seat, f)
|
||||
self.primary_selection_manager.with_primary_selection(seat, f)
|
||||
}
|
||||
|
||||
fn get_primary_selection_manager(&self) -> Option<PrimarySelectionDeviceManager> {
|
||||
self.primary_selection_manager
|
||||
.get_primary_selection_manager()
|
||||
self.primary_selection_manager.get_primary_selection_manager()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
14
src/lib.rs
14
src/lib.rs
|
|
@ -32,18 +32,10 @@ impl Clipboard {
|
|||
let (clipboard_reply_sender, request_receiver) = mpsc::channel();
|
||||
|
||||
let name = String::from("smithay-clipboard");
|
||||
let clipboard_thread = worker::spawn(
|
||||
name,
|
||||
display,
|
||||
clipboard_request_receiver,
|
||||
clipboard_reply_sender,
|
||||
);
|
||||
let clipboard_thread =
|
||||
worker::spawn(name, display, clipboard_request_receiver, clipboard_reply_sender);
|
||||
|
||||
Self {
|
||||
request_receiver,
|
||||
request_sender,
|
||||
clipboard_thread,
|
||||
}
|
||||
Self { request_receiver, request_sender, clipboard_thread }
|
||||
}
|
||||
|
||||
/// Load clipboard data.
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ macro_rules! handle_load {
|
|||
}
|
||||
};
|
||||
|
||||
$queue
|
||||
.sync_roundtrip(&mut (), |_, _, _| unreachable!())
|
||||
.unwrap();
|
||||
$queue.sync_roundtrip(&mut (), |_, _, _| unreachable!()).unwrap();
|
||||
|
||||
let mut contents = String::new();
|
||||
let result = reader.read_to_string(&mut contents).map(|_| {
|
||||
|
|
@ -67,14 +65,12 @@ macro_rules! handle_store {
|
|||
($env:ident,
|
||||
$sel_source:ident, $sel_device:ident, $event_ty:ident,
|
||||
$seat:ident, $serial:ident, $queue:ident, $contents:ident) => {
|
||||
let data_source = $env.$sel_source(
|
||||
vec![MimeType::TextPlainUtf8.to_string()],
|
||||
move |event, _| {
|
||||
let data_source =
|
||||
$env.$sel_source(vec![MimeType::TextPlainUtf8.to_string()], move |event, _| {
|
||||
if let $event_ty::Send { mut pipe, .. } = event {
|
||||
write!(pipe, "{}", $contents).unwrap();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
let _ = $env.$sel_device(&$seat, |device| {
|
||||
device.set_selection(&Some(data_source), $serial);
|
||||
|
|
@ -86,11 +82,7 @@ macro_rules! handle_store {
|
|||
|
||||
/// Reply an error to a clipboard master.
|
||||
pub fn reply_error(tx: &Sender<Result<String>>, description: &str) {
|
||||
tx.send(Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
description,
|
||||
)))
|
||||
.unwrap();
|
||||
tx.send(Err(std::io::Error::new(std::io::ErrorKind::Other, description))).unwrap();
|
||||
}
|
||||
|
||||
/// Update seat and serial on pointer events.
|
||||
|
|
|
|||
|
|
@ -68,9 +68,7 @@ fn worker_impl(display: Display, request_rx: Receiver<Command>, reply_tx: Sender
|
|||
|
||||
let env = Environment::init(&display_proxy, SmithayClipboard::new());
|
||||
let req = queue.sync_roundtrip(&mut (), |_, _, _| unreachable!());
|
||||
let _ = req
|
||||
.and_then(|_| queue.sync_roundtrip(&mut (), |_, _, _| unreachable!()))
|
||||
.unwrap();
|
||||
let _ = req.and_then(|_| queue.sync_roundtrip(&mut (), |_, _, _| unreachable!())).unwrap();
|
||||
|
||||
// Get data device manager.
|
||||
let data_device_manager = env.get_global::<WlDataDeviceManager>();
|
||||
|
|
@ -211,9 +209,7 @@ fn worker_impl(display: Display, request_rx: Receiver<Command>, reply_tx: Sender
|
|||
// Reset the time we're sleeping.
|
||||
sa_tracker.reset_sleep();
|
||||
|
||||
queue
|
||||
.sync_roundtrip(&mut dispatch_data, |_, _, _| unimplemented!())
|
||||
.unwrap();
|
||||
queue.sync_roundtrip(&mut dispatch_data, |_, _, _| unimplemented!()).unwrap();
|
||||
|
||||
// Get latest observed seat and serial.
|
||||
let (seat, serial) = match dispatch_data.last_seat() {
|
||||
|
|
@ -274,9 +270,7 @@ fn worker_impl(display: Display, request_rx: Receiver<Command>, reply_tx: Sender
|
|||
}
|
||||
}
|
||||
|
||||
let pending_events = queue
|
||||
.dispatch_pending(&mut dispatch_data, |_, _, _| {})
|
||||
.unwrap();
|
||||
let pending_events = queue.dispatch_pending(&mut dispatch_data, |_, _, _| {}).unwrap();
|
||||
|
||||
// If some application is trying to spam us when there're no seats, it's likely that
|
||||
// someone is trying to paste from us.
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ pub struct SeatData {
|
|||
|
||||
impl SeatData {
|
||||
pub fn new(seat: WlSeat, keyboard: Option<WlKeyboard>, pointer: Option<WlPointer>) -> Self {
|
||||
SeatData {
|
||||
seat,
|
||||
keyboard,
|
||||
pointer,
|
||||
}
|
||||
SeatData { seat, keyboard, pointer }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,7 @@ impl SleepAmountTracker {
|
|||
/// `max_time_to_sleep` - maximum sleep value for a thread.
|
||||
/// ``
|
||||
pub fn new(max_time_to_sleep: u8, max_warm_wakeups: u8) -> Self {
|
||||
Self {
|
||||
max_time_to_sleep,
|
||||
max_warm_wakeups,
|
||||
warm_wakeup: 0,
|
||||
time_to_sleep: 0,
|
||||
}
|
||||
Self { max_time_to_sleep, max_warm_wakeups, warm_wakeup: 0, time_to_sleep: 0 }
|
||||
}
|
||||
|
||||
/// Reset the current sleep amount to 0ms.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue