[PATCH 3/4] input: replace EventListPtr with InternalEvent array
Peter Hutterer
peter.hutterer at who-t.net
Thu Apr 14 19:47:24 PDT 2011
EventListPtr is a relic from pre-1.6, when we had protocol events in the
event queue and thus events of varying size.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Xext/xtest.c | 5 +-
dix/devices.c | 6 +-
dix/getevents.c | 101 +++++++++++++++------------------------
hw/dmx/input/dmxevents.c | 8 ++--
hw/kdrive/src/kinput.c | 2 +-
hw/xfree86/common/xf86Priv.h | 2 +-
hw/xfree86/common/xf86Xinput.c | 2 +-
hw/xnest/Events.c | 2 +-
hw/xnest/Init.c | 2 +-
hw/xquartz/darwinEvents.c | 2 +-
hw/xwin/winkeybd.c | 2 +-
hw/xwin/winmouse.c | 4 +-
include/input.h | 36 +++++---------
mi/mieq.c | 47 ++++---------------
mi/mipointer.c | 5 +-
xkb/xkbActions.c | 4 +-
16 files changed, 85 insertions(+), 145 deletions(-)
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 18e1ef7..daa6430 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -52,6 +52,7 @@
#include "mipointer.h"
#include "xserver-properties.h"
#include "exevents.h"
+#include "eventstr.h"
#include "inpututils.h"
#include "modinit.h"
@@ -61,7 +62,7 @@ extern int DeviceValuator;
/* XTest events are sent during request processing and may be interruped by
* a SIGIO. We need a separate event list to avoid events overwriting each
* other's memory */
-static EventListPtr xtest_evlist;
+static InternalEvent* xtest_evlist;
/**
* xtestpointer
@@ -428,7 +429,7 @@ ProcXTestFakeInput(ClientPtr client)
}
for (i = 0; i < nevents; i++)
- mieqProcessDeviceEvent(dev, (InternalEvent*)(xtest_evlist+i)->event, NULL);
+ mieqProcessDeviceEvent(dev, &xtest_evlist[i], NULL);
if (need_ptr_update)
miPointerUpdateSprite(dev);
diff --git a/dix/devices.c b/dix/devices.c
index 8acb88d..47662d7 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2359,7 +2359,7 @@ RecalculateMasterButtons(DeviceIntPtr slave)
static void
ReleaseButtonsAndKeys(DeviceIntPtr dev)
{
- EventListPtr eventlist = InitEventList(GetMaximumEventsNum());
+ InternalEvent* eventlist = InitEventList(GetMaximumEventsNum());
ButtonClassPtr b = dev->button;
KeyClassPtr k = dev->key;
int i, j, nevents;
@@ -2374,7 +2374,7 @@ ReleaseButtonsAndKeys(DeviceIntPtr dev)
{
nevents = GetPointerEvents(eventlist, dev, ButtonRelease, i, 0, NULL);
for (j = 0; j < nevents; j++)
- mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+j)->event, NULL);
+ mieqProcessDeviceEvent(dev, &eventlist[j], NULL);
}
}
@@ -2385,7 +2385,7 @@ ReleaseButtonsAndKeys(DeviceIntPtr dev)
{
nevents = GetKeyboardEvents(eventlist, dev, KeyRelease, i, NULL);
for (j = 0; j < nevents; j++)
- mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+j)->event, NULL);
+ mieqProcessDeviceEvent(dev, &eventlist[j], NULL);
}
}
diff --git a/dix/getevents.c b/dix/getevents.c
index 5953bc1..d99b958 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -69,15 +69,15 @@
/* Number of motion history events to store. */
#define MOTION_HISTORY_SIZE 256
-/* InputEventList is the container list for all input events generated by the
+/* InputEventList is the storage for input events generated by the
* DDX. The DDX is expected to call GetEventList() and then pass the list into
* Get{Pointer|Keyboard}Events.
*/
-EventListPtr InputEventList = NULL;
+InternalEvent* InputEventList = NULL;
int InputEventListLen = 0;
int
-GetEventList(EventListPtr* list)
+GetEventList(InternalEvent** list)
{
*list = InputEventList;
return InputEventListLen;
@@ -225,7 +225,7 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask)
}
void
-CreateClassesChangedEvent(EventList* event,
+CreateClassesChangedEvent(InternalEvent* event,
DeviceIntPtr master,
DeviceIntPtr slave,
int type)
@@ -234,7 +234,7 @@ CreateClassesChangedEvent(EventList* event,
DeviceChangedEvent *dce;
CARD32 ms = GetTimeInMillis();
- dce = (DeviceChangedEvent*)event->event;
+ dce = &event->changed_event;
memset(dce, 0, sizeof(DeviceChangedEvent));
dce->deviceid = slave->id;
dce->masterid = master->id;
@@ -678,15 +678,15 @@ clipValuators(DeviceIntPtr pDev, ValuatorMask *mask)
* is done in the event processing).
* Pull in the coordinates from the MD if necessary.
*
- * @param events Pointer to a pre-allocated event list.
+ * @param events Pointer to a pre-allocated event array.
* @param dev The slave device that generated an event.
* @param type Either DEVCHANGE_POINTER_EVENT and/or DEVCHANGE_KEYBOARD_EVENT
* @param num_events The current number of events, returns the number of
* events if a DCCE was generated.
* @return The updated @events pointer.
*/
-EventListPtr
-UpdateFromMaster(EventListPtr events, DeviceIntPtr dev, int type, int *num_events)
+InternalEvent*
+UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_events)
{
DeviceIntPtr master;
@@ -927,12 +927,11 @@ updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms)
}
static void
-queueEventList(DeviceIntPtr device, EventList *events, int nevents)
+queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents)
{
int i;
-
for (i = 0; i < nevents; i++)
- mieqEnqueue(device, (InternalEvent*)((events + i)->event));
+ mieqEnqueue(device, &events[i]);
}
/**
@@ -950,7 +949,7 @@ queueEventList(DeviceIntPtr device, EventList *events, int nevents)
*
*/
void
-QueueKeyboardEvents(EventList *events, DeviceIntPtr device, int type,
+QueueKeyboardEvents(InternalEvent *events, DeviceIntPtr device, int type,
int keycode, const ValuatorMask *mask)
{
int nevents;
@@ -963,12 +962,13 @@ QueueKeyboardEvents(EventList *events, DeviceIntPtr device, int type,
* Returns a set of InternalEvents for KeyPress/KeyRelease, optionally
* also with valuator events.
*
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
- * place via GetMaximumEventsNum(), and for freeing it.
+ * The DDX is responsible for allocating the event list in the first
+ * place via InitEventList(), and for freeing it.
+ *
+ * @return the number of events written into events.
*/
int
-GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
+GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
int key_code, const ValuatorMask *mask_in) {
int num_events = 0;
CARD32 ms = 0;
@@ -1001,7 +1001,7 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
ms = GetTimeInMillis();
- raw = (RawDeviceEvent*)events->event;
+ raw = &events->raw_event;
events++;
num_events++;
@@ -1014,7 +1014,7 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
set_raw_valuators(raw, &mask, raw->valuators.data);
- event = (DeviceEvent*) events->event;
+ event = &events->device_event;
init_event(pDev, event, ms);
event->detail.key = key_code;
@@ -1035,37 +1035,16 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
}
/**
- * Initialize an event list and fill with 32 byte sized events.
+ * Initialize an event array large enough for num_events arrays.
* This event list is to be passed into GetPointerEvents() and
* GetKeyboardEvents().
*
* @param num_events Number of elements in list.
*/
-EventListPtr
+InternalEvent*
InitEventList(int num_events)
{
- EventListPtr events;
- int i;
-
- events = (EventListPtr)calloc(num_events, sizeof(EventList));
- if (!events)
- return NULL;
-
- for (i = 0; i < num_events; i++)
- {
- events[i].evlen = sizeof(InternalEvent);
- events[i].event = calloc(1, sizeof(InternalEvent));
- if (!events[i].event)
- {
- /* rollback */
- while(i--)
- free(events[i].event);
- free(events);
- events = NULL;
- break;
- }
- }
-
+ InternalEvent *events = calloc(num_events, sizeof(InternalEvent));
return events;
}
@@ -1076,12 +1055,8 @@ InitEventList(int num_events)
* @param num_events Number of elements in list.
*/
void
-FreeEventList(EventListPtr list, int num_events)
+FreeEventList(InternalEvent *list, int num_events)
{
- if (!list)
- return;
- while(num_events--)
- free(list[num_events].event);
free(list);
}
@@ -1111,7 +1086,7 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
*
* FIXME: don't require the event list to be passed in.
*
- * @param events Event list used as temporary storage
+ * @param events Set of events list used as temporary storage
* @param device The device to generate the event for
* @param type Event type, one of ButtonPress, ButtonRelease, MotionNotify
* @param buttons Button number of the buttons modified. Must be 0 for
@@ -1120,7 +1095,7 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
* @param mask Valuator mask for valuators present for this event.
*/
void
-QueuePointerEvents(EventList *events, DeviceIntPtr device, int type,
+QueuePointerEvents(InternalEvent *events, DeviceIntPtr device, int type,
int buttons, int flags, const ValuatorMask *mask)
{
int nevents;
@@ -1130,11 +1105,10 @@ QueuePointerEvents(EventList *events, DeviceIntPtr device, int type,
}
/**
- * Generate a series of InternalEvents (filled into the EventList)
- * representing pointer motion, or button presses.
+ * Generate a series of InternalEvents representing pointer motion, or
+ * button presses.
*
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
+ * The DDX is responsible for allocating the events in the first
* place via InitEventList() and GetMaximumEventsNum(), and for freeing it.
*
* In the generated events rootX/Y will be in absolute screen coords and
@@ -1144,9 +1118,11 @@ QueuePointerEvents(EventList *events, DeviceIntPtr device, int type,
* last.valuators[x] of the master device is in absolute screen coords.
*
* master->last.valuators[x] for x > 2 is undefined.
+ *
+ * @return the number of events written into events.
*/
int
-GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
+GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons,
int flags, const ValuatorMask *mask_in) {
int num_events = 1;
CARD32 ms;
@@ -1184,7 +1160,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
- raw = (RawDeviceEvent*)events->event;
+ raw = &events->raw_event;
events++;
num_events++;
@@ -1244,7 +1220,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
clipValuators(pDev, &mask);
- event = (DeviceEvent*) events->event;
+ event = &events->device_event;
init_event(pDev, event, ms);
if (type == MotionNotify) {
@@ -1287,7 +1263,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
*
*/
void
-QueueProximityEvents(EventList *events, DeviceIntPtr device, int type,
+QueueProximityEvents(InternalEvent *events, DeviceIntPtr device, int type,
const ValuatorMask *mask)
{
int nevents;
@@ -1300,12 +1276,13 @@ QueueProximityEvents(EventList *events, DeviceIntPtr device, int type,
* Generate ProximityIn/ProximityOut InternalEvents, accompanied by
* valuators.
*
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
- * place via GetMaximumEventsNum(), and for freeing it.
+ * The DDX is responsible for allocating the events in the first place via
+ * InitEventList(), and for freeing it.
+ *
+ * @return the number of events written into events.
*/
int
-GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask_in)
+GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask_in)
{
int num_events = 1, i;
DeviceEvent *event;
@@ -1337,7 +1314,7 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const Valuato
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
- event = (DeviceEvent *) events->event;
+ event = &events->device_event;
init_event(pDev, event, GetTimeInMillis());
event->type = (type == ProximityIn) ? ET_ProximityIn : ET_ProximityOut;
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 3f9035c..8aa1b80 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -177,7 +177,7 @@ static void enqueueMotion(DevicePtr pDev, int x, int y)
GETDMXLOCALFROMPDEV;
DeviceIntPtr p = dmxLocal->pDevice;
int valuators[3];
- EventListPtr events;
+ InternalEvent* events;
int detail = 0; /* XXX should this be mask of pressed buttons? */
ValuatorMask mask;
valuators[0] = x;
@@ -290,7 +290,7 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
int thisX = 0;
int thisY = 0;
int count;
- EventListPtr events;
+ InternalEvent* events;
ValuatorMask mask;
memset(xE, 0, sizeof(xE));
@@ -389,7 +389,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
XDeviceMotionEvent *me = (XDeviceMotionEvent *)e;
DeviceIntPtr pDevice = dmxLocal->pDevice;
int valuators[MAX_VALUATORS];
- EventListPtr events;
+ InternalEvent* events;
ValuatorMask mask;
if (!e)
@@ -652,7 +652,7 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
xEvent xE;
DeviceIntPtr p = dmxLocal->pDevice;
int valuators[3];
- EventListPtr events;
+ InternalEvent* events;
ValuatorMask mask;
DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 521542c..62e8f78 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -66,7 +66,7 @@ static struct KdConfigDevice *kdConfigPointers = NULL;
static KdKeyboardDriver *kdKeyboardDrivers = NULL;
static KdPointerDriver *kdPointerDrivers = NULL;
-static EventListPtr kdEvents = NULL;
+static InternalEvent* kdEvents = NULL;
static Bool kdInputEnabled;
static Bool kdOffScreen;
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 7137a53..015e12c 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -149,7 +149,7 @@ extern _X_EXPORT int xf86SetLogVerbosity(int verb);
extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
/* xf86Xinput.c */
-extern _X_EXPORT EventList *xf86Events;
+extern _X_EXPORT InternalEvent *xf86Events;
#endif /* _NO_XF86_PROTOTYPES */
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index a6c261c..ed0b4c8 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -99,7 +99,7 @@
return; \
}
-EventListPtr xf86Events = NULL;
+InternalEvent* xf86Events = NULL;
static int
xf86InputDevicePostInit(DeviceIntPtr dev);
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index 574e4e4..bbd70bf 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -43,7 +43,7 @@ is" without express or implied warranty.
CARD32 lastEventTime = 0;
-extern EventList *xnestEvents;
+extern InternalEvent *xnestEvents;
void
ProcessInputEvents(void)
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index 8a90cc6..f8637f2 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -45,7 +45,7 @@ is" without express or implied warranty.
Bool xnestDoFullGeneration = True;
-EventList *xnestEvents = NULL;
+InternalEvent *xnestEvents = NULL;
void
InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index f20e37b..54bb583 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -87,7 +87,7 @@ static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER;
static pthread_t fd_add_tid = NULL;
-static EventListPtr darwinEvents = NULL;
+static InternalEvent* darwinEvents = NULL;
static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER;
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index cf0dea2..8b6be02 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -472,7 +472,7 @@ winKeybdReleaseKeys (void)
void
winSendKeyEvent (DWORD dwKey, Bool fDown)
{
- EventListPtr events;
+ InternalEvent* events;
/*
* When alt-tabing between screens we can get phantom key up messages
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index 0e36687..aaa4d4b 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -234,7 +234,7 @@ winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
void
winMouseButtonsSendEvent (int iEventType, int iButton)
{
- EventListPtr events;
+ InternalEvent* events;
ValuatorMask mask;
if (g_winMouseButtonMap)
@@ -365,7 +365,7 @@ void winEnqueueMotion(int x, int y)
{
int valuators[2];
ValuatorMask mask;
- EventListPtr events;
+ InternalEvent* events;
miPointerSetPosition(g_pwinPointer, POINTER_RELATIVE, &x, &y);
valuators[0] = x;
diff --git a/include/input.h b/include/input.h
index ac4c7b9..d80b4bb 100644
--- a/include/input.h
+++ b/include/input.h
@@ -109,18 +109,8 @@ typedef union _GrabMask GrabMask;
typedef struct _ValuatorMask ValuatorMask;
-typedef struct _EventList {
- xEvent* event;
- int evlen; /* length of allocated memory for event in bytes. This is not
- the actual length of the event. The event's actual length is
- 32 for standard events or 32 +
- ((xGenericEvent*)event)->length * 4 for GenericEvents.
- For events in the EQ, the length is
- ((InternalEvent*)event)->u.any.length */
-} EventList, *EventListPtr;
-
/* The DIX stores incoming input events in this list */
-extern EventListPtr InputEventList;
+extern InternalEvent* InputEventList;
extern int InputEventListLen;
typedef int (*DeviceProc)(
@@ -433,22 +423,22 @@ extern _X_EXPORT void CloseInput(void);
extern _X_EXPORT int GetMaximumEventsNum(void);
-extern _X_EXPORT int GetEventList(EventListPtr* list);
-extern _X_EXPORT EventListPtr InitEventList(int num_events);
-extern _X_EXPORT void FreeEventList(EventListPtr list, int num_events);
+extern _X_EXPORT int GetEventList(InternalEvent** list);
+extern _X_EXPORT InternalEvent *InitEventList(int num_events);
+extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events);
-extern void CreateClassesChangedEvent(EventListPtr event,
+extern void CreateClassesChangedEvent(InternalEvent *event,
DeviceIntPtr master,
DeviceIntPtr slave,
int type);
-extern EventListPtr UpdateFromMaster(
- EventListPtr events,
+extern InternalEvent * UpdateFromMaster(
+ InternalEvent *events,
DeviceIntPtr pDev,
int type,
int *num_events);
extern _X_EXPORT int GetPointerEvents(
- EventListPtr events,
+ InternalEvent *events,
DeviceIntPtr pDev,
int type,
int buttons,
@@ -456,7 +446,7 @@ extern _X_EXPORT int GetPointerEvents(
const ValuatorMask *mask);
extern _X_EXPORT void QueuePointerEvents(
- EventListPtr events,
+ InternalEvent *events,
DeviceIntPtr pDev,
int type,
int buttons,
@@ -464,27 +454,27 @@ extern _X_EXPORT void QueuePointerEvents(
const ValuatorMask *mask);
extern _X_EXPORT int GetKeyboardEvents(
- EventListPtr events,
+ InternalEvent *events,
DeviceIntPtr pDev,
int type,
int key_code,
const ValuatorMask *mask);
extern _X_EXPORT void QueueKeyboardEvents(
- EventListPtr events,
+ InternalEvent *events,
DeviceIntPtr pDev,
int type,
int key_code,
const ValuatorMask *mask);
extern int GetProximityEvents(
- EventListPtr events,
+ InternalEvent *events,
DeviceIntPtr pDev,
int type,
const ValuatorMask *mask);
extern void QueueProximityEvents(
- EventListPtr events,
+ InternalEvent *events,
DeviceIntPtr pDev,
int type,
const ValuatorMask *mask);
diff --git a/mi/mieq.c b/mi/mieq.c
index 08a0c87..a0f383e 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -64,7 +64,7 @@ in this Software without prior written authorization from The Open Group.
#define DequeueScreen(dev) dev->spriteInfo->sprite->pDequeueScreen
typedef struct _Event {
- EventListPtr events;
+ InternalEvent* events;
ScreenPtr pScreen;
DeviceIntPtr pDev; /* device this event _originated_ from */
} EventRec, *EventPtr;
@@ -111,7 +111,7 @@ mieqInit(void)
for (i = 0; i < QUEUE_SIZE; i++)
{
if (miEventQueue.events[i].events == NULL) {
- EventListPtr evlist = InitEventList(1);
+ InternalEvent* evlist = InitEventList(1);
if (!evlist)
FatalError("Could not allocate event queue.\n");
miEventQueue.events[i].events = evlist;
@@ -146,7 +146,7 @@ void
mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
{
unsigned int oldtail = miEventQueue.tail;
- EventListPtr evt;
+ InternalEvent* evt;
int isMotion = 0;
int evlen;
Time time;
@@ -188,21 +188,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
evlen = e->any.length;
evt = miEventQueue.events[oldtail].events;
- if (evt->evlen < evlen)
- {
- evt->evlen = evlen;
- evt->event = realloc(evt->event, evt->evlen);
- if (!evt->event)
- {
- ErrorF("[mi] Running out of memory. Tossing event.\n");
-#ifdef XQUARTZ
- pthread_mutex_unlock(&miEventQueueMutex);
-#endif
- return;
- }
- }
-
- memcpy(evt->event, e, evlen);
+ memcpy(evt, e, evlen);
time = e->any.time;
/* Make sure that event times don't go backwards - this
@@ -211,7 +197,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
miEventQueue.lastEventTime - time < 10000)
e->any.time = miEventQueue.lastEventTime;
- miEventQueue.lastEventTime = ((InternalEvent*)evt->event)->any.time;
+ miEventQueue.lastEventTime = evt->any.time;
miEventQueue.events[oldtail].pScreen = pDev ? EnqueueScreen(pDev) : NULL;
miEventQueue.events[oldtail].pDev = pDev;
@@ -431,10 +417,8 @@ void
mieqProcessInputEvents(void)
{
EventRec *e = NULL;
- int evlen;
ScreenPtr screen;
- static InternalEvent *event = NULL;
- static size_t event_size = 0;
+ static InternalEvent event;
DeviceIntPtr dev = NULL,
master = NULL;
@@ -445,20 +429,7 @@ mieqProcessInputEvents(void)
while (miEventQueue.head != miEventQueue.tail) {
e = &miEventQueue.events[miEventQueue.head];
- evlen = e->events->evlen;
- if(evlen > event_size)
- {
- event = realloc(event, evlen);
- event_size = evlen;
- }
-
-
- if (!event)
- FatalError("[mi] No memory left for event processing.\n");
-
- memcpy(event, e->events->event, evlen);
-
-
+ event = *e->events;
dev = e->pDev;
screen = e->pScreen;
@@ -480,10 +451,10 @@ mieqProcessInputEvents(void)
DPMSSet(serverClient, DPMSModeOn);
#endif
- mieqProcessDeviceEvent(dev, event, screen);
+ mieqProcessDeviceEvent(dev, &event, screen);
/* Update the sprite now. Next event may be from different device. */
- if (event->any.type == ET_Motion && master)
+ if (event.any.type == ET_Motion && master)
miPointerUpdateSprite(dev);
#ifdef XQUARTZ
diff --git a/mi/mipointer.c b/mi/mipointer.c
index db24381..322be9e 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -63,6 +63,7 @@ in this Software without prior written authorization from The Open Group.
# include "dixstruct.h"
# include "inputstr.h"
# include "inpututils.h"
+# include "eventstr.h"
DevPrivateKeyRec miPointerScreenKeyRec;
@@ -99,7 +100,7 @@ static void miPointerDeviceCleanup(DeviceIntPtr pDev,
ScreenPtr pScreen);
static void miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
-static EventList* events; /* for WarpPointer MotionNotifies */
+static InternalEvent* events; /* for WarpPointer MotionNotifies */
Bool
miPointerInitialize (ScreenPtr pScreen,
@@ -689,7 +690,7 @@ miPointerMove (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
darwinEvents_lock();
#endif
for (i = 0; i < nevents; i++)
- mieqEnqueue(pDev, (InternalEvent*)events[i].event);
+ mieqEnqueue(pDev, &events[i]);
#ifdef XQUARTZ
darwinEvents_unlock();
#endif
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index c4336d7..4b5405a 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1351,7 +1351,7 @@ static void
InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, ValuatorMask *mask)
{
ScreenPtr pScreen;
- EventListPtr events;
+ InternalEvent* events;
int nevents, i;
DeviceIntPtr ptr, mpointer, lastSlave = NULL;
Bool saveWait;
@@ -1377,7 +1377,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, Valuat
OsReleaseSignals();
for (i = 0; i < nevents; i++)
- mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
+ mieqProcessDeviceEvent(ptr, &events[i], NULL);
FreeEventList(events, GetMaximumEventsNum());
--
1.7.4.2
More information about the xorg-devel
mailing list