From 2ab59a993276694f9afb7039a96cdb01553076d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Matthias=20Sch=C3=A4fer?= Date: Sat, 5 Jan 2013 14:07:44 +0100 Subject: [PATCH] make touchpad type delay configurable (bug #8948) --- dialogs/mouse-settings/Makefile.am | 2 ++ dialogs/mouse-settings/main.c | 32 +++++++++++++++-- dialogs/mouse-settings/mouse-dialog.glade | 54 ++++++++++++++++++++++++++++- xfsettingsd/pointers.c | 38 +++++++++++--------- 4 files changed, 106 insertions(+), 20 deletions(-) diff --git a/dialogs/mouse-settings/Makefile.am b/dialogs/mouse-settings/Makefile.am index 3975905..66db421 100644 --- a/dialogs/mouse-settings/Makefile.am +++ b/dialogs/mouse-settings/Makefile.am @@ -19,6 +19,7 @@ xfce4_mouse_settings_CFLAGS = \ $(GTK_CFLAGS) \ $(LIBXFCE4UTIL_CFLAGS) \ $(LIBXFCE4UI_CFLAGS) \ + $(EXO_CFLAGS) \ $(XFCONF_CFLAGS) \ $(XI_CFLAGS) \ $(XFCONF_CFLAGS) \ @@ -33,6 +34,7 @@ xfce4_mouse_settings_LDADD = \ $(GTK_LIBS) \ $(LIBXFCE4UTIL_LIBS) \ $(LIBXFCE4UI_LIBS) \ + $(EXO_LIBS) \ $(XFCONF_LIBS) \ $(XI_LIBS) \ $(LIBX11_LIBS) \ diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c index f4b475b..eb85b41 100644 --- a/dialogs/mouse-settings/main.c +++ b/dialogs/mouse-settings/main.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -136,6 +137,18 @@ mouse_settings_format_value_ms (GtkScale *scale, +#ifdef DEVICE_PROPERTIES +static gchar * +mouse_settings_format_value_s (GtkScale *scale, + gdouble value) +{ + /* seconds value for some of the scales in the dialog */ + return g_strdup_printf (_("%g s"), value); +} +#endif + + + #ifdef HAVE_XCURSOR static GdkPixbuf * @@ -1582,6 +1595,8 @@ main (gint argc, gchar **argv) XExtensionVersion *version = NULL; #ifdef DEVICE_PROPERTIES gchar *syndaemon; + GObject *synaptics_disable_while_type; + GObject *synaptics_disable_duration_table; #endif /* setup translation domain */ @@ -1703,12 +1718,25 @@ main (gint argc, gchar **argv) G_CALLBACK (mouse_settings_device_reset), builder); #ifdef DEVICE_PROPERTIES - object = gtk_builder_get_object (builder, "synaptics-disable-while-type"); + synaptics_disable_while_type = gtk_builder_get_object (builder, "synaptics-disable-while-type"); syndaemon = g_find_program_in_path ("syndaemon"); gtk_widget_set_sensitive (GTK_WIDGET (object), syndaemon != NULL); g_free (syndaemon); xfconf_g_property_bind (pointers_channel, "/DisableTouchpadWhileTyping", - G_TYPE_BOOLEAN, G_OBJECT (object), "active"); + G_TYPE_BOOLEAN, G_OBJECT (synaptics_disable_while_type), "active"); + + synaptics_disable_duration_table = gtk_builder_get_object (builder, "synaptics-disable-duration-table"); + + exo_binding_new (G_OBJECT (synaptics_disable_while_type), "active", + G_OBJECT (synaptics_disable_duration_table), "sensitive"); + + object = gtk_builder_get_object (builder, "synaptics-disable-duration-scale"); + g_signal_connect (G_OBJECT (object), "format-value", + G_CALLBACK (mouse_settings_format_value_s), NULL); + + object = gtk_builder_get_object (builder, "synaptics-disable-duration"); + xfconf_g_property_bind (pointers_channel, "/DisableTouchpadDuration", + G_TYPE_DOUBLE, G_OBJECT (object), "value"); object = gtk_builder_get_object (builder, "synaptics-tap-to-click"); g_signal_connect_swapped (G_OBJECT (object), "toggled", diff --git a/dialogs/mouse-settings/mouse-dialog.glade b/dialogs/mouse-settings/mouse-dialog.glade index d3aab0d..681fdb9 100644 --- a/dialogs/mouse-settings/mouse-dialog.glade +++ b/dialogs/mouse-settings/mouse-dialog.glade @@ -42,6 +42,13 @@ False gtk-revert-to-saved + + 0.10000000000000001 + 4 + 2 + 0.10000000000000001 + 1 + @@ -490,6 +497,51 @@ + + True + False + 6 + 1 + 2 + 12 + 6 + + + True + False + 0 + Duratio_n: + True + synaptics-disable-duration-scale + + + GTK_FILL + GTK_FILL + + + + + True + True + The duration in seconds for which the touchpad will be disabled + delayed + synaptics-disable-duration + 1 + right + + + 1 + 2 + + + + + True + True + 1 + + + Tap touchpad to clic_k False @@ -502,7 +554,7 @@ True True - 1 + 2 diff --git a/xfsettingsd/pointers.c b/xfsettingsd/pointers.c index e7192e7..79fdedc 100644 --- a/xfsettingsd/pointers.c +++ b/xfsettingsd/pointers.c @@ -221,7 +221,9 @@ xfce_pointers_helper_syndaemon_check (XfcePointersHelper *helper) Atom *props; gint i, nprops; gboolean have_synaptics = FALSE; - gchar *args[] = { "syndaemon", "-i", "2.0", "-K", "-R", NULL }; + gdouble disable_duration; + gchar disable_duration_string[256]; + gchar *args[] = { "syndaemon", "-i", disable_duration_string, "-K", "-R", NULL }; GError *error = NULL; /* only stop a running daemon */ @@ -272,25 +274,26 @@ xfce_pointers_helper_syndaemon_check (XfcePointersHelper *helper) start_stop_daemon: + /* stop the daemon in any case */ + xfce_pointers_helper_syndaemon_stop (helper); + if (have_synaptics) { - if (helper->syndaemon_pid == 0) + disable_duration = xfconf_channel_get_double (helper->channel, + "/DisableTouchpadDuration", + 2.0); + g_snprintf (disable_duration_string, sizeof(disable_duration_string), + "%.1f", disable_duration); + + if (!g_spawn_async (NULL, args, NULL, G_SPAWN_SEARCH_PATH, + NULL, NULL, &helper->syndaemon_pid, &error)) { - if (!g_spawn_async (NULL, args, NULL, G_SPAWN_SEARCH_PATH, - NULL, NULL, &helper->syndaemon_pid, &error)) - { - g_critical ("Spawning syndaemon failed: %s", error->message); - g_error_free (error); - } - - xfsettings_dbg (XFSD_DEBUG_POINTERS, "Started syndaemon with pid %d", - helper->syndaemon_pid); + g_critical ("Spawning syndaemon failed: %s", error->message); + g_error_free (error); } - } - else - { - /* stop the daemon */ - xfce_pointers_helper_syndaemon_stop (helper); + + xfsettings_dbg (XFSD_DEBUG_POINTERS, "Started syndaemon with pid %d", + helper->syndaemon_pid); } #endif } @@ -917,7 +920,8 @@ xfce_pointers_helper_channel_property_changed (XfconfChannel *channel, return; /* check the daemon status */ - if (strcmp (property_name, "/DisableTouchpadWhileTyping") == 0) + if ((strcmp (property_name, "/DisableTouchpadWhileTyping") == 0) || + (strcmp (property_name, "/DisableTouchpadDuration") == 0)) { xfce_pointers_helper_syndaemon_check (helper); return; -- 1.7.10.4