Blame SOURCES/0002-mouse-Handle-Synaptics-devices-again.patch

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