mirror of
https://github.com/brl/mutter.git
synced 2024-11-27 18:40:40 -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
1b4b361a92
commit
374bba2d4e
@ -483,6 +483,7 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings,
|
|||||||
{
|
{
|
||||||
MetaInputSettingsClass *input_settings_class;
|
MetaInputSettingsClass *input_settings_class;
|
||||||
gboolean edge_scroll_enabled;
|
gboolean edge_scroll_enabled;
|
||||||
|
gboolean two_finger_scroll_enabled;
|
||||||
MetaInputSettingsPrivate *priv;
|
MetaInputSettingsPrivate *priv;
|
||||||
|
|
||||||
if (device &&
|
if (device &&
|
||||||
@ -492,6 +493,11 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings,
|
|||||||
priv = meta_input_settings_get_instance_private (input_settings);
|
priv = meta_input_settings_get_instance_private (input_settings);
|
||||||
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (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");
|
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)
|
if (device)
|
||||||
{
|
{
|
||||||
@ -523,6 +529,10 @@ update_touchpad_two_finger_scroll (MetaInputSettings *input_settings,
|
|||||||
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (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");
|
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)
|
if (device)
|
||||||
{
|
{
|
||||||
settings_device_set_bool_setting (input_settings, 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,
|
(ConfigBoolFunc) input_settings_class->set_two_finger_scroll,
|
||||||
two_finger_scroll_enabled);
|
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
|
static void
|
||||||
|
@ -160,32 +160,16 @@ meta_input_settings_native_set_edge_scroll (MetaInputSettings *settin
|
|||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
gboolean edge_scrolling_enabled)
|
gboolean edge_scrolling_enabled)
|
||||||
{
|
{
|
||||||
enum libinput_config_scroll_method scroll_method = 0;
|
|
||||||
struct libinput_device *libinput_device;
|
struct libinput_device *libinput_device;
|
||||||
enum libinput_config_scroll_method supported;
|
enum libinput_config_scroll_method current, method;
|
||||||
enum libinput_config_scroll_method current;
|
|
||||||
|
|
||||||
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
|
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
|
||||||
if (!libinput_device)
|
|
||||||
return;
|
method = edge_scrolling_enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
||||||
supported = libinput_device_config_scroll_get_methods (libinput_device);
|
|
||||||
current = libinput_device_config_scroll_get_method (libinput_device);
|
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 */
|
device_set_scroll_method (libinput_device, current | method);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -193,31 +177,16 @@ meta_input_settings_native_set_two_finger_scroll (MetaInputSettings *
|
|||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
gboolean two_finger_scroll_enabled)
|
gboolean two_finger_scroll_enabled)
|
||||||
{
|
{
|
||||||
enum libinput_config_scroll_method scroll_method = 0;
|
|
||||||
struct libinput_device *libinput_device;
|
struct libinput_device *libinput_device;
|
||||||
enum libinput_config_scroll_method supported;
|
enum libinput_config_scroll_method current, method;
|
||||||
enum libinput_config_scroll_method current;
|
|
||||||
|
|
||||||
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
|
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_device_config_scroll_get_method (libinput_device);
|
||||||
|
current &= ~LIBINPUT_CONFIG_SCROLL_2FG;
|
||||||
|
|
||||||
if (two_finger_scroll_enabled &&
|
device_set_scroll_method (libinput_device, current | method);
|
||||||
!(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -222,32 +222,19 @@ meta_input_settings_x11_set_edge_scroll (MetaInputSettings *settings,
|
|||||||
gboolean edge_scroll_enabled)
|
gboolean edge_scroll_enabled)
|
||||||
{
|
{
|
||||||
guchar values[SCROLL_METHOD_NUM_FIELDS] = { 0 }; /* 2fg, edge, button. The last value is unused */
|
guchar values[SCROLL_METHOD_NUM_FIELDS] = { 0 }; /* 2fg, edge, button. The last value is unused */
|
||||||
guchar *defaults;
|
guchar *current;
|
||||||
guchar *available;
|
|
||||||
|
|
||||||
available = get_property (device, "libinput Scroll Methods Available",
|
current = get_property (device, "libinput Scroll Method Enabled",
|
||||||
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
||||||
defaults = get_property (device, "libinput Scroll Method Enabled",
|
if (!current)
|
||||||
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
return;
|
||||||
if (!available || !defaults)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
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 */
|
values[SCROLL_METHOD_FIELD_EDGE] = !!edge_scroll_enabled;
|
||||||
if (available[SCROLL_METHOD_FIELD_EDGE] &&
|
change_property (device, "libinput Scroll Method Enabled",
|
||||||
!(available[SCROLL_METHOD_FIELD_2FG] && values[SCROLL_METHOD_FIELD_2FG]))
|
XA_INTEGER, 8, &values, SCROLL_METHOD_NUM_FIELDS);
|
||||||
{
|
meta_XFree (current);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -256,44 +243,19 @@ meta_input_settings_x11_set_two_finger_scroll (MetaInputSettings *set
|
|||||||
gboolean two_finger_scroll_enabled)
|
gboolean two_finger_scroll_enabled)
|
||||||
{
|
{
|
||||||
guchar values[SCROLL_METHOD_NUM_FIELDS] = { 0 }; /* 2fg, edge, button. The last value is unused */
|
guchar values[SCROLL_METHOD_NUM_FIELDS] = { 0 }; /* 2fg, edge, button. The last value is unused */
|
||||||
guchar *defaults;
|
guchar *current;
|
||||||
guchar *available;
|
|
||||||
gboolean changed;
|
|
||||||
|
|
||||||
available = get_property (device, "libinput Scroll Methods Available",
|
current = get_property (device, "libinput Scroll Method Enabled",
|
||||||
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
||||||
defaults = get_property (device, "libinput Scroll Method Enabled",
|
if (!current)
|
||||||
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
return;
|
||||||
if (!available || !defaults)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
memcpy (values, defaults, SCROLL_METHOD_NUM_FIELDS);
|
memcpy (values, current, SCROLL_METHOD_NUM_FIELDS);
|
||||||
changed = FALSE;
|
|
||||||
|
|
||||||
if (available[SCROLL_METHOD_FIELD_2FG])
|
values[SCROLL_METHOD_FIELD_2FG] = !!two_finger_scroll_enabled;
|
||||||
{
|
change_property (device, "libinput Scroll Method Enabled",
|
||||||
values[SCROLL_METHOD_FIELD_2FG] = !!two_finger_scroll_enabled;
|
XA_INTEGER, 8, &values, SCROLL_METHOD_NUM_FIELDS);
|
||||||
changed = TRUE;
|
meta_XFree (current);
|
||||||
}
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user