[PATCH v2] xkb: fill in keycode and event type for slow keys enablement

Peter Hutterer peter.hutterer at who-t.net
Wed Jul 25 23:07:25 PDT 2012


Keith, 

please merge this one directly (this time I double-checked, not in
the repo :)

Cheers,
  Peter

On Tue, Jun 26, 2012 at 10:49:32AM +1000, Peter Hutterer wrote:
> eventType is set for the type that triggered a XkbControlsNotify event.
> Technically, SlowKeys is triggered by a timer which doesn't have a matching
> core event type. So we used to use 0 here.
> 
> Practically, the timer is triggered by a key press + hold and cancelled when
> the key is released before the timeout expires. So we might as well set
> KeyPress (keycode) in the ControlsNotify to give clients a chance to differ
> between timer-triggered SlowKeys and client-triggered ones.
> 
> This is a chance in behaviour, though I suspect with little impact.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> Acked-by: Daniel Stone <daniel at fooishbar.org>
> ---
> Changes to v2:
> - store in XkbSrvInfoRec
> 
>  include/xkbsrv.h |    1 +
>  xkb/xkbAccessX.c |    6 ++++--
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/include/xkbsrv.h b/include/xkbsrv.h
> index a19c8fb..f839edb 100644
> --- a/include/xkbsrv.h
> +++ b/include/xkbsrv.h
> @@ -171,6 +171,7 @@ typedef struct _XkbSrvInfo {
>      KeyCode mouseKey;
>      KeyCode inactiveKey;
>      KeyCode slowKey;
> +    KeyCode slowKeyEnableKey;
>      KeyCode repeatKey;
>      CARD8 krgTimerActive;
>      CARD8 beepType;
> diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
> index fe28e12..e7e0b73 100644
> --- a/xkb/xkbAccessX.c
> +++ b/xkb/xkbAccessX.c
> @@ -291,8 +291,8 @@ AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg)
>          return 4000;
>      }
>      xkbi->krgTimerActive = _OFF_TIMER;
> -    cn.keycode = 0;
> -    cn.eventType = 0;
> +    cn.keycode = xkbi->slowKeyEnableKey;
> +    cn.eventType = KeyPress;
>      cn.requestMajor = 0;
>      cn.requestMinor = 0;
>      if (xkbi->desc->ctrls->enabled_ctrls & XkbSlowKeysMask) {
> @@ -304,6 +304,7 @@ AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg)
>          LogMessage(X_INFO, "XKB SlowKeys are now enabled. Hold shift to disable.\n");
>      }
>  
> +    xkbi->slowKeyEnableKey = 0;
>      return 0;
>  }
>  
> @@ -462,6 +463,7 @@ AccessXFilterPressEvent(DeviceEvent *event, DeviceIntPtr keybd)
>      if (ctrls->enabled_ctrls & XkbAccessXKeysMask) {
>          /* check for magic sequences */
>          if ((sym[0] == XK_Shift_R) || (sym[0] == XK_Shift_L)) {
> +            xkbi->slowKeyEnableKey = key;
>              if (XkbAX_NeedFeedback(ctrls, XkbAX_SlowWarnFBMask)) {
>                  xkbi->krgTimerActive = _KRG_WARN_TIMER;
>                  xkbi->krgTimer = TimerSet(xkbi->krgTimer, 0, 4000,
> -- 
> 1.7.10.2


More information about the xorg-devel mailing list