From 9a13cc8529189c3b316c7bb7c96ab27e9e56aad2 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Wed, 20 May 2015 15:33:49 +0200
Subject: [PATCH] mouse: Do not disable touchpad buttons
Touchpad buttons are disabled also if touchpad is disabled using
"Device Enabled" property. Unfortunately some touchpads share those
buttons with trackpoint, which is consequently unusable. Disable
touchpad using "Synaptics Off" property instead to avoid disabling
the buttons.
Remove also some redundant calls to enable/disable touchpad and
make sure syndaemon isn't running if the touchpads are disabled.
https://bugzilla.gnome.org/show_bug.cgi?id=747504
---
plugins/common/gsd-input-helper.c | 23 +++++++++++++++++++++++
plugins/common/gsd-input-helper.h | 3 +++
plugins/mouse/gsd-mouse-manager.c | 37 +++++++++++--------------------------
3 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index 4872506..3907c70 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -464,6 +464,29 @@ set_device_enabled (int device_id,
return TRUE;
}
+gboolean
+set_touchpad_device_enabled (int device_id,
+ gboolean enabled)
+{
+ Atom prop;
+ guchar value;
+
+ prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Synaptics Off", False);
+ if (!prop)
+ return FALSE;
+
+ gdk_error_trap_push ();
+
+ value = enabled ? 0 : 1;
+ XIChangeProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ device_id, prop, XA_INTEGER, 8, PropModeReplace, &value, 1);
+
+ if (gdk_error_trap_pop ())
+ return FALSE;
+
+ return TRUE;
+}
+
static const char *
custom_command_to_string (CustomCommand command)
{
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index 85e8492..53938bc 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -57,6 +57,9 @@ gboolean supports_xtest (void);
gboolean set_device_enabled (int device_id,
gboolean enabled);
+gboolean set_touchpad_device_enabled (int device_id,
+ gboolean enabled);
+
gboolean device_is_touchpad (XDevice *xdevice);
gboolean device_info_is_touchpad (XDeviceInfo *device_info);
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index 2cd4257..8b62463 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -552,7 +552,10 @@ syndaemon_died (GPid pid, gint status, gpointer user_data)
static int
set_disable_w_typing (GsdMouseManager *manager, gboolean state)
{
- if (state && touchpad_is_present ()) {
+ gboolean touchpad_enabled;
+
+ touchpad_enabled = g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_ENABLED);
+ if (state && touchpad_enabled && touchpad_is_present ()) {
GError *error = NULL;
GPtrArray *args;
@@ -814,7 +817,7 @@ set_touchpad_disabled (GdkDevice *device)
return;
}
- if (set_device_enabled (id, FALSE) == FALSE)
+ if (set_touchpad_device_enabled (id, FALSE) == FALSE)
g_warning ("Error disabling device \"%s\" (%d)", gdk_device_get_name (device), id);
else
g_debug ("Disabled device \"%s\" (%d)", gdk_device_get_name (device), id);
@@ -839,7 +842,7 @@ set_touchpad_enabled (int id)
return;
}
- if (set_device_enabled (id, TRUE) == FALSE)
+ if (set_touchpad_device_enabled (id, TRUE) == FALSE)
g_warning ("Error enabling device \"%d\"", id);
else
g_debug ("Enabled device %d", id);
@@ -948,6 +951,8 @@ set_mouse_settings (GsdMouseManager *manager,
set_natural_scroll (manager, device, g_settings_get_boolean (manager->priv->touchpad_settings, KEY_NATURAL_SCROLL_ENABLED));
if (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_ENABLED) == FALSE)
set_touchpad_disabled (device);
+ else
+ set_touchpad_enabled (gdk_x11_device_get_id (device));
}
static void
@@ -1063,6 +1068,9 @@ touchpad_callback (GSettings *settings,
return;
}
+ if (g_str_equal (key, KEY_TOUCHPAD_ENABLED))
+ set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_DISABLE_W_TYPING));
+
devices = gdk_device_manager_list_devices (manager->priv->device_manager, GDK_DEVICE_TYPE_SLAVE);
for (l = devices; l != NULL; l = l->next) {
@@ -1098,18 +1106,6 @@ touchpad_callback (GSettings *settings,
}
}
g_list_free (devices);
-
- if (g_str_equal (key, KEY_TOUCHPAD_ENABLED) &&
- g_settings_get_boolean (settings, key)) {
- devices = get_disabled_devices (manager->priv->device_manager);
- for (l = devices; l != NULL; l = l->next) {
- int device_id;
-
- device_id = GPOINTER_TO_INT (l->data);
- set_touchpad_enabled (device_id);
- }
- g_list_free (devices);
- }
}
/* Re-enable touchpad when any other pointing device isn't present. */
@@ -1233,17 +1229,6 @@ gsd_mouse_manager_idle_cb (GsdMouseManager *manager)
ensure_touchpad_active (manager);
- if (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_ENABLED)) {
- devices = get_disabled_devices (manager->priv->device_manager);
- for (l = devices; l != NULL; l = l->next) {
- int device_id;
-
- device_id = GPOINTER_TO_INT (l->data);
- set_touchpad_enabled (device_id);
- }
- g_list_free (devices);
- }
-
gnome_settings_profile_end (NULL);
manager->priv->start_idle_id = 0;
--
2.4.1