diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-01-13 10:48:30 +1000 |
---|---|---|
committer | Jens Granseuer <jensgr@gmx.net> | 2010-01-16 11:24:57 +0100 |
commit | 868060f29a83813859a0642ed7092b9b87d29cad (patch) | |
tree | f3eb0935ebdacf96b8256791225cb1e6aa925a53 | |
parent | 3bbb2ee1bfe0ce36838045bb381182de7daa4f44 (diff) | |
download | gnome-settings-daemon-868060f29a83813859a0642ed7092b9b87d29cad.tar.gz |
Don't allow left-handed setting for single-button touchpads.
Setting a left-handed setting to a single-button touchpad may leave the
user without a left button to click (provided tapping is disabled too).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | plugins/mouse/gsd-mouse-manager.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c index ea2f5ff3..d0ecf6b5 100644 --- a/plugins/mouse/gsd-mouse-manager.c +++ b/plugins/mouse/gsd-mouse-manager.c @@ -261,6 +261,36 @@ xinput_device_has_buttons (XDeviceInfo *device_info) return FALSE; } +static gboolean +touchpad_has_single_button (XDevice *device) +{ + Atom type, prop; + int format; + unsigned long nitems, bytes_after; + unsigned char *data; + gboolean is_single_button = FALSE; + int rc; + + prop = XInternAtom (GDK_DISPLAY (), "Synaptics Capabilities", False); + if (!prop) + return FALSE; + + gdk_error_trap_push (); + rc = XGetDeviceProperty (GDK_DISPLAY (), device, prop, 0, 1, False, + XA_INTEGER, &type, &format, &nitems, + &bytes_after, &data); + if (rc == Success && type == XA_INTEGER && format == 8 && nitems >= 3) + is_single_button = (data[0] == 1 && data[1] == 0 && data[2] == 0); + + if (rc == Success) + XFree (data); + + gdk_error_trap_pop (); + + return is_single_button; +} + + static void set_xinput_devices_left_handed (gboolean left_handed) { @@ -292,11 +322,15 @@ set_xinput_devices_left_handed (gboolean left_handed) if (device != NULL) { GConfClient *client = gconf_client_get_default (); gboolean tap = gconf_client_get_bool (client, KEY_TAP_TO_CLICK, NULL); + gboolean single_button = touchpad_has_single_button (device); - if (tap) + if (tap && !single_button) set_tap_to_click (tap, left_handed); XCloseDevice (GDK_DISPLAY (), device); g_object_unref (client); + + if (single_button) + continue; } gdk_error_trap_push (); |