Skip to content

Commit

Permalink
Merge pull request #203 from Akida31/fix_underscore_lock
Browse files Browse the repository at this point in the history
fix let_underscore_lock lint
  • Loading branch information
LGFae authored Feb 9, 2024
2 parents ad3d406 + 3d001fa commit 01e9cf8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions daemon/src/wallpaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl Wallpaper {
}

pub fn get_dimensions(&self) -> (u32, u32) {
let (inner, _) = self.lock();
let inner = self.lock_inner();
let width = inner.width.get() as u32;
let height = inner.height.get() as u32;
let scale_factor = inner.scale_factor.get() as u32;
Expand All @@ -156,10 +156,20 @@ impl Wallpaper {
}

#[inline]
fn lock_inner_mut(&self) -> (RwLockWriteGuard<WallpaperInner>, MutexGuard<SlotPool>) {
fn lock_mut(&self) -> (RwLockWriteGuard<WallpaperInner>, MutexGuard<SlotPool>) {
(self.inner.write().unwrap(), self.pool.lock().unwrap())
}

#[inline]
fn lock_inner(&self) -> RwLockReadGuard<WallpaperInner> {
self.inner.read().unwrap()
}

#[inline]
fn lock_inner_mut(&self) -> RwLockWriteGuard<WallpaperInner> {
self.inner.write().unwrap()
}

pub fn canvas_change<F, T>(&self, f: F) -> T
where
F: FnOnce(&mut [u8]) -> T,
Expand All @@ -182,7 +192,7 @@ impl Wallpaper {

#[inline]
pub fn get_img_info(&self) -> BgImg {
self.lock().0.img.clone()
self.lock_inner().img.clone()
}

#[inline]
Expand Down Expand Up @@ -215,7 +225,7 @@ impl Wallpaper {

pub fn set_img_info(&self, img_info: BgImg) {
log::debug!("output {} - drawing: {}", self.output_id, img_info);
self.lock_inner_mut().0.img = img_info;
self.lock_inner_mut().img = img_info;
}

pub fn draw(&self) {
Expand Down Expand Up @@ -244,7 +254,7 @@ impl Wallpaper {
if let Some(s) = scale_factor {
self.layer_surface.set_buffer_scale(s.get() as u32).unwrap();
}
let (mut inner, mut pool) = self.lock_inner_mut();
let (mut inner, mut pool) = self.lock_mut();
let width = width.unwrap_or(inner.width);
let height = height.unwrap_or(inner.height);
let scale_factor = scale_factor.unwrap_or(inner.scale_factor);
Expand Down

0 comments on commit 01e9cf8

Please sign in to comment.