Update dependencies, fix incompatibilities
This commit is contained in:
parent
d7c90011cd
commit
77552b9426
4 changed files with 344 additions and 333 deletions
573
Cargo.lock
generated
573
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -15,12 +15,12 @@ exclude = ["PKGBUILD"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.3", features = ["derive"] }
|
clap = { version = "4.5.3", features = ["derive"] }
|
||||||
env_logger = "0.11.3"
|
env_logger = "0.11.3"
|
||||||
fast_image_resize = "3.0.4"
|
fast_image_resize = "4.2.1"
|
||||||
image = "0.25.0"
|
image = "0.25.0"
|
||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
mio = { version = "0.8.11", features = ["os-ext", "os-poll"] }
|
mio = { version = "1.0.2", features = ["os-ext", "os-poll"] }
|
||||||
swayipc = "3.0.2"
|
swayipc = "3.0.2"
|
||||||
|
|
||||||
[dependencies.smithay-client-toolkit]
|
[dependencies.smithay-client-toolkit]
|
||||||
version = "0.18.1"
|
version = "0.19.2"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
|
||||||
71
src/image.rs
71
src/image.rs
|
|
@ -1,11 +1,13 @@
|
||||||
use std::{
|
use std::{
|
||||||
fs::read_dir,
|
fs::read_dir,
|
||||||
num::NonZeroU32,
|
path::Path,
|
||||||
path::Path
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use fast_image_resize as fr;
|
use fast_image_resize::{
|
||||||
use image::{ImageBuffer, Rgb, ImageError};
|
FilterType, PixelType, Resizer, ResizeAlg, ResizeOptions,
|
||||||
|
images::Image,
|
||||||
|
};
|
||||||
|
use image::{ImageBuffer, ImageError, ImageReader, Rgb};
|
||||||
use log::{debug, error};
|
use log::{debug, error};
|
||||||
use smithay_client_toolkit::shm::slot::{Buffer, SlotPool};
|
use smithay_client_toolkit::shm::slot::{Buffer, SlotPool};
|
||||||
use smithay_client_toolkit::reexports::client::protocol::wl_shm;
|
use smithay_client_toolkit::reexports::client::protocol::wl_shm;
|
||||||
|
|
@ -18,8 +20,8 @@ pub fn workspace_bgs_from_output_image_dir(
|
||||||
format: wl_shm::Format,
|
format: wl_shm::Format,
|
||||||
brightness: i32,
|
brightness: i32,
|
||||||
contrast: f32,
|
contrast: f32,
|
||||||
surface_width: NonZeroU32,
|
surface_width: u32,
|
||||||
surface_height: NonZeroU32,
|
surface_height: u32,
|
||||||
)
|
)
|
||||||
-> Result<Vec<WorkspaceBackground>, String>
|
-> Result<Vec<WorkspaceBackground>, String>
|
||||||
{
|
{
|
||||||
|
|
@ -50,7 +52,7 @@ pub fn workspace_bgs_from_output_image_dir(
|
||||||
let workspace_name = path.file_stem().unwrap()
|
let workspace_name = path.file_stem().unwrap()
|
||||||
.to_string_lossy().into_owned();
|
.to_string_lossy().into_owned();
|
||||||
|
|
||||||
let raw_image = match image::io::Reader::open(&path)
|
let raw_image = match ImageReader::open(&path)
|
||||||
.map_err(ImageError::IoError)
|
.map_err(ImageError::IoError)
|
||||||
.and_then(|r| r.with_guessed_format()
|
.and_then(|r| r.with_guessed_format()
|
||||||
.map_err(ImageError::IoError)
|
.map_err(ImageError::IoError)
|
||||||
|
|
@ -77,14 +79,16 @@ pub fn workspace_bgs_from_output_image_dir(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut image = image.into_rgb8();
|
let mut image = image.into_rgb8();
|
||||||
|
let image_width = image.width();
|
||||||
|
let image_height = image.height();
|
||||||
|
|
||||||
let Some(image_width) = NonZeroU32::new(image.width()) else {
|
if image_width == 0 {
|
||||||
error!(
|
error!(
|
||||||
"Image '{}' has zero width, skipping", workspace_name
|
"Image '{}' has zero width, skipping", workspace_name
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Some(image_height) = NonZeroU32::new(image.height()) else {
|
if image_height == 0 {
|
||||||
error!(
|
error!(
|
||||||
"Image '{}' has zero height, skipping", workspace_name
|
"Image '{}' has zero height, skipping", workspace_name
|
||||||
);
|
);
|
||||||
|
|
@ -99,22 +103,31 @@ pub fn workspace_bgs_from_output_image_dir(
|
||||||
surface_width, surface_height
|
surface_width, surface_height
|
||||||
);
|
);
|
||||||
|
|
||||||
let src_image = fr::Image::from_vec_u8(
|
let src_image = Image::from_vec_u8(
|
||||||
image_width,
|
image_width,
|
||||||
image_height,
|
image_height,
|
||||||
image.into_raw(),
|
image.into_raw(),
|
||||||
fr::PixelType::U8x3,
|
PixelType::U8x3,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let dst_image = resize_image_with_cropping(
|
let mut dst_image = Image::new(
|
||||||
src_image.view(),
|
|
||||||
surface_width,
|
surface_width,
|
||||||
surface_height,
|
surface_height,
|
||||||
|
PixelType::U8x3,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let mut resizer = Resizer::new();
|
||||||
|
resizer.resize(
|
||||||
|
&src_image,
|
||||||
|
&mut dst_image,
|
||||||
|
&ResizeOptions::new()
|
||||||
|
.fit_into_destination(None)
|
||||||
|
.resize_alg(ResizeAlg::Convolution(FilterType::Lanczos3))
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
image = ImageBuffer::from_raw(
|
image = ImageBuffer::from_raw(
|
||||||
surface_width.get(),
|
surface_width,
|
||||||
surface_height.get(),
|
surface_height,
|
||||||
dst_image.into_vec()
|
dst_image.into_vec()
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -222,31 +235,3 @@ fn buffer_bgr888_from_image(
|
||||||
|
|
||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copied example from fast_image_resize
|
|
||||||
fn resize_image_with_cropping(
|
|
||||||
mut src_view: fr::DynamicImageView,
|
|
||||||
dst_width: NonZeroU32,
|
|
||||||
dst_height: NonZeroU32
|
|
||||||
) -> fr::Image {
|
|
||||||
// Set cropping parameters
|
|
||||||
src_view.set_crop_box_to_fit_dst_size(dst_width, dst_height, None);
|
|
||||||
|
|
||||||
// Create container for data of destination image
|
|
||||||
let mut dst_image = fr::Image::new(
|
|
||||||
dst_width,
|
|
||||||
dst_height,
|
|
||||||
src_view.pixel_type(),
|
|
||||||
);
|
|
||||||
// Get mutable view of destination image data
|
|
||||||
let mut dst_view = dst_image.view_mut();
|
|
||||||
|
|
||||||
// Create Resizer instance and resize source image
|
|
||||||
// into buffer of destination image
|
|
||||||
let mut resizer = fr::Resizer::new(
|
|
||||||
fr::ResizeAlg::Convolution(fr::FilterType::Lanczos3)
|
|
||||||
);
|
|
||||||
resizer.resize(&src_view, &mut dst_view).unwrap();
|
|
||||||
|
|
||||||
dst_image
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
use std::{
|
use std::path::PathBuf;
|
||||||
num::NonZeroU32,
|
|
||||||
path::PathBuf
|
|
||||||
};
|
|
||||||
|
|
||||||
use log::{debug, error, warn};
|
use log::{debug, error, warn};
|
||||||
use smithay_client_toolkit::{
|
use smithay_client_toolkit::{
|
||||||
|
|
@ -108,6 +105,24 @@ impl CompositorHandler for State
|
||||||
_new_transform: wl_output::Transform,
|
_new_transform: wl_output::Transform,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn surface_enter(
|
||||||
|
&mut self,
|
||||||
|
_conn: &Connection,
|
||||||
|
_qh: &QueueHandle<Self>,
|
||||||
|
_surface: &WlSurface,
|
||||||
|
_output: &wl_output::WlOutput,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn surface_leave(
|
||||||
|
&mut self,
|
||||||
|
_conn: &Connection,
|
||||||
|
_qh: &QueueHandle<Self>,
|
||||||
|
_surface: &WlSurface,
|
||||||
|
_output: &wl_output::WlOutput,
|
||||||
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayerShellHandler for State
|
impl LayerShellHandler for State
|
||||||
|
|
@ -270,8 +285,8 @@ logical size: {}x{}",
|
||||||
pixel_format,
|
pixel_format,
|
||||||
self.brightness,
|
self.brightness,
|
||||||
self.contrast,
|
self.contrast,
|
||||||
NonZeroU32::new(width as u32).unwrap(),
|
width.try_into().unwrap(),
|
||||||
NonZeroU32::new(height as u32).unwrap()
|
height.try_into().unwrap()
|
||||||
) {
|
) {
|
||||||
Ok(workspace_bgs) => {
|
Ok(workspace_bgs) => {
|
||||||
debug!(
|
debug!(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue