[gnome-control-center/gnome-3-20] mouse: Detect and warn if we're running on the synaptics driver



commit ce48b5c6594ad450bbfee526683fe19efffe9ef3
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Apr 4 20:01:31 2016 +0200

    mouse: Detect and warn if we're running on the synaptics driver
    
    Since we don't support the synaptics driver anymore we shouldn't show
    the touchpad section in that case. In addition, emit a warning so that
    this system mis-configuration is easier to diagnose.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764257

 panels/mouse/cc-mouse-caps-helper.c   |   43 +++++++++++++++++++++++++++++++++
 panels/mouse/cc-mouse-caps-helper.h   |    2 +
 panels/mouse/gnome-mouse-properties.c |    8 ++++++
 3 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/panels/mouse/cc-mouse-caps-helper.c b/panels/mouse/cc-mouse-caps-helper.c
index d82bdb2..6fdeb4d 100644
--- a/panels/mouse/cc-mouse-caps-helper.c
+++ b/panels/mouse/cc-mouse-caps-helper.c
@@ -98,3 +98,46 @@ cc_touchpad_check_capabilities (gboolean *have_two_finger_scrolling,
        /* else we unconditionally show all touchpad knobs */
        return FALSE;
 }
+
+gboolean
+cc_synaptics_check (void)
+{
+        Display *display;
+        GList *devicelist, *l;
+        Atom prop, realtype;
+        int realformat;
+        unsigned long nitems, bytes_after;
+        unsigned char *data;
+        gboolean have_synaptics = FALSE;
+
+        if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+                return FALSE;
+
+        display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+        prop = XInternAtom (display, "Synaptics Capabilities", 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)
+                       continue;
+
+                if ((XIGetProperty (display, gdk_x11_device_get_id (device), prop,
+                                    0, 2, False, XA_INTEGER, &realtype, &realformat, &nitems,
+                                    &bytes_after, &data) == Success) && (realtype != None)) {
+                        have_synaptics = TRUE;
+                        XFree (data);
+                }
+
+                if (have_synaptics)
+                        break;
+        }
+        g_list_free (devicelist);
+
+        gdk_error_trap_pop_ignored ();
+
+        return have_synaptics;
+}
diff --git a/panels/mouse/cc-mouse-caps-helper.h b/panels/mouse/cc-mouse-caps-helper.h
index d116abe..f2581d9 100644
--- a/panels/mouse/cc-mouse-caps-helper.h
+++ b/panels/mouse/cc-mouse-caps-helper.h
@@ -27,4 +27,6 @@ gboolean cc_touchpad_check_capabilities (gboolean *have_two_finger_scrolling,
                                          gboolean *have_edge_scrolling,
                                          gboolean *have_tap_to_click);
 
+gboolean cc_synaptics_check (void);
+
 #endif /* _CC_MOUSE_CAPS_HELPER_H_ */
diff --git a/panels/mouse/gnome-mouse-properties.c b/panels/mouse/gnome-mouse-properties.c
index d90019e..a648b9d 100644
--- a/panels/mouse/gnome-mouse-properties.c
+++ b/panels/mouse/gnome-mouse-properties.c
@@ -61,6 +61,7 @@ struct _CcMousePropertiesPrivate
        gboolean have_mouse;
        gboolean have_touchpad;
        gboolean have_touchscreen;
+       gboolean have_synaptics;
 
        gboolean left_handed;
        GtkGesture *left_gesture;
@@ -79,6 +80,10 @@ 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;
@@ -327,6 +332,9 @@ cc_mouse_properties_init (CcMouseProperties *object)
        d->have_mouse = mouse_is_present ();
        d->have_touchpad = touchpad_is_present ();
        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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]