[gnome-flashback] input-settings: re-add support for edge scrolling with some touchpads
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] input-settings: re-add support for edge scrolling with some touchpads
- Date: Thu, 28 Jul 2016 20:40:36 +0000 (UTC)
commit a50e70e07546b1f978178cc82a8b6548c9cf0381
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jun 30 14:27:23 2016 +0200
input-settings: re-add support for edge scrolling with some touchpads
Add support for setting edge-scrolling separately from two-finger
scrolling. We now have 2 separate boolean settings for those, with the
Mouse panel in gnome-control-center allowing to set only one of those at
a time, but nothing precludes both being set in the configuration.
We need to handle:
- two-finger-scrolling-enabled and edge-scrolling-enabled settings both
being set.
- those 2 settings being change out-of-order
- two-finger-scrolling being set on a device that doesn't support it
- edge-scrolling-enabled on a device that doesn't support it
And the combinations of one touchpad supporting just one of edge
scrolling and two-finger scrolling and another vice-versa.
https://bugzilla.gnome.org/show_bug.cgi?id=768245
Original commit:
https://git.gnome.org/browse/mutter/commit/?id=36cd7177fd40432cb4ae7db10e2571dbbd9604b9
configure.ac | 2 +-
.../libinput-settings/gf-input-settings.c | 117 ++++++++++++++++++--
2 files changed, 108 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 54b7c03..89741e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,7 +110,7 @@ GTK_REQUIRED=3.19.5
LIBGNOME_DESKTOP_REQUIRED=3.12.0
CANBERRA_REQUIRED=0.13
GLIB_REQUIRED=2.44.0
-GSETTINGS_DESKTOP_SCHEMAS_REQUIRED=3.21.3
+GSETTINGS_DESKTOP_SCHEMAS_REQUIRED=3.21.4
POLKIT_AGENT_REQUIRED=0.97
POLKIT_GOBJECT_REQUIRED=0.97
IBUS_REQUIRED=1.5.2
diff --git a/gnome-flashback/libinput-settings/gf-input-settings.c
b/gnome-flashback/libinput-settings/gf-input-settings.c
index 52bfe69..5eff59d 100644
--- a/gnome-flashback/libinput-settings/gf-input-settings.c
+++ b/gnome-flashback/libinput-settings/gf-input-settings.c
@@ -349,32 +349,102 @@ set_edge_scroll (GfInputSettings *settings,
gboolean edge_scroll_enabled)
{
guchar *available;
+ guchar *defaults;
guchar values[3] = { 0 }; /* 2fg, edge, button. The last value is unused */
available = get_property (settings, device,
"libinput Scroll Methods Available",
XA_INTEGER, 8, 3);
- if (!available)
- return;
+ defaults = get_property (settings, device,
+ "libinput Scroll Method Enabled",
+ XA_INTEGER, 8, 3);
+
+ if (!available || !defaults)
+ {
+ if (available)
+ XFree (available);
+
+ if (defaults)
+ XFree (defaults);
+
+ return;
+ }
+
+ memcpy (values, defaults, 3);
+
+ /* Don't set edge scrolling if two-finger scrolling is enabled and available */
+ if (available[1] && !(available[0] && values[0]))
+ {
+ values[1] = !!edge_scroll_enabled;
+
+ change_property (settings, device, "libinput Scroll Method Enabled",
+ XA_INTEGER, 8, &values, 3);
+ }
+
+ if (available)
+ XFree (available);
+
+ if (defaults)
+ XFree (defaults);
+}
+
+static void
+set_two_finger_scroll (GfInputSettings *settings,
+ GdkDevice *device,
+ gboolean two_finger_scroll_enabled)
+{
+ guchar *available;
+ gboolean changed;
+ guchar *defaults;
+ guchar values[3] = { 0 }; /* 2fg, edge, button. The last value is unused */
+
+ available = get_property (settings, device,
+ "libinput Scroll Methods Available",
+ XA_INTEGER, 8, 3);
+
+ defaults = get_property (settings, device,
+ "libinput Scroll Method Enabled",
+ XA_INTEGER, 8, 3);
+
+ if (!available || !defaults)
+ {
+ if (available)
+ XFree (available);
+
+ if (defaults)
+ XFree (defaults);
+
+ return;
+ }
+
+ memcpy (values, defaults, 3);
+ changed = FALSE;
if (available[0])
{
- values[0] = 1;
+ values[0] = !!two_finger_scroll_enabled;
+ changed = TRUE;
}
- else if (available[1] && edge_scroll_enabled)
+
+ /* Disable edge scrolling when two-finger scrolling is enabled */
+ if (values[0] && values[1])
{
- values[1] = 1;
+ values[1] = 0;
+ changed = TRUE;
}
- else
+
+ if (changed)
{
- /* Disabled */
+ change_property (settings, device, "libinput Scroll Method Enabled",
+ XA_INTEGER, 8, &values, 3);
}
- change_property (settings, device, "libinput Scroll Method Enabled",
- XA_INTEGER, 8, &values, 3);
+ if (available)
+ XFree (available);
- XFree (available);
+ if (defaults)
+ XFree (defaults);
}
static void
@@ -656,6 +726,30 @@ update_touchpad_edge_scroll (GfInputSettings *settings,
}
static void
+update_touchpad_two_finger_scroll (GfInputSettings *settings,
+ GdkDevice *device)
+{
+ gboolean two_finger_scroll_enabled;
+
+ if (device && gdk_device_get_source (device) != GDK_SOURCE_TOUCHPAD)
+ return;
+
+ two_finger_scroll_enabled = g_settings_get_boolean (settings->touchpad,
+ "two-finger-scrolling-enabled");
+
+ if (device)
+ {
+ device_set_bool_setting (settings, device,
+ set_two_finger_scroll, two_finger_scroll_enabled);
+ }
+ else
+ {
+ set_bool_setting (settings, GDK_SOURCE_TOUCHPAD,
+ set_two_finger_scroll, two_finger_scroll_enabled);
+ }
+}
+
+static void
update_touchpad_click_method (GfInputSettings *settings,
GdkDevice *device)
{
@@ -768,6 +862,8 @@ settings_changed_cb (GSettings *gsettings,
update_touchpad_send_events (settings, NULL);
else if (strcmp (key, "edge-scrolling-enabled") == 0)
update_touchpad_edge_scroll (settings, NULL);
+ else if (strcmp (key, "two-finger-scrolling-enabled") == 0)
+ update_touchpad_two_finger_scroll (settings, NULL);
else if (strcmp (key, "click-method") == 0)
update_touchpad_click_method (settings, NULL);
}
@@ -972,6 +1068,7 @@ apply_device_settings (GfInputSettings *settings,
update_touchpad_tap_enabled (settings, device);
update_touchpad_send_events (settings, device);
update_touchpad_edge_scroll (settings, device);
+ update_touchpad_two_finger_scroll (settings, device);
update_touchpad_click_method (settings, device);
update_trackball_scroll_button (settings, device);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]