Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing #113 and adding proper mouse support #300

Merged
merged 2 commits into from
Jun 22, 2024
Merged

fixing #113 and adding proper mouse support #300

merged 2 commits into from
Jun 22, 2024

Conversation

sminez
Copy link
Owner

@sminez sminez commented Jun 22, 2024

Thanks to @favilo for the initial implementation that this was inspired by (found here) and apologies to @psychon for not addressing the issue with motion notify events until now...!

This change includes a breaking API change to how mouse bindings are defined: rather than bindings being tied individually to press, release and motion the MouseEventHandler trait now defines a handler that is responsible for all three for a given button press and modifier set. As a demonstration of how this looks, this is the simple mouse bindings that are now present in the minimal example:

fn mouse_bindings() -> HashMap<MouseState, Box<dyn MouseEventHandler<RustConn>>> {
    use penrose::core::bindings::{
        ModifierKey::{Meta, Shift},
        MouseButton::{Left, Middle, Right},
    };

    map! {
        map_keys: |(button, modifiers)| MouseState { button, modifiers };

        (Left, vec![Shift, Meta]) => MouseDragHandler::boxed_default(),
        (Right, vec![Shift, Meta]) => MouseResizeHandler::boxed_default(),
        (Middle, vec![Shift, Meta]) => sink_clicked(),
    }
}
mouse-support-demo-2024-06-22_17.03.08.mp4

@sminez sminez merged commit a0c77a1 into develop Jun 22, 2024
10 checks passed
@sminez sminez deleted the mouse-support branch June 22, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant