From 5b5941862cc88193fedd2e381f8bec4dcf411ec9 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 26 Jun 2012 10:30:35 +1000 Subject: [PATCH] xkb: fill in keycode and event type for slow keys enablement 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 --- 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