summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2008-02-03 09:56:19 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-02-18 18:46:01 +1030
commit3fe64d8d271aea0863bf01b0376f3eceec0c90b5 (patch)
tree8953d8bbd54c777d5439724fcc6b073f7e9a610c
parent09a8fc5c7a79ca22fc23224bb544f2e709681f3f (diff)
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.
-rw-r--r--dix/events.c4
-rw-r--r--dix/getevents.c11
-rw-r--r--hw/kdrive/src/kinput.c16
-rw-r--r--hw/xfree86/common/xf86Xinput.c30
-rw-r--r--include/input.h3
5 files changed, 30 insertions, 34 deletions
diff --git a/dix/events.c b/dix/events.c
index 2928554ff..1155178b1 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -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");
}
/**
diff --git a/dix/getevents.c b/dix/getevents.c
index 840fa2b89..2a9df0f40 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -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.
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 5b1dc5cdc..78b44199e 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -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);
}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index f99e540a4..a928b4cd3 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -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);
diff --git a/include/input.h b/include/input.h
index 18636766b..fb24e7637 100644
--- a/include/input.h
+++ b/include/input.h
@@ -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);