[PATCH xf86-input-synaptics] syndaemon: enable touchpad when pressing a modifier combo

Anton Lindqvist anton.lindqvist at gmail.com
Mon Aug 1 08:54:29 UTC 2016


I run syndaemon with the -K option and often find myself in the
following scenario: I'm typing non modifier combos in my terminal, only
to later press a modifier combo causing my WM to switch application, the
touchpad is then disabled due to my previous typing. I find this
annoying and therefore propose the following change: enable the touchpad
immediately once a modifier combo is detected. This is done by adding a
third possible return value from keyboard_activity causing the main loop
to reset the timestamp of the last activity which will cause the
touchpad to be enabled.

Any feedback would be much appreciated and don't forget to bring your
scissor if you decide to apply this patch.

>8------------8<

When ignoring modifier combos enable the touchpad immediately when a
such a combo is detected.

Signed-off-by: Anton Lindqvist <anton.lindqvist at gmail.com>
---
 tools/syndaemon.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/tools/syndaemon.c b/tools/syndaemon.c
index 29e75f5..021bf2a 100644
--- a/tools/syndaemon.c
+++ b/tools/syndaemon.c
@@ -182,7 +182,9 @@ install_signal_handler(void)
 }
 
 /**
- * Return non-zero if the keyboard state has changed since the last call.
+ * Return 1 if the keyboard state has changed since the last call, -1 if
+ * the keyboard state contains a new modifier combo since the last call or 0
+ * otherwise.
  */
 static int
 keyboard_activity(Display * display)
@@ -203,7 +205,10 @@ keyboard_activity(Display * display)
     if (ignore_modifier_combos) {
         for (i = 0; i < KEYMAP_SIZE; i++) {
             if (key_state[i] & ~keyboard_mask[i]) {
-                ret = 0;
+                if (old_key_state[i] & ~keyboard_mask[i])
+                    ret = 0;
+                else
+                    ret = -1;
                 break;
             }
         }
@@ -232,8 +237,14 @@ main_loop(Display * display, double idle_time, int poll_delay)
 
     for (;;) {
         current_time = get_time();
-        if (keyboard_activity(display))
-            last_activity = current_time;
+        switch (keyboard_activity(display)) {
+            case 1:
+                last_activity = current_time;
+                break;
+            case -1:
+                last_activity = 0.0;
+                break;
+        }
 
         /* If system times goes backwards, touchpad can get locked. Make
          * sure our last activity wasn't in the future and reset if it was. */
-- 
2.7.0


More information about the xorg-devel mailing list