From 219ae5b628f9ffe2be0876d5911cc04e52bef5f8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 21 Aug 2009 16:38:53 +1000 Subject: dix: hide the sequenceNumber key repeat hack behind two functions. Just in case we figure out a better way to do it in the future. Signed-off-by: Peter Hutterer --- dix/eventconvert.c | 36 ++++++++++++++++++++++++++++++++---- dix/events.c | 8 +++++--- 2 files changed, 37 insertions(+), 7 deletions(-) (limited to 'dix') diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 69d2f1fec..21eed40e1 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -55,6 +55,35 @@ static int eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count); static int eventToDeviceChanged(DeviceChangedEvent *ev, xEvent **dcce); static int eventToDeviceEvent(DeviceEvent *ev, xEvent **xi); static int eventToRawEvent(RawDeviceEvent *ev, xEvent **xi); + +/* Do not use, read comments below */ +BOOL EventIsKeyRepeat(xEvent *event); + +/** + * Hack to allow detectable autorepeat for core and XI1 events. + * The sequence number is unused until we send to the client and can be + * misused to store data. More or less, anyway. + * + * Do not use this. It may change any time without warning, eat your babies + * and piss on your cat. + */ +static void +EventSetKeyRepeatFlag(xEvent *event, BOOL on) +{ + event->u.u.sequenceNumber = on; +} + +/** + * Check if the event was marked as a repeat event before. + * NOTE: This is a nasty hack and should NOT be used by anyone else but + * TryClientEvents. + */ +BOOL +EventIsKeyRepeat(xEvent *event) +{ + return !!event->u.u.sequenceNumber; +} + /** * Convert the given event to the respective core event. * @@ -90,8 +119,7 @@ EventToCore(InternalEvent *event, xEvent *core) core->u.keyButtonPointer.rootX = e->root_x; core->u.keyButtonPointer.rootY = e->root_y; core->u.keyButtonPointer.state = e->corestate; - if (e->type == ET_KeyPress && e->key_repeat) - core->u.u.sequenceNumber = 1; + EventSetKeyRepeatFlag(core, (e->type == ET_KeyPress && e->key_repeat)); } break; case ET_ProximityIn: @@ -239,8 +267,8 @@ eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count) kbp->root_y = ev->root_y; kbp->deviceid = ev->deviceid; kbp->state = ev->corestate; - if (ev->type == ET_KeyPress && ev->key_repeat) - kbp->sequenceNumber = 1; + EventSetKeyRepeatFlag((xEvent*)kbp, + (ev->type == ET_KeyPress && ev->key_repeat)); if (num_events > 1) kbp->deviceid |= MORE_EVENTS; diff --git a/dix/events.c b/dix/events.c index 62eb6c225..90a2675c4 100644 --- a/dix/events.c +++ b/dix/events.c @@ -226,6 +226,9 @@ static Bool CheckPassiveGrabsOnWindow(WindowPtr pWin, DeviceEvent *event, BOOL checkCore); +/** Key repeat hack. Do not use but in TryClientEvents */ +extern BOOL EventIsKeyRepeat(xEvent *event); + /** * Main input device struct. * inputInfo.pointer @@ -1948,8 +1951,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents, return 1; } else if (type == KeyPress) { - /* sequenceNumber == 1 if autorepeat is set */ - if (pEvents->u.u.sequenceNumber) + if (EventIsKeyRepeat(pEvents)) { if (!_XkbWantsDetectableAutoRepeat(client)) { @@ -1970,7 +1972,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents, } else if (type == DeviceKeyPress) { - if (((deviceKeyButtonPointer *)pEvents)->sequenceNumber) + if (EventIsKeyRepeat(pEvents)) { if (!_XkbWantsDetectableAutoRepeat(client)) { -- cgit v1.2.3