Skip to content

tasuren/window-observer-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

window-observer-rs

This crate provides an observer that receives events such as window movement and resizing. It is designed to receive window events on Windows and macOS for cross-platform applications.

⚠️ It is not production ready yet. Expect extremely disruptive changes.

Example

use window_observer::{self, Event, WindowObserver};

#[tokio::main]
async fn main() {
    let pid = std::env::var("PID")
        .map(|v| v.parse().unwrap())
        .expect("Please give me the env `PID` of application that has window.");

    let (event_tx, mut event_rx) = tokio::sync::mpsc::unbounded_channel();
    let event_filter = window_observer::smallvec![Event::Activated, Event::Moved, Event::Resized];

    let _window_observer = WindowObserver::start(pid, event_tx, event_filter)
        .await
        .unwrap();

    while let Some((_window, event)) = event_rx.recv().await {
        println!("{event:?}");
    }
}

ToDo

First release todos:

  • macOS
    • Resize detection
    • Move detection
    • Foreground detection
    • Resize detection with information such as width, height
    • Move detection with information such as x, y.
    • Get the window title
  • Windows
    • Resize detection
    • Move detectio
    • Foreground detectionn
    • Resize detection with information such as width, height
    • Move detection with information such as x, y.
    • Get the window title
  • Linux? I have no plans to make this at this time due to my inexperienced knowledge about Linux.
    But I'd be happy to receive pull requests.

Acknowledgements

License

This project is licensed under the MIT License.

About

**WIP** Window observer library for Rust.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages