Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slideshows #58

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ pub fn layer_surface(
layer: &mut CosmicBgLayer,
queue_handle: &QueueHandle<CosmicBg>,
buffer: &Buffer,
buffer_damage: (i32, i32),
) {
let (width, height) = layer.size.unwrap();

let wl_surface = layer.layer.wl_surface();

// Damage the entire window
wl_surface.damage_buffer(0, 0, width as i32, height as i32);
wl_surface.damage_buffer(0, 0, buffer_damage.0, buffer_damage.1);

// Request our next frame
layer
Expand Down
20 changes: 14 additions & 6 deletions src/wallpaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub struct Wallpaper {
// Cache of source image, if `current_source` is a `Source::Path`
current_image: Option<image::DynamicImage>,
timer_token: Option<RegistrationToken>,
new_image: bool,
}

impl Drop for Wallpaper {
Expand All @@ -63,7 +62,6 @@ impl Wallpaper {
current_source: None,
current_image: None,
image_queue: VecDeque::default(),
new_image: false,
timer_token: None,
loop_handle,
queue_handle,
Expand Down Expand Up @@ -188,13 +186,17 @@ impl Wallpaper {
}

let image = cur_resized_img.as_ref().unwrap();

let buffer_result =
crate::draw::canvas(pool, image, width as i32, height as i32, width as i32 * 4);

match buffer_result {
Ok(buffer) => {
crate::draw::layer_surface(layer, &self.queue_handle, &buffer);
crate::draw::layer_surface(
layer,
&self.queue_handle,
&buffer,
(width as i32, height as i32),
);
layer.needs_redraw = false;

let elapsed = Instant::now().duration_since(start);
Expand Down Expand Up @@ -282,7 +284,6 @@ impl Wallpaper {
if let Err(err) = self.save_state() {
error!("{err}");
}
self.new_image = true;
self.image_queue = image_queue;
}

Expand Down Expand Up @@ -343,7 +344,7 @@ impl Wallpaper {
}

item.image_queue.push_back(next);
item.new_image = true;
item.clear_image();
item.draw();

return TimeoutAction::ToDuration(Duration::from_secs(rotation_freq));
Expand All @@ -355,6 +356,13 @@ impl Wallpaper {
.ok();
}
}

fn clear_image(&mut self) {
self.current_image = None;
for l in &mut self.layers {
l.needs_redraw = true;
}
}
}

fn current_image(output: &str) -> Option<Source> {
Expand Down
Loading