backends: Force 2-finger scroll by default if available

When the touchpad is two-finger scrolling capable, always enable it.

When the touchpad only supports edge scrolling (usually older devices, and
usually smaller devices), allow disabling the edge scrolling.

This requires a newer gsettings-desktop-schemas as the scroll-method key
was removed, and the edge-scroll-enabled key added.

https://bugzilla.gnome.org/show_bug.cgi?id=759304
This commit is contained in:
Bastien Nocera 2015-12-11 12:32:46 +01:00
parent 0e8ca1a042
commit a27b2597b9
5 changed files with 49 additions and 54 deletions

View File

@ -63,7 +63,7 @@ MUTTER_PC_MODULES="
gio-unix-2.0 >= 2.35.1
pango >= 1.2.0
cairo >= 1.10.0
gsettings-desktop-schemas >= 3.15.92
gsettings-desktop-schemas >= 3.19.3
$CLUTTER_PACKAGE >= 1.25.1
cogl-1.0 >= 1.17.1
upower-glib >= 0.99.0

View File

@ -63,9 +63,9 @@ struct _MetaInputSettingsClass
void (* set_invert_scroll) (MetaInputSettings *settings,
ClutterInputDevice *device,
gboolean inverted);
void (* set_scroll_method) (MetaInputSettings *settings,
ClutterInputDevice *device,
GDesktopTouchpadScrollMethod mode);
void (* set_edge_scroll) (MetaInputSettings *settings,
ClutterInputDevice *device,
gboolean enabled);
void (* set_scroll_button) (MetaInputSettings *settings,
ClutterInputDevice *device,
guint button);

View File

@ -395,11 +395,11 @@ update_touchpad_tap_enabled (MetaInputSettings *input_settings,
}
static void
update_touchpad_scroll_method (MetaInputSettings *input_settings,
ClutterInputDevice *device)
update_touchpad_edge_scroll (MetaInputSettings *input_settings,
ClutterInputDevice *device)
{
MetaInputSettingsClass *input_settings_class;
GDesktopTouchpadScrollMethod method;
gboolean edge_scroll_enabled;
MetaInputSettingsPrivate *priv;
if (device &&
@ -408,19 +408,19 @@ update_touchpad_scroll_method (MetaInputSettings *input_settings,
priv = meta_input_settings_get_instance_private (input_settings);
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings);
method = g_settings_get_enum (priv->touchpad_settings, "scroll-method");
edge_scroll_enabled = g_settings_get_boolean (priv->touchpad_settings, "edge-scrolling-enabled");
if (device)
{
settings_device_set_uint_setting (input_settings, device,
input_settings_class->set_scroll_method,
method);
settings_device_set_bool_setting (input_settings, device,
input_settings_class->set_edge_scroll,
edge_scroll_enabled);
}
else
{
settings_set_uint_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
(ConfigUintFunc) input_settings_class->set_scroll_method,
method);
settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
(ConfigBoolFunc) input_settings_class->set_edge_scroll,
edge_scroll_enabled);
}
}
@ -645,8 +645,8 @@ meta_input_settings_changed_cb (GSettings *settings,
update_touchpad_tap_enabled (input_settings, NULL);
else if (strcmp (key, "send-events") == 0)
update_touchpad_send_events (input_settings, NULL);
else if (strcmp (key, "scroll-method") == 0)
update_touchpad_scroll_method (input_settings, NULL);
else if (strcmp (key, "edge-scrolling-enabled") == 0)
update_touchpad_edge_scroll (input_settings, NULL);
else if (strcmp (key, "click-method") == 0)
update_touchpad_click_method (input_settings, NULL);
}
@ -771,7 +771,7 @@ apply_device_settings (MetaInputSettings *input_settings,
update_device_natural_scroll (input_settings, device);
update_touchpad_tap_enabled (input_settings, device);
update_touchpad_send_events (input_settings, device);
update_touchpad_scroll_method (input_settings, device);
update_touchpad_edge_scroll (input_settings, device);
update_touchpad_click_method (input_settings, device);
update_trackball_scroll_button (input_settings, device);

View File

@ -154,30 +154,30 @@ device_set_click_method (struct libinput_device *libinput_device,
}
static void
meta_input_settings_native_set_scroll_method (MetaInputSettings *settings,
ClutterInputDevice *device,
GDesktopTouchpadScrollMethod mode)
meta_input_settings_native_set_edge_scroll (MetaInputSettings *settings,
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;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
supported = libinput_device_config_scroll_get_methods (libinput_device);
switch (mode)
if (supported & LIBINPUT_CONFIG_SCROLL_2FG)
{
case G_DESKTOP_TOUCHPAD_SCROLL_METHOD_DISABLED:
scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
break;
case G_DESKTOP_TOUCHPAD_SCROLL_METHOD_EDGE_SCROLLING:
scroll_method = LIBINPUT_CONFIG_SCROLL_EDGE;
break;
case G_DESKTOP_TOUCHPAD_SCROLL_METHOD_TWO_FINGER_SCROLLING:
scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
break;
default:
g_assert_not_reached ();
return;
}
}
else 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);
}
@ -252,7 +252,7 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
input_settings_class->set_left_handed = meta_input_settings_native_set_left_handed;
input_settings_class->set_tap_enabled = meta_input_settings_native_set_tap_enabled;
input_settings_class->set_invert_scroll = meta_input_settings_native_set_invert_scroll;
input_settings_class->set_scroll_method = meta_input_settings_native_set_scroll_method;
input_settings_class->set_edge_scroll = meta_input_settings_native_set_edge_scroll;
input_settings_class->set_scroll_button = meta_input_settings_native_set_scroll_button;
input_settings_class->set_click_method = meta_input_settings_native_set_click_method;
input_settings_class->set_keyboard_repeat = meta_input_settings_native_set_keyboard_repeat;

View File

@ -199,9 +199,9 @@ meta_input_settings_x11_set_invert_scroll (MetaInputSettings *settings,
}
static void
meta_input_settings_x11_set_scroll_method (MetaInputSettings *settings,
ClutterInputDevice *device,
GDesktopTouchpadScrollMethod mode)
meta_input_settings_x11_set_edge_scroll (MetaInputSettings *settings,
ClutterInputDevice *device,
gboolean edge_scroll_enabled)
{
guchar values[3] = { 0 }; /* 2fg, edge, button. The last value is unused */
guchar *available;
@ -211,26 +211,21 @@ meta_input_settings_x11_set_scroll_method (MetaInputSettings *setting
if (!available)
return;
switch (mode)
if (available[0])
{
case G_DESKTOP_TOUCHPAD_SCROLL_METHOD_DISABLED:
break;
case G_DESKTOP_TOUCHPAD_SCROLL_METHOD_EDGE_SCROLLING:
values[1] = 1;
break;
case G_DESKTOP_TOUCHPAD_SCROLL_METHOD_TWO_FINGER_SCROLLING:
values[0] = 1;
break;
default:
g_assert_not_reached ();
}
else if (available[1] && edge_scroll_enabled)
{
values[1] = 1;
}
else
{
/* Disabled */
}
if ((values[0] && !available[0]) || (values[1] && !available[1]))
g_warning ("Device '%s' does not support scroll mode %d\n",
clutter_input_device_get_device_name (device), mode);
else
change_property (device, "libinput Scroll Method Enabled",
XA_INTEGER, 8, &values, 3);
change_property (device, "libinput Scroll Method Enabled",
XA_INTEGER, 8, &values, 3);
meta_XFree (available);
}
@ -321,7 +316,7 @@ meta_input_settings_x11_class_init (MetaInputSettingsX11Class *klass)
input_settings_class->set_left_handed = meta_input_settings_x11_set_left_handed;
input_settings_class->set_tap_enabled = meta_input_settings_x11_set_tap_enabled;
input_settings_class->set_invert_scroll = meta_input_settings_x11_set_invert_scroll;
input_settings_class->set_scroll_method = meta_input_settings_x11_set_scroll_method;
input_settings_class->set_edge_scroll = meta_input_settings_x11_set_edge_scroll;
input_settings_class->set_scroll_button = meta_input_settings_x11_set_scroll_button;
input_settings_class->set_click_method = meta_input_settings_x11_set_click_method;
input_settings_class->set_keyboard_repeat = meta_input_settings_x11_set_keyboard_repeat;