mouse: Use g-s-d helper to detect touchpad

This commit is contained in:
Bastien Nocera 2010-12-09 12:07:48 +00:00
parent 741723eaf8
commit 01fbd4fee0

View file

@ -31,6 +31,7 @@
#include <math.h>
#include "gnome-mouse-properties.h"
#include "gsd-input-helper.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -216,62 +217,6 @@ synaptics_check_capabilities (GtkBuilder *dialog)
XFreeDeviceList (devicelist);
}
static gboolean
find_synaptics (void)
{
gboolean ret = FALSE;
int numdevices, i;
XDeviceInfo *devicelist;
Atom realtype, prop;
int realformat;
unsigned long nitems, bytes_after;
unsigned char *data;
XExtensionVersion *version;
/* Input device properties require version 1.5 or higher */
version = XGetExtensionVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "XInputExtension");
if (!version->present ||
(version->major_version * 1000 + version->minor_version) < 1005) {
XFree (version);
return False;
}
prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Synaptics Off", True);
if (!prop)
return False;
devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &numdevices);
for (i = 0; i < numdevices; i++) {
if (devicelist[i].use != IsXExtensionPointer)
continue;
gdk_error_trap_push();
XDevice *device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
devicelist[i].id);
if (gdk_error_trap_pop ())
continue;
gdk_error_trap_push ();
if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, prop, 0, 1, False,
XA_INTEGER, &realtype, &realformat, &nitems,
&bytes_after, &data) == Success) && (realtype != None)) {
XFree (data);
ret = TRUE;
}
gdk_error_trap_pop_ignored ();
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
if (ret)
break;
}
XFree (version);
XFreeDeviceList (devicelist);
return ret;
}
/* Set up the property editors in the dialog. */
static void
setup_dialog (GtkBuilder *dialog)
@ -316,7 +261,7 @@ setup_dialog (GtkBuilder *dialog)
G_SETTINGS_BIND_DEFAULT);
/* Trackpad page */
if (find_synaptics () == FALSE)
if (touchpad_is_present () == FALSE)
gtk_notebook_remove_page (GTK_NOTEBOOK (WID ("prefs_widget")), -1);
else {
g_settings_bind (touchpad_settings, "disable-while-typing",