Move input event list initialisation and storage from DDX to DIX.
Rather than letting the DDX allocate the events, allocate them once in the DIX and just pass it around when needed. DDX should call GetEventList() to obtain this list and then pass it into Get{Pointer|Keyboard}Events.
This commit is contained in:
parent
09a8fc5c7a
commit
3fe64d8d27
|
@ -5711,6 +5711,10 @@ InitEvents(void)
|
|||
DontPropagateMasks[i] = 0;
|
||||
DontPropagateRefCnts[i] = 0;
|
||||
}
|
||||
|
||||
InputEventList = InitEventList(GetMaximumEventsNum());
|
||||
if (!InputEventList)
|
||||
FatalError("[dix] Failed to allocate input event list.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,6 +70,17 @@ extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
|
|||
/* Number of motion history events to store. */
|
||||
#define MOTION_HISTORY_SIZE 256
|
||||
|
||||
/* InputEventList is the container list for all 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;
|
||||
|
||||
_X_EXPORT EventListPtr
|
||||
GetEventList()
|
||||
{
|
||||
return InputEventList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick some arbitrary size for Xi motion history.
|
||||
|
|
|
@ -65,7 +65,7 @@ static struct KdConfigDevice *kdConfigPointers = NULL;
|
|||
static KdKeyboardDriver *kdKeyboardDrivers = NULL;
|
||||
static KdPointerDriver *kdPointerDrivers = NULL;
|
||||
|
||||
static xEvent *kdEvents = NULL;
|
||||
static EventListPtr *kdEvents = NULL;
|
||||
|
||||
static Bool kdInputEnabled;
|
||||
static Bool kdOffScreen;
|
||||
|
@ -1391,11 +1391,6 @@ KdInitInput (void)
|
|||
ErrorF("Failed to add keyboard!\n");
|
||||
}
|
||||
|
||||
if (!kdEvents)
|
||||
kdEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
|
||||
if (!kdEvents)
|
||||
FatalError("Couldn't allocate event buffer\n");
|
||||
|
||||
mieqInit();
|
||||
}
|
||||
|
||||
|
@ -1984,6 +1979,7 @@ KdReleaseAllKeys (void)
|
|||
key++) {
|
||||
if (IsKeyDown(ki, key)) {
|
||||
KdHandleKeyboardEvent(ki, KeyRelease, key);
|
||||
kdEvents = GetEventList();
|
||||
nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key);
|
||||
for (i = 0; i < nEvents; i++)
|
||||
KdQueueEvent (ki->dixdev, kdEvents + i);
|
||||
|
@ -2048,9 +2044,10 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
|
|||
KdHandleKeyboardEvent(ki, type, key_code);
|
||||
}
|
||||
|
||||
kdEvents = GetEventList();
|
||||
nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code);
|
||||
for (i = 0; i < nEvents; i++)
|
||||
KdQueueEvent(ki->dixdev, kdEvents + i);
|
||||
KdQueueEvent(ki->dixdev, kdEvents);
|
||||
}
|
||||
else {
|
||||
ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
|
||||
|
@ -2148,8 +2145,9 @@ _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
|
|||
if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
|
||||
return;
|
||||
|
||||
nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, 0, 3,
|
||||
valuators);
|
||||
kdEvents = GetEventList();
|
||||
nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel,
|
||||
0, 3, valuators);
|
||||
for (i = 0; i < nEvents; i++)
|
||||
KdQueueEvent(pi->dixdev, kdEvents + i);
|
||||
}
|
||||
|
|
|
@ -569,11 +569,7 @@ xf86PostMotionEventP(DeviceIntPtr device,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = InitEventList(GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
|
||||
xf86Events = GetEventList();
|
||||
nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0,
|
||||
flags, first_valuator, num_valuators,
|
||||
valuators);
|
||||
|
@ -605,11 +601,7 @@ xf86PostProximityEvent(DeviceIntPtr device,
|
|||
valuators[i] = va_arg(var, int);
|
||||
va_end(var);
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = InitEventList(GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
|
||||
xf86Events = GetEventList();
|
||||
nevents = GetProximityEvents(xf86Events, device,
|
||||
is_in ? ProximityIn : ProximityOut,
|
||||
first_valuator, num_valuators, valuators);
|
||||
|
@ -647,11 +639,7 @@ xf86PostButtonEvent(DeviceIntPtr device,
|
|||
valuators[i] = va_arg(var, int);
|
||||
va_end(var);
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = InitEventList(GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
|
||||
xf86Events = GetEventList();
|
||||
nevents = GetPointerEvents(xf86Events, device,
|
||||
is_down ? ButtonPress : ButtonRelease, button,
|
||||
(is_absolute) ? POINTER_ABSOLUTE : POINTER_RELATIVE,
|
||||
|
@ -680,11 +668,6 @@ xf86PostKeyEvent(DeviceIntPtr device,
|
|||
"badly south after this message, then xf86PostKeyEvent is "
|
||||
"broken.\n");
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = InitEventList(GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
|
||||
if (is_absolute) {
|
||||
valuators = xcalloc(sizeof(int), num_valuators);
|
||||
va_start(var, num_valuators);
|
||||
|
@ -692,6 +675,7 @@ xf86PostKeyEvent(DeviceIntPtr device,
|
|||
valuators[i] = va_arg(var, int);
|
||||
va_end(var);
|
||||
|
||||
xf86Events = GetEventList();
|
||||
nevents = GetKeyboardValuatorEvents(xf86Events, device,
|
||||
is_down ? KeyPress : KeyRelease,
|
||||
key_code, first_valuator,
|
||||
|
@ -726,11 +710,7 @@ xf86PostKeyboardEvent(DeviceIntPtr device,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!xf86Events)
|
||||
xf86Events = InitEventList(GetMaximumEventsNum());
|
||||
if (!xf86Events)
|
||||
FatalError("Couldn't allocate event store\n");
|
||||
|
||||
xf86Events = GetEventList();
|
||||
nevents = GetKeyboardEvents(xf86Events, device,
|
||||
is_down ? KeyPress : KeyRelease, key_code);
|
||||
|
||||
|
|
|
@ -94,6 +94,8 @@ typedef struct _EventList {
|
|||
((xGenericEvent*)event)->length * 4 for GenericEvents */
|
||||
} EventList, *EventListPtr;
|
||||
|
||||
/* The DIX stores incoming input events in this list */
|
||||
extern EventListPtr InputEventList;
|
||||
|
||||
typedef int (*DeviceProc)(
|
||||
DeviceIntPtr /*device*/,
|
||||
|
@ -396,6 +398,7 @@ extern void InitInput(
|
|||
|
||||
extern int GetMaximumEventsNum(void);
|
||||
|
||||
extern EventListPtr GetEventList();
|
||||
extern EventListPtr InitEventList(int num_events);
|
||||
extern void FreeEventList(EventListPtr list, int num_events);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user