summaryrefslogtreecommitdiff
path: root/src/backends/native/meta-input-settings-native.c
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2016-10-27 19:25:16 +0200
committerRui Matos <tiagomatos@gmail.com>2016-11-02 14:07:13 +0100
commit2641b364e81b4d404acc96f3fba2978fd4a021e7 (patch)
treef12ca2051992a9cef19c67826614ae1a8bd176ad /src/backends/native/meta-input-settings-native.c
parentfb5e591bc93dbbe5a37f7ad03652e7f89896abab (diff)
downloadmutter-2641b364e81b4d404acc96f3fba2978fd4a021e7.tar.gz
MetaInputSettings: fix two finger preference over edge scrolling logic
Enabling edge scrolling before disabling two finger would result in edge scrolling not actually being enabled because two finger is still enabled at the time and we bail out. This patch moves this logic to common code for both the native and X backends and fixes it by ensuring that both settings are never set at the same time and still re-checking if edge scrolling should be enabled after two finger scrolling gets disabled. We also simplify the code by not checking for supported/available settings since the underlying devices will just reject those values and there isn't anything we can do about it here. It's the UI's job to only show supported/available settings to users. https://bugzilla.gnome.org/show_bug.cgi?id=771744
Diffstat (limited to 'src/backends/native/meta-input-settings-native.c')
-rw-r--r--src/backends/native/meta-input-settings-native.c51
1 files changed, 10 insertions, 41 deletions
diff --git a/src/backends/native/meta-input-settings-native.c b/src/backends/native/meta-input-settings-native.c
index 5a142f77b..266d224d9 100644
--- a/src/backends/native/meta-input-settings-native.c
+++ b/src/backends/native/meta-input-settings-native.c
@@ -160,32 +160,16 @@ meta_input_settings_native_set_edge_scroll (MetaInputSettings *settin
ClutterInputDevice *device,
gboolean edge_scrolling_enabled)
{
- enum libinput_config_scroll_method scroll_method = 0;
struct libinput_device *libinput_device;
- enum libinput_config_scroll_method supported;
- enum libinput_config_scroll_method current;
+ enum libinput_config_scroll_method current, method;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
- if (!libinput_device)
- return;
- supported = libinput_device_config_scroll_get_methods (libinput_device);
- current = libinput_device_config_scroll_get_method (libinput_device);
- /* Don't set edge scrolling if two-finger scrolling is enabled and available */
- if (current == LIBINPUT_CONFIG_SCROLL_2FG)
- return;
-
- if (supported & LIBINPUT_CONFIG_SCROLL_EDGE &&
- edge_scrolling_enabled)
- {
- scroll_method = LIBINPUT_CONFIG_SCROLL_EDGE;
- }
- else
- {
- scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
- }
+ method = edge_scrolling_enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
+ current = libinput_device_config_scroll_get_method (libinput_device);
+ current &= ~LIBINPUT_CONFIG_SCROLL_EDGE;
- device_set_scroll_method (libinput_device, scroll_method);
+ device_set_scroll_method (libinput_device, current | method);
}
static void
@@ -193,31 +177,16 @@ meta_input_settings_native_set_two_finger_scroll (MetaInputSettings *
ClutterInputDevice *device,
gboolean two_finger_scroll_enabled)
{
- enum libinput_config_scroll_method scroll_method = 0;
struct libinput_device *libinput_device;
- enum libinput_config_scroll_method supported;
- enum libinput_config_scroll_method current;
+ enum libinput_config_scroll_method current, method;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
- supported = libinput_device_config_scroll_get_methods (libinput_device);
- current = libinput_device_config_scroll_get_method (libinput_device);
-
- if (two_finger_scroll_enabled &&
- !(supported & LIBINPUT_CONFIG_SCROLL_2FG))
- return;
- if (two_finger_scroll_enabled)
- {
- scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
- }
- else if (current != LIBINPUT_CONFIG_SCROLL_EDGE)
- {
- scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
- }
- else
- return;
+ method = two_finger_scroll_enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
+ current = libinput_device_config_scroll_get_method (libinput_device);
+ current &= ~LIBINPUT_CONFIG_SCROLL_2FG;
- device_set_scroll_method (libinput_device, scroll_method);
+ device_set_scroll_method (libinput_device, current | method);
}
static void