Skip to content

Commit

Permalink
minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
LGFae committed May 3, 2024
1 parent 07e8a73 commit 82def7a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ wayland-client = { version = "0.31", default-features = false, features = [ "log
wayland-protocols = { version = "0.31", default-features = false, features = [ "client", "staging" ]}
wayland-protocols-wlr = { version = "0.2", default-features = false, features = [ "client" ]}

rustix = { version = "0.38", default-features = false, features = [ "event", "shm", "mm", "net" ] }
rustix = { version = "0.38", default-features = false, features = [ "event" ] }
libc = "0.2"

keyframe = "1.1"
Expand Down
8 changes: 5 additions & 3 deletions daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl Daemon {
Request::Clear(clear) => {
let wallpapers = self.find_wallpapers_by_names(&clear.outputs);
let color = clear.color;
match std::thread::Builder::new()
let spawn_result = std::thread::Builder::new()
.stack_size(1 << 15)
.name("clear".to_string())
.spawn(move || {
Expand All @@ -386,7 +386,8 @@ impl Daemon {
wallpaper.clear(color);
wallpaper.draw();
}
}) {
});
match spawn_result {
Ok(_) => Answer::Ok,
Err(e) => Answer::Err(format!("failed to spawn `clear` thread: {e}")),
}
Expand Down Expand Up @@ -415,7 +416,8 @@ impl Daemon {
}
used_wallpapers.push(wallpapers);
}
self.animator.transition(transition, imgs, animations, used_wallpapers)
self.animator
.transition(transition, imgs, animations, used_wallpapers)
}
};
if let Err(e) = answer.send(&stream) {
Expand Down
7 changes: 1 addition & 6 deletions daemon/src/wallpaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
num::NonZeroI32,
sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Arc, Condvar, Mutex, RwLock,
Condvar, Mutex, RwLock,
},
};

Expand All @@ -27,7 +27,6 @@ use crate::{bump_pool::BumpPool, Daemon, LayerSurface};
#[derive(Debug)]
struct AnimationState {
id: AtomicUsize,
transition_finished: Arc<AtomicBool>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -132,7 +131,6 @@ impl Wallpaper {
inner_staging,
animation_state: AnimationState {
id: AtomicUsize::new(0),
transition_finished: Arc::new(AtomicBool::new(false)),
},
configured: AtomicBool::new(false),
qh: qh.clone(),
Expand Down Expand Up @@ -381,9 +379,6 @@ impl Wallpaper {
#[inline]
pub(super) fn stop_animations(&self) {
self.animation_state.id.fetch_add(1, Ordering::AcqRel);
self.animation_state
.transition_finished
.store(false, Ordering::Release);
}

pub(super) fn clear(&self, color: [u8; 3]) {
Expand Down
7 changes: 5 additions & 2 deletions utils/src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,10 @@ impl Request {
{
for i in 0..outputs.len() {
let Img {
path, dim: dims, format, ..
path,
dim: dims,
format,
..
} = &imgs[i];
for output in outputs[i].iter() {
if let Err(e) = super::cache::store(output, path) {
Expand Down Expand Up @@ -1125,7 +1128,7 @@ fn create_memfd() -> rustix::io::Result<OwnedFd> {
use rustix::fs::{MemfdFlags, SealFlags};
use std::ffi::CStr;

let name = CStr::from_bytes_with_nul(b"swww-daemon\0").unwrap();
let name = CStr::from_bytes_with_nul(b"swww-ipc\0").unwrap();
let flags = MemfdFlags::ALLOW_SEALING | MemfdFlags::CLOEXEC;

loop {
Expand Down

0 comments on commit 82def7a

Please sign in to comment.