rdev icon indicating copy to clipboard operation
rdev copied to clipboard

Mouse drag doesn't work

Open blesswinsamuel opened this issue 2 years ago • 4 comments

First of all, thank you for this library.

When I tried the example https://github.com/Narsil/rdev/blob/main/examples/grab.rs, it prints mouse move and click events. But, when I click and move the mouse while the mouse button is being clicked, it doesn't print those events. I expect MouseMove events to be printed between the ButtonPress(Left) and ButtonRelease(Left) events.

Here's the output:

My callback Event { time: SystemTime { tv_sec: 1677442442, tv_nsec: 943688000 }, name: None, event_type: ButtonPress(Left) }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466498000 }, name: None, event_type: ButtonRelease(Left) }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466626000 }, name: None, event_type: MouseMove { x: 474.41796875, y: 1146.15625 } }

Here's what I expect:

My callback Event { time: SystemTime { tv_sec: 1677442442, tv_nsec: 943688000 }, name: None, event_type: ButtonPress(Left) }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466626000 }, name: None, event_type: MouseMove { x: 123, y: 123 } }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466626000 }, name: None, event_type: MouseMove { x: 124, y: 124 } }
...
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466498000 }, name: None, event_type: ButtonRelease(Left) }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466626000 }, name: None, event_type: MouseMove { x: 474.41796875, y: 1146.15625 } }

I'm using macOS Ventura 13.1 and rdev version 0.5.2.

blesswinsamuel avatar Feb 26 '23 20:02 blesswinsamuel

I also encountered this problem in macOS Ventura 13.4 and rdev 0.5.3. Did you solve it?

swithun-liu-backup avatar Jul 02 '23 10:07 swithun-liu-backup

grabbing is unstable (it's really hard to make an OS independant API for it as not everything is even grabbable) . Does the listen work ?

Narsil avatar Jul 03 '23 09:07 Narsil

listen also doesn't work.

Here is my try:

fn main() {
    if let Err(error) = listen(callback) {
        println!("Error: {:?}", error)
    }

    fn callback(event: Event) {
        println!("My callback {:?}", event);
        match event.event_type {
            EventType::ButtonPress(button) => match button {
                Button::Right => {
                    println!("right btn press");
                },
                _ => (),
            },
            EventType::ButtonRelease(button) => match button {
                Button::Right => {
                    println!("right btn release");
                },
                _ => (),
            },
            EventType::MouseMove { x, y } => {
                println!("x: {}, y: {}", x, y);
            },
            _ => (),
        }
    }
}

This is output when I press right button, then move the mouse, and finally release right button.

My callback Event { time: SystemTime { tv_sec: 1688384409, tv_nsec: 912707000 }, name: None, event_type: ButtonPress(Right) }
right btn press
My callback Event { time: SystemTime { tv_sec: 1688384414, tv_nsec: 232347000 }, name: None, event_type: ButtonRelease(Right) }
right btn release

swithun-liu-backup avatar Jul 03 '23 11:07 swithun-liu-backup

Did you find a solution to this?

Advait1306 avatar Mar 06 '24 17:03 Advait1306