From 6881c089a00b184358de3e6c80f2711f59ec5e04 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Mon, 13 Mar 2017 19:58:42 +0100
Subject: [PATCH 2/3] mouse: Handle Synaptics devices again
If mutter can handle those, so can g-c-c
---
panels/mouse/cc-mouse-caps-helper.c | 85 ++++++++++++++++++++++++++++++++---
panels/mouse/gnome-mouse-properties.c | 10 +----
2 files changed, 79 insertions(+), 16 deletions(-)
diff --git a/panels/mouse/cc-mouse-caps-helper.c b/panels/mouse/cc-mouse-caps-helper.c
index 65e11df67..521f318d4 100644
--- a/panels/mouse/cc-mouse-caps-helper.c
+++ b/panels/mouse/cc-mouse-caps-helper.c
@@ -25,9 +25,72 @@
#include "cc-mouse-caps-helper.h"
static gboolean
-touchpad_check_capabilities_x11 (gboolean *have_two_finger_scrolling,
- gboolean *have_edge_scrolling,
- gboolean *have_tap_to_click)
+touchpad_check_capabilities_x11_synaptics (gboolean *have_two_finger_scrolling,
+ gboolean *have_edge_scrolling,
+ gboolean *have_tap_to_click)
+{
+ Display *display;
+ GList *devicelist, *l;
+ Atom realtype, prop_two_finger_scroll, prop_edge_scroll, prop_tap_action;
+ int realformat;
+ unsigned long nitems, bytes_after;
+ unsigned char *data;
+
+ display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ prop_two_finger_scroll = XInternAtom (display, "Synaptics Two-Finger Scrolling", False);
+ prop_edge_scroll = XInternAtom (display, "Synaptics Edge Scrolling", False);
+ prop_tap_action = XInternAtom (display, "Synaptics Tap Action", False);
+ if (!prop_two_finger_scroll || !prop_edge_scroll || !prop_tap_action)
+ return FALSE;
+
+ *have_two_finger_scrolling = FALSE;
+ *have_edge_scrolling = FALSE;
+ *have_tap_to_click = FALSE;
+
+ gdk_error_trap_push ();
+
+ devicelist = gdk_seat_get_slaves (gdk_display_get_default_seat (gdk_display_get_default ()),
+ GDK_SEAT_CAPABILITY_ALL_POINTING);
+ for (l = devicelist; l != NULL; l = l->next) {
+ GdkDevice *device = l->data;
+
+ if (gdk_device_get_source (device) != GDK_SOURCE_TOUCHPAD &&
+ gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
+ continue;
+
+ /* xorg-x11-drv-synaptics */
+ if ((XIGetProperty (display, gdk_x11_device_get_id (device), prop_two_finger_scroll,
+ 0, 2, False, XA_INTEGER, &realtype, &realformat, &nitems,
+ &bytes_after, &data) == Success) && (realtype != None)) {
+ *have_two_finger_scrolling = TRUE;
+ XFree (data);
+ }
+
+ if ((XIGetProperty (display, gdk_x11_device_get_id (device), prop_edge_scroll,
+ 0, 3, False, XA_INTEGER, &realtype, &realformat, &nitems,
+ &bytes_after, &data) == Success) && (realtype != None)) {
+ *have_edge_scrolling = TRUE;
+ XFree (data);
+ }
+
+ if ((XIGetProperty (display, gdk_x11_device_get_id (device), prop_tap_action,
+ 0, 8, False, XA_INTEGER, &realtype, &realformat, &nitems,
+ &bytes_after, &data) == Success) && (realtype != None)) {
+ *have_tap_to_click = TRUE;
+ XFree (data);
+ }
+ }
+ g_list_free (devicelist);
+
+ gdk_error_trap_pop_ignored ();
+
+ return TRUE;
+}
+
+static gboolean
+touchpad_check_capabilities_x11_libinput (gboolean *have_two_finger_scrolling,
+ gboolean *have_edge_scrolling,
+ gboolean *have_tap_to_click)
{
Display *display;
GList *devicelist, *l;
@@ -91,10 +154,18 @@ cc_touchpad_check_capabilities (gboolean *have_two_finger_scrolling,
gboolean *have_edge_scrolling,
gboolean *have_tap_to_click)
{
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
- return touchpad_check_capabilities_x11 (have_two_finger_scrolling,
- have_edge_scrolling,
- have_tap_to_click);
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+ if (cc_synaptics_check ()) {
+ return touchpad_check_capabilities_x11_synaptics (have_two_finger_scrolling,
+ have_edge_scrolling,
+ have_tap_to_click);
+ }
+
+ return touchpad_check_capabilities_x11_libinput (have_two_finger_scrolling,
+ have_edge_scrolling,
+ have_tap_to_click);
+ }
+
/* else we unconditionally show all touchpad knobs */
*have_two_finger_scrolling = TRUE;
*have_edge_scrolling = TRUE;
diff --git a/panels/mouse/gnome-mouse-properties.c b/panels/mouse/gnome-mouse-properties.c
index 95a74e418..e2053a5cd 100644
--- a/panels/mouse/gnome-mouse-properties.c
+++ b/panels/mouse/gnome-mouse-properties.c
@@ -61,7 +61,6 @@ struct _CcMousePropertiesPrivate
gboolean have_mouse;
gboolean have_touchpad;
gboolean have_touchscreen;
- gboolean have_synaptics;
gboolean left_handed;
GtkGesture *left_gesture;
@@ -81,10 +80,6 @@ setup_touchpad_options (CcMousePropertiesPrivate *d)
gboolean have_edge_scrolling;
gboolean have_tap_to_click;
- gtk_widget_set_visible (WID ("touchpad-frame"), !d->have_synaptics);
- if (d->have_synaptics)
- return;
-
gtk_widget_set_visible (WID ("touchpad-frame"), d->have_touchpad);
if (!d->have_touchpad)
return;
@@ -387,11 +382,8 @@ cc_mouse_properties_init (CcMouseProperties *object)
G_CALLBACK (device_changed), d);
d->have_mouse = mouse_is_present ();
- d->have_touchpad = touchpad_is_present ();
+ d->have_touchpad = touchpad_is_present () || cc_synaptics_check ();
d->have_touchscreen = touchscreen_is_present ();
- d->have_synaptics = cc_synaptics_check ();
- if (d->have_synaptics)
- g_warning ("Detected synaptics X driver, please migrate to libinput");
d->changing_scroll = FALSE;
--
2.13.6