windows issues

This commit is contained in:
Your Name
2026-03-16 23:58:49 +01:00
parent d030d9f069
commit 90231c439e
8 changed files with 297 additions and 572 deletions

831
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ ctrlc = "3.5.2"
futures = "0.3"
oklab = "1.1.2"
png = "0.17"
reqwest = { version = "0.13.2", features = ["json"] }
reqwest = { version = "0.13.2", default-features = false, features = ["json"] }
rgb = "0.8"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
@@ -24,6 +24,8 @@ embed-resource = "2.3"
grim-rs = "0.1.6"
libc = "0.2.183"
tray-item = { version = "0.10.0", features = ["ksni"] }
reqwest = { version = "0.13.2", default-features = false, features = ["json", "native-tls-vendored"] }
[target.'cfg(windows)'.dependencies]
tray-item = { version = "0.10.0" }
reqwest = { version = "0.13.2", default-features = false, features = ["json", "native-tls-vendored"] }

BIN
ico.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 893 KiB

BIN
icon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -54,7 +54,7 @@ impl HaClient {
.map(|modes| {
modes
.iter()
.any(|m| m.as_str().map_or(false, |s| color_modes.contains(&s)))
.any(|m| m.as_str().is_some_and(|s| color_modes.contains(&s)))
})
.unwrap_or(false)
})

View File

@@ -10,6 +10,12 @@ use std::sync::Arc;
use tray_item::{IconSource, TrayItem};
#[cfg(target_os = "windows")]
fn get_tray_icon() -> IconSource {
IconSource::Resource("app-icon")
}
#[cfg(not(target_os = "windows"))]
fn get_tray_icon() -> IconSource {
let icon_data = include_bytes!("../icon.png");
let cursor = Cursor::new(&icon_data[..]);
@@ -121,7 +127,7 @@ fn main() {
println!("Creating scene snapshot for restore on exit...");
if let Err(e) = rt_handle_toggle.block_on(
ha_client_toggle
.create_scene_snapshot("ambilight_restore", &*target_lights_toggle),
.create_scene_snapshot("ambilight_restore", &target_lights_toggle),
) {
eprintln!("Failed to create scene snapshot: {}", e);
}

View File

@@ -1,5 +1,3 @@
use anyhow;
pub type ScreenResult<T> = Result<T, anyhow::Error>;
#[derive(Clone, Copy)]
@@ -12,8 +10,6 @@ pub struct Pixel {
pub struct Screenshot {
pub data: Vec<Pixel>,
pub height: usize,
pub width: usize,
}
impl Screenshot {
@@ -108,8 +104,6 @@ mod ffi {
.map_err(|e| anyhow::anyhow!("Failed to capture screenshot: {}", e))?;
let raw_data = result.data();
let width = result.width() as usize;
let height = result.height() as usize;
let pixels: Vec<Pixel> = raw_data
.chunks_exact(4)
@@ -121,11 +115,7 @@ mod ffi {
})
.collect();
Ok(Screenshot {
data: pixels,
height,
width,
})
Ok(Screenshot { data: pixels })
}
}
@@ -214,11 +204,7 @@ mod ffi {
CGImageRelease(cg_img);
CFRelease(cf_data as *const libc::c_void);
Ok(Screenshot {
data: pixels,
height,
width,
})
Ok(Screenshot { data: pixels })
}
}
}
@@ -428,11 +414,7 @@ mod ffi {
}
}
Ok(Screenshot {
data: pixels,
height: height as usize,
width: width as usize,
})
Ok(Screenshot { data: pixels })
}
}
}