input: remove nested union from InternalEvent.

There's no need for internal events to be a struct with a single nested
union, we might as well make the union itself the InternalEvent.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-05-20 17:02:50 +10:00
parent b12d302df8
commit 438a4eafa5
5 changed files with 47 additions and 50 deletions

View File

@ -123,7 +123,7 @@ RegisterOtherDevice(DeviceIntPtr device)
Bool
IsPointerEvent(InternalEvent* event)
{
switch(event->u.any.type)
switch(event->any.type)
{
case ET_ButtonPress:
case ET_ButtonRelease:
@ -953,7 +953,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
CHECKEVENT(ev);
if (ev->u.any.type == ET_Raw)
if (ev->any.type == ET_Raw)
{
ProcessRawEvent((RawDeviceEvent*)ev, device);
return;

View File

@ -69,7 +69,7 @@ static int eventToRawEvent(RawDeviceEvent *ev, xEvent **xi);
int
EventToCore(InternalEvent *event, xEvent *core)
{
switch(event->u.any.type)
switch(event->any.type)
{
case ET_Motion:
case ET_ButtonPress:
@ -117,7 +117,7 @@ EventToCore(InternalEvent *event, xEvent *core)
int
EventToXI(InternalEvent *ev, xEvent **xi, int *count)
{
switch (ev->u.any.type)
switch (ev->any.type)
{
case ET_Motion:
case ET_ButtonPress:
@ -134,7 +134,7 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count)
return Success;
}
ErrorF("[dix] EventToXI: Not implemented for %d \n", ev->u.any.type);
ErrorF("[dix] EventToXI: Not implemented for %d \n", ev->any.type);
return BadImplementation;
}
@ -153,7 +153,7 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count)
int
EventToXI2(InternalEvent *ev, xEvent **xi)
{
switch (ev->u.any.type)
switch (ev->any.type)
{
case ET_Motion:
case ET_ButtonPress:
@ -172,7 +172,7 @@ EventToXI2(InternalEvent *ev, xEvent **xi)
}
ErrorF("[dix] EventToXI2: Not implemented for %d \n", ev->u.any.type);
ErrorF("[dix] EventToXI2: Not implemented for %d \n", ev->any.type);
return BadImplementation;
}
@ -472,7 +472,7 @@ int
GetCoreType(InternalEvent *event)
{
int coretype = 0;
switch(event->u.any.type)
switch(event->any.type)
{
case ET_Motion: coretype = MotionNotify; break;
case ET_ButtonPress: coretype = ButtonPress; break;
@ -491,7 +491,7 @@ int
GetXIType(InternalEvent *event)
{
int xitype = 0;
switch(event->u.any.type)
switch(event->any.type)
{
case ET_Motion: xitype = DeviceMotionNotify; break;
case ET_ButtonPress: xitype = DeviceButtonPress; break;
@ -513,7 +513,7 @@ GetXI2Type(InternalEvent *event)
{
int xi2type = 0;
switch(event->u.any.type)
switch(event->any.type)
{
case ET_Motion: xi2type = XI_Motion; break;
case ET_ButtonPress: xi2type = XI_ButtonPress; break;

View File

@ -1075,18 +1075,18 @@ MonthChangedOrBadTime(InternalEvent *ev)
* different sources in sorted order, then it's possible for time to go
* backwards when it should not. Here we ensure a decent time.
*/
if ((currentTime.milliseconds - ev->u.any.time) > TIMESLOP)
if ((currentTime.milliseconds - ev->any.time) > TIMESLOP)
currentTime.months++;
else
ev->u.any.time = currentTime.milliseconds;
ev->any.time = currentTime.milliseconds;
}
static void
NoticeTime(InternalEvent *ev)
{
if (ev->u.any.time < currentTime.milliseconds)
if (ev->any.time < currentTime.milliseconds)
MonthChangedOrBadTime(ev);
currentTime.milliseconds = ev->u.any.time;
currentTime.milliseconds = ev->any.time;
lastDeviceEventTime = currentTime;
}
@ -1158,7 +1158,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
pSprite->hotPhys.y = event->root_y;
/* do motion compression, but not if from different devices */
if (tail &&
(tail->event->u.any.type == ET_Motion) &&
(tail->event->any.type == ET_Motion) &&
(tail->device == device) &&
(tail->pScreen == pSprite->hotPhys.pScreen))
{
@ -1212,10 +1212,10 @@ PlayReleasedEvents(void)
pDev = qe->device;
if (*syncEvents.pendtail == *prev)
syncEvents.pendtail = prev;
if (qe->event->u.any.type == ET_Motion)
if (qe->event->any.type == ET_Motion)
CheckVirtualMotion(pDev, qe, NullWindow);
syncEvents.time.months = qe->months;
syncEvents.time.milliseconds = qe->event->u.any.time;
syncEvents.time.milliseconds = qe->event->any.time;
#ifdef PANORAMIX
/* Translate back to the sprite screen since processInputProc
will translate from sprite screen to screen 0 upon reentry
@ -2391,7 +2391,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
if (rc != Success)
{
ErrorF("[dix] %s: XI conversion failed in DDE (%d, %d). Skipping delivery.\n",
dev->name, event->u.any.type, rc);
dev->name, event->any.type, rc);
goto unwind;
} else if (count > 0)
{
@ -2444,7 +2444,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
{
if (rc != BadMatch)
ErrorF("[dix] %s: Core conversion failed in DDE (%d, %d).\n",
dev->name, event->u.any.type, rc);
dev->name, event->any.type, rc);
goto unwind;
}
@ -3581,7 +3581,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
if (rc != Success)
{
ErrorF("[dix] %s: XI conversion failed in DFE (%d, %d). Skipping delivery.\n",
keybd->name, event->u.any.type, rc);
keybd->name, event->any.type, rc);
goto unwind;
} else if (count == 0) /* no XI/Core event for you */
return;
@ -3593,7 +3593,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
if (rc != Success)
{
ErrorF("[dix] %s: XI2 conversion failed in DFE (%d, %d). Skipping delivery.\n",
keybd->name, event->u.any.type, rc);
keybd->name, event->any.type, rc);
goto unwind;
} else if (xi2)
{
@ -3621,7 +3621,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
if (rc != Success)
{
ErrorF("[dix] %s: core conversion failed DFE (%d, %d). Skipping delivery.\n",
keybd->name, event->u.any.type, rc);
keybd->name, event->any.type, rc);
goto unwind;
}
@ -3706,7 +3706,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
if (rc != Success)
{
ErrorF("[dix] %s: XI2 conversion failed in DGE (%d, %d). Skipping delivery.\n",
thisDev->name, event->u.any.type, rc);
thisDev->name, event->any.type, rc);
goto unwind;
}
@ -3714,7 +3714,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
if (rc != Success)
{
ErrorF("[dix] %s: XI conversion failed in DGE (%d, %d). Skipping delivery.\n",
thisDev->name, event->u.any.type, rc);
thisDev->name, event->any.type, rc);
goto unwind;
} else if (count == 0) /* no XI/Core event for you */
goto unwind;
@ -3789,10 +3789,10 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
}
if (deliveries && (event->u.any.type == ET_Motion))
if (deliveries && (event->any.type == ET_Motion))
thisDev->valuator->motionHintWindow = grab->window;
}
if (deliveries && !deactivateGrab && event->u.any.type != ET_Motion)
if (deliveries && !deactivateGrab && event->any.type != ET_Motion)
{
switch (grabinfo->sync.state)
{

View File

@ -63,9 +63,9 @@ enum {
ET_Internal = 0xFF /* First byte */
} EventType;
#define CHECKEVENT(ev) if (ev && ((InternalEvent*)(ev))->u.any.header != 0xFF) \
#define CHECKEVENT(ev) if (ev && ((InternalEvent*)(ev))->any.header != 0xFF) \
FatalError("Wrong event type %d.\n", \
((InternalEvent*)(ev))->u.any.header);
((InternalEvent*)(ev))->any.header);
/**
* Used for ALL input device events internal in the server until
@ -204,9 +204,7 @@ typedef struct
* Event type used inside the X server for input event
* processing.
*/
typedef struct
{
union {
typedef union {
struct {
unsigned char header; /**< Always ET_Internal */
int type; /**< One of ET_* */
@ -219,7 +217,6 @@ typedef struct
DGAEvent dga;
#endif
RawDeviceEvent raw;
} u;
} InternalEvent;
#endif

View File

@ -165,7 +165,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
CHECKEVENT(e);
/* avoid merging events from different devices */
if (e->u.any.type == ET_Motion)
if (e->any.type == ET_Motion)
isMotion = pDev->id;
if (isMotion && isMotion == miEventQueue.lastMotion &&
@ -192,7 +192,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
stuck = 0;
}
evlen = e->u.any.length;
evlen = e->any.length;
evt = miEventQueue.events[oldtail].events;
if (evt->evlen < evlen)
{
@ -210,14 +210,14 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
memcpy(evt->event, e, evlen);
time = e->u.any.time;
time = e->any.time;
/* Make sure that event times don't go backwards - this
* is "unnecessary", but very useful. */
if (time < miEventQueue.lastEventTime &&
miEventQueue.lastEventTime - time < 10000)
e->u.any.time = miEventQueue.lastEventTime;
e->any.time = miEventQueue.lastEventTime;
miEventQueue.lastEventTime = ((InternalEvent*)evt->event)->u.any.time;
miEventQueue.lastEventTime = ((InternalEvent*)evt->event)->any.time;
miEventQueue.events[oldtail].pScreen = EnqueueScreen(pDev);
miEventQueue.events[oldtail].pDev = pDev;
@ -264,7 +264,7 @@ mieqSetHandler(int event, mieqHandler handler)
static void
ChangeDeviceID(DeviceIntPtr dev, InternalEvent* event)
{
switch(event->u.any.type)
switch(event->any.type)
{
case ET_Motion:
case ET_KeyPress:
@ -275,14 +275,14 @@ ChangeDeviceID(DeviceIntPtr dev, InternalEvent* event)
case ET_ProximityOut:
case ET_Hierarchy:
case ET_DeviceChanged:
event->u.device.deviceid = dev->id;
event->device.deviceid = dev->id;
break;
case ET_Raw:
event->u.raw.deviceid = dev->id;
event->raw.deviceid = dev->id;
break;
default:
ErrorF("[mi] Unknown event type (%d), cannot change id.\n",
event->u.any.type);
event->any.type);
}
}
@ -294,14 +294,14 @@ FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev,
CHECKEVENT(master);
/* Ensure chained button mappings, i.e. that the detail field is the
* value of the mapped button on the SD, not the physical button */
if (original->u.any.type == ET_ButtonPress ||
original->u.any.type == ET_ButtonRelease)
if (original->any.type == ET_ButtonPress ||
original->any.type == ET_ButtonRelease)
{
int btn = original->u.device.detail.button;
int btn = original->device.detail.button;
if (!sdev->button)
return; /* Should never happen */
master->u.device.detail.button = sdev->button->map[btn];
master->device.detail.button = sdev->button->map[btn];
}
}
@ -316,7 +316,7 @@ void
CopyGetMasterEvent(DeviceIntPtr mdev, DeviceIntPtr sdev,
InternalEvent* original, EventListPtr master)
{
int len = original->u.any.length;
int len = original->any.length;
InternalEvent *mevent;
CHECKEVENT(original);
@ -349,13 +349,13 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
CHECKEVENT(event);
/* Custom event handler */
handler = miEventQueue.handlers[event->u.any.type];
handler = miEventQueue.handlers[event->any.type];
if (screen && screen != DequeueScreen(dev) && !handler) {
/* Assumption - screen switching can only occur on motion events. */
DequeueScreen(dev) = screen;
x = event->u.device.root_x;
y = event->u.device.root_y;
x = event->device.root_x;
y = event->device.root_y;
NewCurrentScreen (dev, DequeueScreen(dev), x, y);
}
else {
@ -441,7 +441,7 @@ mieqProcessInputEvents(void)
mieqProcessDeviceEvent(dev, event, screen);
/* Update the sprite now. Next event may be from different device. */
if (event->u.any.type == ET_Motion && master)
if (event->any.type == ET_Motion && master)
miPointerUpdateSprite(dev);
#ifdef XQUARTZ