diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c index 74cf30afd..9fc6f6089 100644 --- a/src/backends/meta-input-settings.c +++ b/src/backends/meta-input-settings.c @@ -483,6 +483,7 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings, { MetaInputSettingsClass *input_settings_class; gboolean edge_scroll_enabled; + gboolean two_finger_scroll_enabled; MetaInputSettingsPrivate *priv; if (device && @@ -492,6 +493,11 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings, priv = meta_input_settings_get_instance_private (input_settings); input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings); edge_scroll_enabled = g_settings_get_boolean (priv->touchpad_settings, "edge-scrolling-enabled"); + two_finger_scroll_enabled = g_settings_get_boolean (priv->touchpad_settings, "two-finger-scrolling-enabled"); + + /* If both are enabled we prefer two finger. */ + if (edge_scroll_enabled && two_finger_scroll_enabled) + edge_scroll_enabled = FALSE; if (device) { @@ -523,6 +529,10 @@ update_touchpad_two_finger_scroll (MetaInputSettings *input_settings, input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings); two_finger_scroll_enabled = g_settings_get_boolean (priv->touchpad_settings, "two-finger-scrolling-enabled"); + /* Disable edge since they can't both be set. */ + if (two_finger_scroll_enabled) + update_touchpad_edge_scroll (input_settings, device); + if (device) { settings_device_set_bool_setting (input_settings, device, @@ -535,6 +545,10 @@ update_touchpad_two_finger_scroll (MetaInputSettings *input_settings, (ConfigBoolFunc) input_settings_class->set_two_finger_scroll, two_finger_scroll_enabled); } + + /* Edge might have been disabled because two finger was on. */ + if (!two_finger_scroll_enabled) + update_touchpad_edge_scroll (input_settings, device); } static void 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); + + 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; - /* 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; - } - - 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); + + 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; - 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; - - device_set_scroll_method (libinput_device, scroll_method); + device_set_scroll_method (libinput_device, current | method); } static void diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c index f595d4232..332997b47 100644 --- a/src/backends/x11/meta-input-settings-x11.c +++ b/src/backends/x11/meta-input-settings-x11.c @@ -222,32 +222,19 @@ meta_input_settings_x11_set_edge_scroll (MetaInputSettings *settings, gboolean edge_scroll_enabled) { guchar values[SCROLL_METHOD_NUM_FIELDS] = { 0 }; /* 2fg, edge, button. The last value is unused */ - guchar *defaults; - guchar *available; + guchar *current; - available = get_property (device, "libinput Scroll Methods Available", - XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS); - defaults = get_property (device, "libinput Scroll Method Enabled", - XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS); - if (!available || !defaults) - goto out; + current = get_property (device, "libinput Scroll Method Enabled", + XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS); + if (!current) + return; - memcpy (values, defaults, SCROLL_METHOD_NUM_FIELDS); + memcpy (values, current, SCROLL_METHOD_NUM_FIELDS); - /* Don't set edge scrolling if two-finger scrolling is enabled and available */ - if (available[SCROLL_METHOD_FIELD_EDGE] && - !(available[SCROLL_METHOD_FIELD_2FG] && values[SCROLL_METHOD_FIELD_2FG])) - { - values[1] = !!edge_scroll_enabled; - change_property (device, "libinput Scroll Method Enabled", - XA_INTEGER, 8, &values, SCROLL_METHOD_NUM_FIELDS); - } - -out: - if (available) - meta_XFree (available); - if (defaults) - meta_XFree (defaults); + values[SCROLL_METHOD_FIELD_EDGE] = !!edge_scroll_enabled; + change_property (device, "libinput Scroll Method Enabled", + XA_INTEGER, 8, &values, SCROLL_METHOD_NUM_FIELDS); + meta_XFree (current); } static void @@ -256,44 +243,19 @@ meta_input_settings_x11_set_two_finger_scroll (MetaInputSettings *set gboolean two_finger_scroll_enabled) { guchar values[SCROLL_METHOD_NUM_FIELDS] = { 0 }; /* 2fg, edge, button. The last value is unused */ - guchar *defaults; - guchar *available; - gboolean changed; + guchar *current; - available = get_property (device, "libinput Scroll Methods Available", - XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS); - defaults = get_property (device, "libinput Scroll Method Enabled", - XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS); - if (!available || !defaults) - goto out; + current = get_property (device, "libinput Scroll Method Enabled", + XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS); + if (!current) + return; - memcpy (values, defaults, SCROLL_METHOD_NUM_FIELDS); - changed = FALSE; + memcpy (values, current, SCROLL_METHOD_NUM_FIELDS); - if (available[SCROLL_METHOD_FIELD_2FG]) - { - values[SCROLL_METHOD_FIELD_2FG] = !!two_finger_scroll_enabled; - changed = TRUE; - } - - /* Disable edge scrolling when two-finger scrolling is enabled */ - if (values[SCROLL_METHOD_FIELD_2FG] && values[SCROLL_METHOD_FIELD_EDGE]) - { - values[SCROLL_METHOD_FIELD_EDGE] = 0; - changed = TRUE; - } - - if (changed) - { - change_property (device, "libinput Scroll Method Enabled", - XA_INTEGER, 8, &values, SCROLL_METHOD_NUM_FIELDS); - } - -out: - if (available) - meta_XFree (available); - if (defaults) - meta_XFree (defaults); + values[SCROLL_METHOD_FIELD_2FG] = !!two_finger_scroll_enabled; + change_property (device, "libinput Scroll Method Enabled", + XA_INTEGER, 8, &values, SCROLL_METHOD_NUM_FIELDS); + meta_XFree (current); } static void