Expand description
§winshift
A cross-platform library for monitoring window focus changes.
§Features
- Native window focus tracking on Linux via X11
- macOS support via Accessibility API (requires app tracking workaround)
- Windows support planned (not yet implemented)
- Event-driven callback system
- Minimal overhead window monitoring
- Thread-safe design
Note: The app tracking functionality on macOS exists solely to work around platform limitations for reliable window focus detection.
§Quick Start
use winshift::{FocusChangeHandler, WindowFocusHook};
struct MyHandler;
impl FocusChangeHandler for MyHandler {
fn on_app_change(&self, pid: i32, app_name: String) {
println!("App changed: {} (PID: {})", app_name, pid);
}
fn on_window_change(&self, window_title: String) {
println!("Window changed to: {}", window_title);
}
}
fn main() -> Result<(), winshift::WinshiftError> {
let handler = MyHandler;
let hook = WindowFocusHook::new(handler);
hook.run()
}Re-exports§
pub use env_logger;
Macros§
- debug
- Logs a message at the debug level.
- error
- Logs a message at the error level.
- info
- Logs a message at the info level.
- trace
- Logs a message at the trace level.
- warn
- Logs a message at the warn level.
Structs§
- Window
Focus Hook - Main window focus monitoring hook
- Window
Hook Config - Configuration for window monitoring behavior
Enums§
- Monitoring
Mode - Monitoring mode for selective event tracking
- Winshift
Error
Constants§
Traits§
- Focus
Change Handler - Trait for handling window focus change events