Browse Source

Clippy lints

main
Johannes Wünsche 8 months ago
parent
commit
f01efaf6c3
Signed by: johannes
GPG Key ID: 2511CF80B7C283AB
  1. 2
      src/bin/enkeictl.rs
  2. 4
      src/main.rs
  3. 2
      src/util/resource_loader.rs
  4. 31
      src/watchdog/ipc.rs
  5. 62
      src/worker.rs

2
src/bin/enkeictl.rs

@ -99,7 +99,7 @@ fn main() {
path: args.file,
mode: args.mode,
};
if let Err(_) = write(msg) {
if write(msg).is_err() {
eprintln!("Could not connect to enkei. Please make sure that $XDG_RUNTIME_DIR is set and enkei is running.");
std::process::exit(1);
}

4
src/main.rs

@ -171,7 +171,7 @@ pub struct Args {
mode: Option<Mode>,
}
#[derive(ArgEnum, Clone, Debug, Deserialize)]
#[derive(ArgEnum, Clone, Copy, Debug, Deserialize)]
pub enum Mode {
Static,
Dynamic,
@ -287,7 +287,7 @@ fn get_metadata_for_path(
) {
Ok(MetadataReader::static_configuration(path))
} else {
return Err(ApplicationError::InvalidDataType);
Err(ApplicationError::InvalidDataType)
}
}
}

2
src/util/resource_loader.rs

@ -49,7 +49,7 @@ impl ResourceLoader {
scaling: Scaling,
filter: Filter,
) -> Result<&Vec<u8>, ImageError> {
let scale_key = (path.clone(), mode.clone(), filter.clone(), scaling.clone());
let scale_key = (path.clone(), mode.clone(), filter, scaling);
// workaround as this introduces nastier non-lexical lifetimes
if self.scaled.cache_get(&scale_key).is_some() {
// The scaling and filter cannot differ

31
src/watchdog/ipc.rs

@ -45,26 +45,23 @@ fn spawn_inner(tx: Sender<WorkerMessage>) -> Result<(), InnerError> {
// TODO: Clean up when leaving this may create situations where we can't
// find the receiver side anymore and the sending is refused.
std::fs::remove_file(&socket_path).ok();
let socket = UnixListener::bind(&socket_path).map_err(|e| InnerError::SocketCreation(e))?;
let socket = UnixListener::bind(&socket_path).map_err(InnerError::SocketCreation)?;
std::thread::spawn(move || loop {
match socket.accept() {
Ok((mut socket, _)) => {
let mut res = Vec::new();
socket.read_to_end(&mut res).ok();
if let Ok(msg) = bincode::deserialize::<Message>(&res) {
if msg.path.exists() && msg.path.is_file() {
debug!("Received path {{ {:?} }}", msg.path);
tx.send(WorkerMessage::IPCConfigUpdate(msg))
.expect("Cannot fail");
} else {
debug!(
"Received a message {{ {:?} }} but it was no valid path. Dropping...",
msg.path
)
}
if let Ok((mut socket, _)) = socket.accept() {
let mut res = Vec::new();
socket.read_to_end(&mut res).ok();
if let Ok(msg) = bincode::deserialize::<Message>(&res) {
if msg.path.exists() && msg.path.is_file() {
debug!("Received path {{ {:?} }}", msg.path);
tx.send(WorkerMessage::IPCConfigUpdate(msg))
.expect("Cannot fail");
} else {
debug!(
"Received a message {{ {:?} }} but it was no valid path. Dropping...",
msg.path
)
}
}
Err(_) => {}
}
});
Ok(())

62
src/worker.rs

@ -16,6 +16,7 @@
use crossbeam_channel::{unbounded, Receiver, Sender};
use std::collections::hash_map::Entry;
use std::rc::Rc;
use log::debug;
@ -107,38 +108,26 @@ pub fn work(
match msg {
WorkerMessage::AddOutput(output, id) => {
debug!("Message: AddOutput {{ id: {} }}", id);
let lock = output
.read()
.map_err(|_| ApplicationError::locked_out(line!(), file!()))?;
if let Some(geo) = lock.geometry() {
debug!(
"Updating output {{ make: {}, model: {}, position: {}x{} }}",
geo.make(),
geo.model(),
geo.x(),
geo.y()
);
}
if let Some(fps) = lock.refresh_rate() {
state.set_fps(fps);
}
drop(lock);
if state.renders.contains_key(&id) {
debug!("Output {{ id: {id} }} updated and not new. Refreshing.");
// On Change we have to reinitialize the output, though this needs
// to be a complete reinit with all surfaces so for simplicity we
// "destroy" the output here and add it anew.
senders
.send(WorkerMessage::RemoveOutput(id))
.expect("Cannot fail");
senders
.send(WorkerMessage::AddOutput(output, id))
.expect("Cannot fail");
} else {
let lock = output
.read()
.map_err(|_| ApplicationError::locked_out(line!(), file!()))?;
if let Some(geo) = lock.geometry() {
debug!(
"Rendering on output {{ make: {}, model: {}, position: {}x{} }}",
geo.make(),
geo.model(),
geo.x(),
geo.y()
);
}
if let Some(fps) = lock.refresh_rate() {
state.set_fps(fps);
}
drop(lock);
state.renders.insert(
id,
OutputRendering::new(
if let Entry::Vacant(e) = state.renders.entry(id) {
e.insert(
OutputRendering::new(
&compositor,
&layers,
&mut event_queue,
@ -163,6 +152,17 @@ pub fn work(
senders.clone(),
state.timer_receiver.clone(),
)?;
} else {
debug!("Output {{ id: {id} }} updated and not new. Refreshing.");
// On Change we have to reinitialize the output, though this needs
// to be a complete reinit with all surfaces so for simplicity we
// "destroy" the output here and add it anew.
senders
.send(WorkerMessage::RemoveOutput(id))
.expect("Cannot fail");
senders
.send(WorkerMessage::AddOutput(output, id))
.expect("Cannot fail");
}
}
WorkerMessage::RemoveOutput(id) => {

Loading…
Cancel
Save