mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
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
This commit is contained in:
parent
fb5e591bc9
commit
2641b364e8
@ -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
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
current = get_property (device, "libinput Scroll Method Enabled",
|
||||
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;
|
||||
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;
|
||||
values[SCROLL_METHOD_FIELD_EDGE] = !!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);
|
||||
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",
|
||||
current = get_property (device, "libinput Scroll Method Enabled",
|
||||
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;
|
||||
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);
|
||||
meta_XFree (current);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user