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
+1 -1
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)
})
+7 -1
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);
}
+3 -21
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 })
}
}
}