backends/native: Fix handling of trackball settings

The org.gnome.desktop.peripherals.trackball.scroll-wheel-emulation-button
setting contains buttons X11-style. Work out the BTN evcode that applies
to it when applying the setting on the libinput device.

https://bugzilla.gnome.org/show_bug.cgi?id=787804
This commit is contained in:
Carlos Garnacho 2017-10-04 18:58:13 +02:00
parent 91e3a0b3a9
commit c71faffb71

View File

@ -245,16 +245,33 @@ meta_input_settings_native_set_scroll_button (MetaInputSettings *settings,
guint button)
{
struct libinput_device *libinput_device;
enum libinput_config_scroll_method method;
guint evcode;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
if (!libinput_device)
return;
if (!device_set_scroll_method (libinput_device,
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN))
if (button == 0)
{
method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
evcode = 0;
}
else
{
/* Compensate for X11 scroll buttons */
if (button > 7)
button -= 4;
/* Button is 1-indexed */
evcode = (BTN_LEFT - 1) + button;
method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
}
if (!device_set_scroll_method (libinput_device, method))
return;
libinput_device_config_scroll_set_button (libinput_device, button);
libinput_device_config_scroll_set_button (libinput_device, evcode);
}
static void