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 <peter.hutterer@who-t.net>
This commit is contained in:
parent
bfb219f532
commit
219ae5b628
|
@ -55,6 +55,35 @@ static int eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count);
|
||||||
static int eventToDeviceChanged(DeviceChangedEvent *ev, xEvent **dcce);
|
static int eventToDeviceChanged(DeviceChangedEvent *ev, xEvent **dcce);
|
||||||
static int eventToDeviceEvent(DeviceEvent *ev, xEvent **xi);
|
static int eventToDeviceEvent(DeviceEvent *ev, xEvent **xi);
|
||||||
static int eventToRawEvent(RawDeviceEvent *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.
|
* 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.rootX = e->root_x;
|
||||||
core->u.keyButtonPointer.rootY = e->root_y;
|
core->u.keyButtonPointer.rootY = e->root_y;
|
||||||
core->u.keyButtonPointer.state = e->corestate;
|
core->u.keyButtonPointer.state = e->corestate;
|
||||||
if (e->type == ET_KeyPress && e->key_repeat)
|
EventSetKeyRepeatFlag(core, (e->type == ET_KeyPress && e->key_repeat));
|
||||||
core->u.u.sequenceNumber = 1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ET_ProximityIn:
|
case ET_ProximityIn:
|
||||||
|
@ -239,8 +267,8 @@ eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count)
|
||||||
kbp->root_y = ev->root_y;
|
kbp->root_y = ev->root_y;
|
||||||
kbp->deviceid = ev->deviceid;
|
kbp->deviceid = ev->deviceid;
|
||||||
kbp->state = ev->corestate;
|
kbp->state = ev->corestate;
|
||||||
if (ev->type == ET_KeyPress && ev->key_repeat)
|
EventSetKeyRepeatFlag((xEvent*)kbp,
|
||||||
kbp->sequenceNumber = 1;
|
(ev->type == ET_KeyPress && ev->key_repeat));
|
||||||
|
|
||||||
if (num_events > 1)
|
if (num_events > 1)
|
||||||
kbp->deviceid |= MORE_EVENTS;
|
kbp->deviceid |= MORE_EVENTS;
|
||||||
|
|
|
@ -226,6 +226,9 @@ static Bool CheckPassiveGrabsOnWindow(WindowPtr pWin,
|
||||||
DeviceEvent *event,
|
DeviceEvent *event,
|
||||||
BOOL checkCore);
|
BOOL checkCore);
|
||||||
|
|
||||||
|
/** Key repeat hack. Do not use but in TryClientEvents */
|
||||||
|
extern BOOL EventIsKeyRepeat(xEvent *event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main input device struct.
|
* Main input device struct.
|
||||||
* inputInfo.pointer
|
* inputInfo.pointer
|
||||||
|
@ -1948,8 +1951,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
|
||||||
return 1;
|
return 1;
|
||||||
} else if (type == KeyPress)
|
} else if (type == KeyPress)
|
||||||
{
|
{
|
||||||
/* sequenceNumber == 1 if autorepeat is set */
|
if (EventIsKeyRepeat(pEvents))
|
||||||
if (pEvents->u.u.sequenceNumber)
|
|
||||||
{
|
{
|
||||||
if (!_XkbWantsDetectableAutoRepeat(client))
|
if (!_XkbWantsDetectableAutoRepeat(client))
|
||||||
{
|
{
|
||||||
|
@ -1970,7 +1972,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
|
||||||
|
|
||||||
} else if (type == DeviceKeyPress)
|
} else if (type == DeviceKeyPress)
|
||||||
{
|
{
|
||||||
if (((deviceKeyButtonPointer *)pEvents)->sequenceNumber)
|
if (EventIsKeyRepeat(pEvents))
|
||||||
{
|
{
|
||||||
if (!_XkbWantsDetectableAutoRepeat(client))
|
if (!_XkbWantsDetectableAutoRepeat(client))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue