Files
cursor_rush/frontend/src-tauri/src/platform/windows/mod.rs
T
2025-05-16 17:38:33 +02:00

46 lines
1.3 KiB
Rust

// Windows platform implementation module
pub mod types;
mod cursor;
mod state;
use std::path::PathBuf;
use crate::platform::Result;
// Functions expected by the platform-agnostic interface
pub fn set_cursor(path: &str) -> Result<()> {
println!("Windows platform: setting cursor to {}", path);
// Create a cursor info struct to pass to update_cursor_info
let mut cursor_info = crate::platform::types::CursorInfo {
name: path.split('\\').last().unwrap_or("unknown").to_string(),
path: PathBuf::from(path),
image: None,
hotspot_x: 0, // Default hotspot at top-left
hotspot_y: 0,
#[cfg(target_os = "windows")]
win_cursor: None,
};
// Use the existing update_cursor_info function to handle loading and applying the cursor
if !cursor::update_cursor_info(&mut cursor_info) {
return Err(format!("Failed to update cursor from {}", path));
}
Ok(())
}
pub fn restore_default_cursor() -> Result<()> {
println!("Windows platform: restoring default cursor");
cursor::restore_cursor();
Ok(())
}
pub fn init() -> Result<()> {
println!("Windows platform: initializing cursor system");
if !cursor::hide_system_cursor() {
return Err("Failed to initialize cursor system".to_string());
}
Ok(())
}