feat: update dependencies to latest compatible versions

- Update frontend dependencies (SolidJS, Vite, Tailwind, etc.)
- Update backend dependencies (Tauri 1.8.3, Tokio, Serde, etc.)
- Fix thread safety issues with SafeDisplay wrapper for ddc-hi::Display
- Resolve display-info API compatibility issues
- All dependencies updated within major version constraints
This commit is contained in:
2025-06-30 17:35:03 +08:00
parent b1fd751090
commit ddf61c861d
6 changed files with 1633 additions and 853 deletions

2357
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,27 @@ use tokio::sync::RwLock;
use super::DisplayState;
// Safe wrapper for Display that implements Send + Sync
pub struct SafeDisplay {
display: Display,
}
unsafe impl Send for SafeDisplay {}
unsafe impl Sync for SafeDisplay {}
impl SafeDisplay {
pub fn new(display: Display) -> Self {
Self { display }
}
pub fn get_mut(&mut self) -> &mut Display {
&mut self.display
}
}
pub struct DisplayHandler {
pub state: Arc<RwLock<DisplayState>>,
pub controller: Arc<RwLock<Display>>,
pub controller: Arc<RwLock<SafeDisplay>>,
}
impl DisplayHandler {
@ -16,7 +34,7 @@ impl DisplayHandler {
let mut temp_state = self.state.read().await.clone();
match controller.handle.get_vcp_feature(0x10) {
match controller.get_mut().handle.get_vcp_feature(0x10) {
Ok(value) => {
temp_state.max_brightness = value.maximum();
temp_state.min_brightness = 0;
@ -24,7 +42,7 @@ impl DisplayHandler {
}
Err(_) => {}
};
match controller.handle.get_vcp_feature(0x12) {
match controller.get_mut().handle.get_vcp_feature(0x12) {
Ok(value) => {
temp_state.max_contrast = value.maximum();
temp_state.min_contrast = 0;
@ -32,7 +50,7 @@ impl DisplayHandler {
}
Err(_) => {}
};
match controller.handle.get_vcp_feature(0xdc) {
match controller.get_mut().handle.get_vcp_feature(0xdc) {
Ok(value) => {
temp_state.max_mode = value.maximum();
temp_state.min_mode = 0;
@ -52,6 +70,7 @@ impl DisplayHandler {
let mut state = self.state.write().await;
controller
.get_mut()
.handle
.set_vcp_feature(0x10, brightness)
.map_err(|err| anyhow::anyhow!("can not set brightness. {:?}", err))?;
@ -69,6 +88,7 @@ impl DisplayHandler {
let mut state = self.state.write().await;
controller
.get_mut()
.handle
.set_vcp_feature(0x12, contrast)
.map_err(|err| anyhow::anyhow!("can not set contrast. {:?}", err))?;
@ -84,6 +104,7 @@ impl DisplayHandler {
let mut state = self.state.write().await;
controller
.get_mut()
.handle
.set_vcp_feature(0xdc, mode)
.map_err(|err| anyhow::anyhow!("can not set mode. {:?}", err))?;

View File

@ -13,7 +13,7 @@ use crate::{
rpc::{BoardMessageChannels, DisplaySetting},
};
use super::{display_handler::DisplayHandler, display_state::DisplayState};
use super::{display_handler::{DisplayHandler, SafeDisplay}, display_state::DisplayState};
const CONFIG_FILE_NAME: &str = "cc.ivanli.ambient_light/displays.toml";
@ -85,7 +85,8 @@ impl DisplayManager {
let controllers = Display::enumerate();
for display in controllers {
let controller = Arc::new(RwLock::new(display));
let safe_display = SafeDisplay::new(display);
let controller = Arc::new(RwLock::new(safe_display));
let state = Arc::new(RwLock::new(DisplayState::default()));
let handler = DisplayHandler {
state: state.clone(),

View File

@ -20,7 +20,6 @@ use serde::{Deserialize, Serialize};
use serde_json::to_string;
use tauri::{http::ResponseBuilder, regex, Manager};
use volume::VolumeManager;
#[derive(Serialize, Deserialize)]
#[serde(remote = "DisplayInfo")]
struct DisplayInfoDef {