YaLTeR / niri

A scrollable-tiling Wayland compositor.
https://matrix.to/#/#niri:matrix.org
GNU General Public License v3.0
3.59k stars 105 forks source link

Gesture bindings #372

Open YaLTeR opened 4 months ago

YaLTeR commented 4 months ago

Add some way to customize gesture bindings. I don't have a concrete design yet, but:

  1. Users should be able to customize how many fingers to use for the swipe gestures (supersede https://github.com/YaLTeR/niri/pull/315, cc @MagneFire)
  2. I should be able to add new gestures without breaking users' configs
  3. Users should be able to bind gestures only where it makes sense, i.e. swipe actions to swipe gestures and not to pinch gestures for example

I'm thinking something like a binds section, but for gestures. To satisfy 1. and 2., maybe encode number of fingers explicitly into the "key"?

gestures {
    touchpad-swipe-3-horizontal horizontal-view-movement
    touchpad-swipe-3-vertical workspace-switch
    Mod+Mouse3-horizontal horizontal-view-movement
    Mod+touch-swipe-3-horizontal horizontal-view-movement
}

This way, I can add new defaults when this section is missing from the config, and when it is present in the config the user will just need to add new gestures manually.

I don't entirely like this though, looks kinda awkward.

Also, I can see a problem in the future where there may be a 2D gesture, and so you will need to be able to bind either touchpad-swipe-N to a 2D gesture, or separate touchpad-swipe-N-horizontal/vertical to 1D gestures. But also maybe that's not a problem and can just be verified during parsing.

Also, this "gestures" section that I have in mind seems to be mainly about continuous gestures (swipe and pinch) and not about discrete gestures like double-resize-click (these seem more fit for the regular binds section).

Also, should it be allowed to bind "vertical" to "horizontal" gestures and vice versa? Maybe not.

YaLTeR commented 3 months ago

How about this:

gestures {
    touchpad-swipe-3 horizontal="view-movement" vertical="workspace-switch"
    Mod+Mouse3 horizontal="view-movement" vertical="workspace-switch"
    Mod+Mouse2 "resize-window"
}

You can only set either an argument, or the properties. All three have only those variants that make sense for that property (i.e. no vertical-only gestures in the horizontal property).

I'm still not sure about encoding the finger count into the "key" name.

in the future where there may be a 2D gesture

Examples: currently existing interactive window resize; future interactive window move. For the resize it even makes sense to be able to bind just the horizontal part (since we're a scrolling WM).

markomarkovic commented 2 months ago

I was looking for a way to set Mod+Mouse1 for horizontal view movement, this would solve that issue nicely.

The encoding of the finger count into the key name makes sense to me.

IvanTurgenev commented 3 weeks ago

Yeah even mouses nowadays have gesture buttons image

nakibrayan3 commented 3 weeks ago

how about some thing like this:

gestures {
  touchpad-swipe-3-horizontal-left focus-column-left
  touchpad-swipe-3-horizontal-left focus-column-right
}

So that the touchpad gestures are identical to the keyboard shortcuts for focusing columns. this fixes https://github.com/YaLTeR/niri/discussions/466

YaLTeR commented 3 weeks ago

I envision the gesture bindings section only for continuous binds, and the regular bind section for discrete binds.

valpackett commented 1 week ago

Do you have any thoughts on forwarding continuous gestures to layer-shell based desktop components? (think being able to pinch in the app menu from anywhere like on macOS) I have previously prototyped that for Wayfire in wf-globalgestures which exposes a custom protocol, but I think I'd be fine with a config-based solution to avoid having Yet Another Protocol, like so (this example would result in that gesture always being forwarded to a client with matching 'namespace' on the current output):

gestures {
    touchpad-pinch-4 forward-to-client namespace=r#"^owo\.uwu\.ControlCenter$"#
}
YaLTeR commented 1 week ago

Hm, interesting idea. Need to look into it when implementing.