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

65 lines
1.7 KiB
Rust

// Platform-specific cursor handling
// Common types for cursor handling
pub mod types;
// Windows implementation
#[cfg(target_os = "windows")]
mod windows;
// macOS implementation
#[cfg(target_os = "macos")]
mod macos;
// Linux implementation
#[cfg(target_os = "linux")]
mod linux;
// Error type for platform operations
pub type Result<T> = std::result::Result<T, String>;
// Platform-agnostic interface for cursor handling
#[cfg(target_os = "windows")]
pub use self::windows::{set_cursor, restore_default_cursor, init};
#[cfg(target_os = "macos")]
pub use self::macos::{set_cursor, restore_default_cursor, init};
#[cfg(target_os = "linux")]
pub use self::linux::{set_cursor, restore_default_cursor, init};
// Initialize platform-specific cursor handling
pub fn initialize() -> Result<()> {
#[cfg(target_os = "windows")]
{
init()
}
#[cfg(not(target_os = "windows"))]
{
Ok(())
}
}
// Cross-platform implementation for setting cursor
pub fn set_system_cursor(path: &str) -> Result<()> {
println!("Setting system cursor: {}", path);
set_cursor(path)
}
// Cross-platform implementation for restoring default cursor
pub fn restore_system_cursor() -> Result<()> {
println!("Restoring system cursor");
restore_default_cursor()
}
// Default implementations for non-supported platforms
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
pub fn set_cursor(_path: &str) -> Result<()> {
Err("Cursor customization not supported on this platform".to_string())
}
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
pub fn restore_default_cursor() -> Result<()> {
Err("Cursor restoration not supported on this platform".to_string())
}