Skip to main content

focus_tracker/
lib.rs

1pub use focus_tracker_core::*;
2
3mod focus_tracker;
4pub(crate) mod icon_cache;
5
6pub use focus_tracker::*;
7
8#[cfg(target_os = "macos")]
9#[path = "macos/mod.rs"]
10mod platform;
11
12#[cfg(target_os = "linux")]
13#[path = "linux/mod.rs"]
14mod platform;
15
16#[cfg(target_os = "windows")]
17#[path = "windows/mod.rs"]
18mod platform;
19
20/// Returns the document URL of the focused window for the given OS process,
21/// when the platform and the application expose one.
22///
23/// This is a thin facade over the platform module. Today only macOS provides
24/// a real implementation (via the Accessibility API's `AXDocument`
25/// attribute); Linux and Windows return `Ok(None)` until equivalent support
26/// is implemented for those targets.
27///
28/// Callers should treat `Ok(None)` as a soft signal ("no document open / no
29/// URL available") and surface real errors only in the
30/// [`FocusTrackerError::PermissionDenied`] case, which means the platform
31/// blocked the lookup and the caller should back off.
32///
33/// # Errors
34///
35/// Returns [`FocusTrackerError::PermissionDenied`] when macOS denies
36/// Accessibility access. Other errors are platform-specific.
37pub fn focused_document_url(pid: u32) -> FocusTrackerResult<Option<String>> {
38    platform::focused_document_url(pid)
39}