summaryrefslogtreecommitdiff
path: root/hw/xfree86/common/xf86Xinput.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2008-03-04 18:11:10 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-03-04 18:11:10 +1030
commit4f2cd0ed96d3b10c78774c721c2ffbfb0556dddd (patch)
tree9f477ddd4af2162152057bded1426102b475e67c /hw/xfree86/common/xf86Xinput.c
parent23ae68a4c74a2ec90b4130c37b0d0aec3f4082ce (diff)
parent453661a9e193a511cf5e54e6d330454163817316 (diff)
Merge branch 'master' into mpx
This merge reverts Magnus' device coorindate scaling changes. MPX core event generation is very different, so we can't scale in GetPointerEvents. Conflicts: Xi/opendev.c dix/devices.c dix/dixfonts.c dix/getevents.c dix/resource.c dix/window.c hw/xfree86/common/xf86Xinput.c mi/mipointer.c xkb/ddxBeep.c xkb/ddxCtrls.c xkb/ddxKeyClick.c xkb/ddxList.c xkb/ddxLoad.c xkb/xkb.c xkb/xkbAccessX.c xkb/xkbEvents.c xkb/xkbInit.c xkb/xkbPrKeyEv.c xkb/xkbUtils.c
Diffstat (limited to 'hw/xfree86/common/xf86Xinput.c')
-rw-r--r--hw/xfree86/common/xf86Xinput.c59
1 files changed, 40 insertions, 19 deletions
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index d2c05313d..d8e23ee8d 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -142,6 +142,11 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
/* Backwards compatibility. */
local->history_size = GetMotionHistorySize();
+ /* Preallocate xEvent store */
+ if (!xf86Events)
+ xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ if (!xf86Events)
+ FatalError("Couldn't allocate event store\n");
}
/***********************************************************************
@@ -495,6 +500,8 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
* convenient functions to post events
*/
+#define MAX_VALUATORS 36 /* XXX from comment in dix/getevents.c */
+
_X_EXPORT void
xf86PostMotionEvent(DeviceIntPtr device,
int is_absolute,
@@ -504,17 +511,12 @@ xf86PostMotionEvent(DeviceIntPtr device,
{
va_list var;
int i = 0;
- static int *valuators = NULL;
- static int n_valuators = 0;
-
- if (num_valuators > n_valuators) {
- xfree (valuators);
- valuators = NULL;
- }
+ static int valuators[MAX_VALUATORS];
- if (!valuators) {
- valuators = xcalloc(sizeof(int), num_valuators);
- n_valuators = num_valuators;
+ if (num_valuators > MAX_VALUATORS) {
+ xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
+ " is greater than MAX_VALUATORS\n", num_valuators);
+ return;
}
va_start(var, num_valuators);
@@ -539,6 +541,12 @@ xf86PostMotionEventP(DeviceIntPtr device,
int index;
int flags = 0;
+ if (num_valuators > MAX_VALUATORS) {
+ xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
+ " is greater than MAX_VALUATORS\n", num_valuators);
+ return;
+ }
+
if (is_absolute)
flags = POINTER_ABSOLUTE;
else
@@ -592,9 +600,15 @@ xf86PostProximityEvent(DeviceIntPtr device,
...)
{
va_list var;
- int i, nevents, *valuators = NULL;
+ int i, nevents;
+ int valuators[MAX_VALUATORS];
- valuators = xcalloc(sizeof(int), num_valuators);
+
+ if (num_valuators > MAX_VALUATORS) {
+ xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
+ " is greater than MAX_VALUATORS\n", num_valuators);
+ return;
+ }
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
@@ -608,7 +622,6 @@ xf86PostProximityEvent(DeviceIntPtr device,
for (i = 0; i < nevents; i++)
mieqEnqueue(device, (xf86Events + i)->event);
- xfree(valuators);
}
_X_EXPORT void
@@ -621,7 +634,7 @@ xf86PostButtonEvent(DeviceIntPtr device,
...)
{
va_list var;
- int *valuators = NULL;
+ int valuators[MAX_VALUATORS];
int i = 0, nevents = 0;
int index;
@@ -632,7 +645,11 @@ xf86PostButtonEvent(DeviceIntPtr device,
return;
}
#endif
- valuators = xcalloc(sizeof(int), num_valuators);
+ if (num_valuators > MAX_VALUATORS) {
+ xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
+ " is greater than MAX_VALUATORS\n", num_valuators);
+ return;
+ }
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
@@ -648,7 +665,6 @@ xf86PostButtonEvent(DeviceIntPtr device,
for (i = 0; i < nevents; i++)
mieqEnqueue(device, (xf86Events + i)->event);
- xfree(valuators);
}
_X_EXPORT void
@@ -661,15 +677,21 @@ xf86PostKeyEvent(DeviceIntPtr device,
...)
{
va_list var;
- int i = 0, nevents = 0, *valuators = NULL;
+ int i = 0, nevents = 0;
+ static int valuators[MAX_VALUATORS];
/* instil confidence in the user */
DebugF("this function has never been tested properly. if things go quite "
"badly south after this message, then xf86PostKeyEvent is "
"broken.\n");
+ if (num_valuators > MAX_VALUATORS) {
+ xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
+ " is greater than MAX_VALUATORS\n", num_valuators);
+ return;
+ }
+
if (is_absolute) {
- valuators = xcalloc(sizeof(int), num_valuators);
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
valuators[i] = va_arg(var, int);
@@ -680,7 +702,6 @@ xf86PostKeyEvent(DeviceIntPtr device,
is_down ? KeyPress : KeyRelease,
key_code, first_valuator,
num_valuators, valuators);
- xfree(valuators);
}
else {
nevents = GetKeyboardEvents(xf86Events, device,