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

Peter Hutterer peter.hutterer at who-t.net
Wed Aug 3 07:42:43 UTC 2016


On Mon, Aug 01, 2016 at 10:54:29AM +0200, Anton Lindqvist wrote:
> 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.

seems like a sensible addition, thanks.

> 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.

typo "a such"
and I wouldn't mind a bit more details on when it enables/disables the
touchpad because I had to read to code and test to figure it out. that's
what the commit message should relay. You're using modifier combo in a
couple of different ways which is confusing. in the syndaemon context, the
modifier combo means modifers + keys but your patch re-enables the touchpad
as soon as *any* modifier is pressed.

please explain this in the commit message.

> 
> 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.
>   */

let's define an enum and use that, much more expressive than random integer
values. ACTIVITY_NONE, ACTIVITY_MODIFIER, ACTIVITY_KEY or something.

>  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. */

syndaemon has 2 modes, one uses the RECORD extension (iirc that's the one
used by GNOME until recently). Please add the same functionality to the
RECORD mode as well.

Cheers,
   Peter


More information about the xorg-devel mailing list