backends/native: fix the scroll button lock right/middle mismatch

In X, buttons 1, 2, 3 are left, middle, right. In evdev, the order is
BTN_LEFT, BTN_RIGHT, BTN_MIDDLE. So setting a scroll button to 2 gave us a
middle button in the X session and a right button in a wayland session.

Fix that by hard-coding the LMR buttons handling.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1433
This commit is contained in:
Peter Hutterer 2020-09-09 09:15:59 +10:00 committed by Georges Basile Stavracas Neto
parent 6e3ecadb79
commit aa638f4d48

View File

@ -287,12 +287,26 @@ meta_input_settings_native_set_scroll_button (MetaInputSettings *settings,
} }
else else
{ {
/* Compensate for X11 scroll buttons */ switch (button)
if (button > 7) {
button -= 4; case 1:
evcode = BTN_LEFT;
break;
case 2:
evcode = BTN_MIDDLE;
break;
case 3:
evcode = BTN_RIGHT;
break;
default:
/* Compensate for X11 scroll buttons */
if (button > 7)
button -= 4;
/* Button is 1-indexed */
evcode = (BTN_LEFT - 1) + button;
}
/* Button is 1-indexed */
evcode = (BTN_LEFT - 1) + button;
method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
} }