Xi: make ProcessOtherEvents more InternalEvent aware.
Get rid of the deviceValuator processing and a few other things, but still drop back into XI before checking device grabs or doing anything else. NoticeEventTime now needs to take InternalEvents, and while we're at it, change NoticeTime from a macro to a function. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
3a02e538db
commit
75595ba4aa
105
Xi/exevents.c
105
Xi/exevents.c
|
@ -890,14 +890,12 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
|
||||||
void
|
void
|
||||||
ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count)
|
ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
GrabPtr grab = device->deviceGrab.grab;
|
GrabPtr grab = device->deviceGrab.grab;
|
||||||
Bool deactivateDeviceGrab = FALSE;
|
Bool deactivateDeviceGrab = FALSE;
|
||||||
int key = 0, rootX, rootY;
|
int key = 0, rootX, rootY;
|
||||||
ButtonClassPtr b;
|
ButtonClassPtr b;
|
||||||
KeyClassPtr k;
|
KeyClassPtr k;
|
||||||
ValuatorClassPtr v;
|
ValuatorClassPtr v;
|
||||||
deviceValuator *xV;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int state;
|
int state;
|
||||||
DeviceIntPtr mouse = NULL, kbd = NULL;
|
DeviceIntPtr mouse = NULL, kbd = NULL;
|
||||||
|
@ -938,18 +936,27 @@ ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count)
|
||||||
if (device->isMaster || !device->u.master)
|
if (device->isMaster || !device->u.master)
|
||||||
CheckMotion(event, device);
|
CheckMotion(event, device);
|
||||||
|
|
||||||
|
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case ET_Motion:
|
||||||
|
case ET_ButtonPress:
|
||||||
|
case ET_ButtonRelease:
|
||||||
|
case ET_KeyPress:
|
||||||
|
case ET_KeyRelease:
|
||||||
|
case ET_ProximityIn:
|
||||||
|
case ET_ProximityOut:
|
||||||
|
GetSpritePosition(device, &rootX, &rootY);
|
||||||
|
event->root_x = rootX;
|
||||||
|
event->root_y = rootY;
|
||||||
|
NoticeEventTime((InternalEvent*)event);
|
||||||
|
event->corestate = state;
|
||||||
|
key = event->detail.key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
nevents = ConvertBackToXI((InternalEvent*)ev, xE);
|
nevents = ConvertBackToXI((InternalEvent*)ev, xE);
|
||||||
|
|
||||||
if (xE->u.u.type != DeviceValuator && xE->u.u.type != GenericEvent) {
|
|
||||||
GetSpritePosition(device, &rootX, &rootY);
|
|
||||||
xE->u.keyButtonPointer.rootX = rootX;
|
|
||||||
xE->u.keyButtonPointer.rootY = rootY;
|
|
||||||
NoticeEventTime(xE);
|
|
||||||
|
|
||||||
xE->u.keyButtonPointer.state = state;
|
|
||||||
|
|
||||||
key = xE->u.u.detail;
|
|
||||||
}
|
|
||||||
if (DeviceEventCallback) {
|
if (DeviceEventCallback) {
|
||||||
DeviceEventInfoRec eventinfo;
|
DeviceEventInfoRec eventinfo;
|
||||||
|
|
||||||
|
@ -958,43 +965,41 @@ ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count)
|
||||||
CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
|
CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Valuator event handling */
|
switch(event->type)
|
||||||
xV = (deviceValuator*)xE;
|
{
|
||||||
for (i = 1; i < count; i++) {
|
case ET_KeyPress:
|
||||||
if ((++xV)->type == DeviceValuator)
|
if (!grab && CheckDeviceGrabs(device, xE, 0, nevents)) {
|
||||||
xV->device_state = state;
|
device->deviceGrab.activatingKey = key;
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (xE->u.u.type == DeviceKeyPress) {
|
break;
|
||||||
if (!grab && CheckDeviceGrabs(device, xE, 0, count)) {
|
case ET_KeyRelease:
|
||||||
device->deviceGrab.activatingKey = key;
|
if (device->deviceGrab.fromPassiveGrab &&
|
||||||
return;
|
(key == device->deviceGrab.activatingKey))
|
||||||
}
|
deactivateDeviceGrab = TRUE;
|
||||||
} else if (xE->u.u.type == DeviceKeyRelease) {
|
break;
|
||||||
if (device->deviceGrab.fromPassiveGrab &&
|
case ET_ButtonPress:
|
||||||
(key == device->deviceGrab.activatingKey))
|
event->detail.button = b->map[key];
|
||||||
deactivateDeviceGrab = TRUE;
|
if (!event->detail.button) { /* there's no button 0 */
|
||||||
} else if (xE->u.u.type == DeviceButtonPress) {
|
event->detail.button = key;
|
||||||
xE->u.u.detail = b->map[key];
|
xE->u.u.detail = key; /* XXX: temporary */
|
||||||
if (xE->u.u.detail == 0) {
|
return;
|
||||||
xE->u.u.detail = key;
|
}
|
||||||
return;
|
if (!grab && CheckDeviceGrabs(device, xE, 0, nevents))
|
||||||
}
|
{
|
||||||
if (!grab && CheckDeviceGrabs(device, xE, 0, count))
|
/* if a passive grab was activated, the event has been sent
|
||||||
{
|
* already */
|
||||||
/* if a passive grab was activated, the event has been sent
|
return;
|
||||||
* already */
|
}
|
||||||
return;
|
case ET_ButtonRelease:
|
||||||
}
|
event->detail.button = b->map[key];
|
||||||
|
if (!event->detail.button) { /* there's no button 0 */
|
||||||
} else if (xE->u.u.type == DeviceButtonRelease) {
|
event->detail.button = key;
|
||||||
xE->u.u.detail = b->map[key];
|
xE->u.u.detail = key; /* XXX: temporary */
|
||||||
if (xE->u.u.detail == 0) {
|
return;
|
||||||
xE->u.u.detail = key;
|
}
|
||||||
return;
|
if (!b->buttonsDown && device->deviceGrab.fromPassiveGrab)
|
||||||
}
|
deactivateDeviceGrab = TRUE;
|
||||||
if (!b->buttonsDown && device->deviceGrab.fromPassiveGrab)
|
|
||||||
deactivateDeviceGrab = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grab)
|
if (grab)
|
||||||
|
@ -1007,7 +1012,7 @@ ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count)
|
||||||
|
|
||||||
if (deactivateDeviceGrab == TRUE)
|
if (deactivateDeviceGrab == TRUE)
|
||||||
(*device->deviceGrab.DeactivateGrab) (device);
|
(*device->deviceGrab.DeactivateGrab) (device);
|
||||||
xE->u.u.detail = key;
|
event->detail.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
29
dix/events.c
29
dix/events.c
|
@ -974,29 +974,32 @@ XineramaGetCursorScreen(DeviceIntPtr pDev)
|
||||||
#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
|
#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
MonthChangedOrBadTime(xEvent *xE)
|
MonthChangedOrBadTime(InternalEvent *ev)
|
||||||
{
|
{
|
||||||
/* If the ddx/OS is careless about not processing timestamped events from
|
/* If the ddx/OS is careless about not processing timestamped events from
|
||||||
* different sources in sorted order, then it's possible for time to go
|
* different sources in sorted order, then it's possible for time to go
|
||||||
* backwards when it should not. Here we ensure a decent time.
|
* backwards when it should not. Here we ensure a decent time.
|
||||||
*/
|
*/
|
||||||
if ((currentTime.milliseconds - XE_KBPTR.time) > TIMESLOP)
|
if ((currentTime.milliseconds - ev->u.any.time) > TIMESLOP)
|
||||||
currentTime.months++;
|
currentTime.months++;
|
||||||
else
|
else
|
||||||
XE_KBPTR.time = currentTime.milliseconds;
|
ev->u.any.time = currentTime.milliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NoticeTime(xE) { \
|
static void
|
||||||
if ((xE)->u.keyButtonPointer.time < currentTime.milliseconds) \
|
NoticeTime(InternalEvent *ev)
|
||||||
MonthChangedOrBadTime(xE); \
|
{
|
||||||
currentTime.milliseconds = (xE)->u.keyButtonPointer.time; \
|
if (ev->u.any.time < currentTime.milliseconds)
|
||||||
lastDeviceEventTime = currentTime; }
|
MonthChangedOrBadTime(ev);
|
||||||
|
currentTime.milliseconds = ev->u.any.time;
|
||||||
|
lastDeviceEventTime = currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NoticeEventTime(xEvent *xE)
|
NoticeEventTime(InternalEvent *ev)
|
||||||
{
|
{
|
||||||
if (!syncEvents.playingEvents)
|
if (!syncEvents.playingEvents)
|
||||||
NoticeTime(xE);
|
NoticeTime(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -1022,11 +1025,11 @@ EnqueueEvent(xEvent *ev, DeviceIntPtr device, int count)
|
||||||
static xEvent xi[1000]; /* enough bytes for the events we have atm */
|
static xEvent xi[1000]; /* enough bytes for the events we have atm */
|
||||||
xEvent *xE = xi;
|
xEvent *xE = xi;
|
||||||
|
|
||||||
|
|
||||||
|
NoticeTime((InternalEvent*)event);
|
||||||
|
|
||||||
nevents = ConvertBackToXI((InternalEvent*)ev, xE);
|
nevents = ConvertBackToXI((InternalEvent*)ev, xE);
|
||||||
|
|
||||||
NoticeTime(xE);
|
|
||||||
|
|
||||||
|
|
||||||
/* Fix for key repeating bug. */
|
/* Fix for key repeating bug. */
|
||||||
if (device->key != NULL && device->key->xkbInfo != NULL &&
|
if (device->key != NULL && device->key->xkbInfo != NULL &&
|
||||||
xE->u.u.type == KeyRelease)
|
xE->u.u.type == KeyRelease)
|
||||||
|
|
|
@ -325,7 +325,7 @@ extern _X_EXPORT WindowPtr GetCurrentRootWindow(DeviceIntPtr pDev);
|
||||||
extern _X_EXPORT WindowPtr GetSpriteWindow(DeviceIntPtr pDev);
|
extern _X_EXPORT WindowPtr GetSpriteWindow(DeviceIntPtr pDev);
|
||||||
|
|
||||||
|
|
||||||
extern _X_EXPORT void NoticeEventTime(xEventPtr /* xE */);
|
extern _X_EXPORT void NoticeEventTime(InternalEvent *ev);
|
||||||
|
|
||||||
extern _X_EXPORT void EnqueueEvent(
|
extern _X_EXPORT void EnqueueEvent(
|
||||||
xEventPtr /* xE */,
|
xEventPtr /* xE */,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user