swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.44k stars 1.1k forks source link

Option to swap scroll axes #7063

Open tmccombs opened 2 years ago

tmccombs commented 2 years ago

I would like to swap vertical and horizontal scroll (so that using my vertical scroll wheel scrolls horizontally and vice versa).

It's sort of possible to do this with config like:

bindsym --whole-window --inhibited  {  
    button4 seat - cursor press button6
    button5 seat - cursor press button7
    button6 seat - cursor press button4
    button7 seat - cursor press button5
}                                      

However, this doesn't work if a modifier key (such as shift) is pushed down. And having to add additional bindsyms for each modifier is a little much.

It would be nice if there was a specific option for swapping the axes. Or maybe add an option to ignore modifier keys for a bindsym, but continue using the modifier for buttons triggered as a result.

tmccombs commented 1 year ago

In sway 1.8, it appears that what I had above no longer works. In fact, it seams like seat - cursor press button4 and similar don't seem to work at all.

pzant commented 1 year ago

In sway 1.8.1 scroll bindings don't work

tmccombs commented 5 months ago

Or maybe add an option to ignore modifier keys for a bindsym, but continue using the modifier for buttons triggered as a result.

Fwiw, Hyprland has a bindi command that does this.

Although, since you can't bind to scroll events anymore, that wouldn't be sufficient.

Also worth pointing out this is possible in X with xinput set-button-map

tmccombs commented 5 months ago

Unfortunately, I don't think it is possible to work around this with udev rules either, as described in https://github.com/swaywm/sway/issues/3960#issuecomment-2068083432. Because in udev at least scroll events aren't key presses, they are EV_REL events, which as far as I can tell can't be mapped to a different event.

litoj commented 4 months ago

I tried this:

bindsym --whole-window {
    button6 seat - cursor press button4
    button7 seat - cursor press button5
}

which consistently kept crashing sway whenever I scrolled for a random amount of time:

2024-05-07 06:49:23 - [swaybg-1.2.1/main.c:282] Found config * for output eDP-1 (BOE 0x09B6)
sway: types/seat/wlr_seat_pointer.c:332: wlr_seat_pointer_send_axis: Assertion `wlr_seat->pointer_state.cached_axis_source == source' failed.

(btw also note the inconsistency of quoting: backtick for beginning of expression and quote for end. Is this really the normal assert() behaviour?)

Originally I also had seat - cursor press SHIFT_LEFT because I wanted to map horizontal scroll to shift scroll for gimp and other apps, but that also did nothing. Though at least no crashes were happening at that point.