[PATCH 10/11] dix: replace CORE_EVENT and XI2_EVENT macros with inline functions.
Peter Hutterer
peter.hutterer at who-t.net
Tue May 10 21:49:49 PDT 2011
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
dix/events.c | 38 +++++++++++++++++++++++---------------
1 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/dix/events.c b/dix/events.c
index 3f7cc6f..7885e86 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -176,12 +176,20 @@ typedef const char *string;
#define AllEventMasks (LastEventMask|(LastEventMask-1))
-#define CORE_EVENT(event) \
- (!((event)->u.u.type & EXTENSION_EVENT_BASE) && \
- (event)->u.u.type != GenericEvent)
-#define XI2_EVENT(event) \
- (((event)->u.u.type == GenericEvent) && \
- ((xGenericEvent*)(event))->extension == IReqCode)
+static inline BOOL
+is_core_event(const xEvent *event)
+{
+ return !(event->u.u.type & EXTENSION_EVENT_BASE) &&
+ event->u.u.type != GenericEvent;
+}
+
+static inline BOOL
+is_xi2_event(const xEvent *event)
+{
+ return (event->u.u.type == GenericEvent) &&
+ ((xGenericEvent*)event)->extension == IReqCode;
+}
+
/**
* Used to indicate a implicit passive grab created by a ButtonPress event.
@@ -416,7 +424,7 @@ GetEventFilter(DeviceIntPtr dev, xEvent *event)
{
if (event->u.u.type != GenericEvent)
return filters[dev ? dev->id : 0][event->u.u.type];
- else if (XI2_EVENT(event))
+ else if (is_xi2_event(event))
return (1 << (((xXIDeviceEvent*)event)->evtype % 8));
ErrorF("[dix] Unknown device type %d. No filter\n", event->u.u.type);
return 0;
@@ -432,7 +440,7 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
int filter;
int evtype;
- if (!inputMasks || !XI2_EVENT(ev))
+ if (!inputMasks || !is_xi2_event(ev))
return 0;
evtype = ((xGenericEvent*)ev)->evtype;
@@ -447,13 +455,13 @@ Mask
GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients* other)
{
/* XI2 filters are only ever 8 bit, so let's return a 8 bit mask */
- if (XI2_EVENT(event))
+ if (is_xi2_event(event))
{
int byte = ((xGenericEvent*)event)->evtype / 8;
return (other->xi2mask[dev->id][byte] |
other->xi2mask[XIAllDevices][byte] |
(IsMaster(dev)? other->xi2mask[XIAllMasterDevices][byte] : 0));
- } else if (CORE_EVENT(event))
+ } else if (is_core_event(event))
return other->mask[XIAllDevices];
else
return other->mask[dev->id];
@@ -1994,9 +2002,9 @@ DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events,
enum EventDeliveryState rc = EVENT_SKIP;
InputClients *other;
- if (CORE_EVENT(events))
+ if (is_core_event(events))
other = (InputClients *)wOtherClients(win);
- else if (XI2_EVENT(events))
+ else if (is_xi2_event(events))
{
OtherInputMasks *inputMasks = wOtherInputMasks(win);
/* Has any client selected for the event? */
@@ -2097,7 +2105,7 @@ IsButtonPressEvent(xEvent *pEvents)
{
int type = pEvents->u.u.type;
- if (((XI2_EVENT(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)) ||
+ if (((is_xi2_event(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)) ||
type == DeviceButtonPress || type == ButtonPress)
return TRUE;
else
@@ -2135,7 +2143,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
int type = pEvents->u.u.type;
/* Deliver to window owner */
- if ((filter == CantBeFiltered) || CORE_EVENT(pEvents))
+ if ((filter == CantBeFiltered) || is_core_event(pEvents))
{
enum EventDeliveryState rc;
@@ -2328,7 +2336,7 @@ FixUpEventFromWindow(
if (calcChild)
child = FindChildForEvent(pSprite, pWin);
- if (XI2_EVENT(xE))
+ if (is_xi2_event(xE))
{
xXIDeviceEvent* event = (xXIDeviceEvent*)xE;
--
1.7.4.4
More information about the xorg-devel
mailing list