From c71faffb710d8a08470ba0de3bc7b408582699f5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Oct 2017 18:58:13 +0200 Subject: [PATCH] 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 --- .../native/meta-input-settings-native.c | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/backends/native/meta-input-settings-native.c b/src/backends/native/meta-input-settings-native.c index 8a62bb3fe..beb721774 100644 --- a/src/backends/native/meta-input-settings-native.c +++ b/src/backends/native/meta-input-settings-native.c @@ -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