xserver: Branch 'master' - 14 commits
Keith Packard
keithp at kemper.freedesktop.org
Mon Mar 14 13:03:08 PDT 2011
Xi/xipassivegrab.c | 4
Xi/xiproperty.c | 4
config/hal.c | 6 -
config/udev.c | 6 -
dix/devices.c | 2
dix/eventconvert.c | 3
dix/getevents.c | 26 ----
dix/ptrveloc.c | 217 ++++++++++++++++++++++-------------------
hw/xfree86/common/xf86Xinput.c | 3
include/input.h | 12 --
include/ptrveloc.h | 26 +++-
mi/misprite.c | 41 +++----
record/record.c | 1
xkb/xkbActions.c | 11 --
14 files changed, 183 insertions(+), 179 deletions(-)
New commits:
commit a8146f6becc44bf9ad611d33bded17df07e6af21
Author: Erkki Seppälä <erkki.seppala at vincit.fi>
Date: Wed Mar 9 17:29:14 2011 +0200
mi/misprite: use memory management provided by dixRegisterPrivateKey
The record allocated by miSpriteDeviceCursorInitialize was not being
released.
This patch makes misprite use dixRegisterPrivateKey with the record
size argument, which handles the memory management
issues. miSpriteDeviceCursorInitialize is restructured to initialize
pCursorInfo only if miDCDeviceInitialize succeeds. The record itself
is zeroed on cleanup to ensure that the assumptions in the code still
hold.
Reviewed-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
Signed-off-by: Erkki Seppälä <erkki.seppala at vincit.fi>
Reviewed-by: Daniel Stone <daniel at fooishbar.org>
Signed-off-by: Keith Packard <keithp at keithp.com>
diff --git a/mi/misprite.c b/mi/misprite.c
index b0290af..1cfcdf6 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -308,7 +308,7 @@ miSpriteInitialize (ScreenPtr pScreen,
if (!dixRegisterPrivateKey(&miSpriteScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
- if (!dixRegisterPrivateKey(&miSpriteDevPrivatesKeyRec, PRIVATE_DEVICE, 0))
+ if (!dixRegisterPrivateKey(&miSpriteDevPrivatesKeyRec, PRIVATE_DEVICE, sizeof(miCursorInfoRec)))
return FALSE;
pScreenPriv = malloc(sizeof (miSpriteScreenRec));
@@ -860,38 +860,35 @@ miSpriteMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
static Bool
miSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
{
- miCursorInfoPtr pCursorInfo;
- int ret = FALSE;
-
- pCursorInfo = malloc(sizeof(miCursorInfoRec));
- if (!pCursorInfo)
- return FALSE;
-
- pCursorInfo->pCursor = NULL;
- pCursorInfo->x = 0;
- pCursorInfo->y = 0;
- pCursorInfo->isUp = FALSE;
- pCursorInfo->shouldBeUp = FALSE;
- pCursorInfo->pCacheWin = NullWindow;
- pCursorInfo->isInCacheWin = FALSE;
- pCursorInfo->checkPixels = TRUE;
- pCursorInfo->pScreen = FALSE;
+ int ret = miDCDeviceInitialize(pDev, pScreen);
- ret = miDCDeviceInitialize(pDev, pScreen);
- if (!ret)
+ if (ret)
{
- free(pCursorInfo);
- pCursorInfo = NULL;
+ miCursorInfoPtr pCursorInfo;
+ pCursorInfo = dixLookupPrivate(&pDev->devPrivates, miSpriteDevPrivatesKey);
+ pCursorInfo->pCursor = NULL;
+ pCursorInfo->x = 0;
+ pCursorInfo->y = 0;
+ pCursorInfo->isUp = FALSE;
+ pCursorInfo->shouldBeUp = FALSE;
+ pCursorInfo->pCacheWin = NullWindow;
+ pCursorInfo->isInCacheWin = FALSE;
+ pCursorInfo->checkPixels = TRUE;
+ pCursorInfo->pScreen = FALSE;
}
- dixSetPrivate(&pDev->devPrivates, miSpriteDevPrivatesKey, pCursorInfo);
+
return ret;
}
static void
miSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
{
+ miCursorInfoPtr pCursorInfo = dixLookupPrivate(&pDev->devPrivates, miSpriteDevPrivatesKey);
+
if (DevHasCursor(pDev))
miDCDeviceCleanup(pDev, pScreen);
+
+ memset(pCursorInfo, 0, sizeof(miCursorInfoRec));
}
/*
commit c3c0e2fdd326214e271ce144e8fc2725cbd738ef
Merge: a19771e... 7355555...
Author: Keith Packard <keithp at keithp.com>
Date: Wed Mar 9 14:25:54 2011 -0800
Merge remote branch 'whot/for-keith'
commit 73555555a440855f9ae64c3367c5c7dca98c8741
Author: Adam Jackson <ajax at redhat.com>
Date: Tue Mar 8 15:33:13 2011 -0500
record: warning fix
record.c:810:9: warning: unused variable 'count'
Scope-shadowed by a later variable of the same name, safe to just
delete.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/record/record.c b/record/record.c
index 1168c43..c59f187 100644
--- a/record/record.c
+++ b/record/record.c
@@ -804,7 +804,6 @@ RecordADeviceEvent(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
RecordContextPtr pContext;
RecordClientsAndProtocolPtr pRCAP;
int eci; /* enabled context index */
- int count;
for (eci = 0; eci < numEnabledContexts; eci++)
{
commit 4d114cc5467a514faa437ce7f4c5e772e2f6a21d
Author: Adam Jackson <ajax at redhat.com>
Date: Tue Mar 8 15:33:12 2011 -0500
input: warning fixes
eventconvert.c:287:9: warning: enumeration value 'ET_Enter' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_Leave' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_FocusIn' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_FocusOut' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_DeviceChanged' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_Hierarchy' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_DGAEvent' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_RawKeyPress' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_RawKeyRelease' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_RawButtonPress' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_RawButtonRelease' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_RawMotion' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_XQuartz' not handled in switch
eventconvert.c:287:9: warning: enumeration value 'ET_Internal' not handled in switch
From the code it appears these are can't happens, so if they ever do,
BadImplementation seems entirely appropriate.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 760729b..c9d1994 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -297,6 +297,9 @@ eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count)
case ET_ProximityOut:
*count = 0;
return BadMatch;
+ default:
+ *count = 0;
+ return BadImplementation;
}
}
commit 7b5e562ea74039832116ee13db910f290f074782
Author: Adam Jackson <ajax at redhat.com>
Date: Tue Mar 8 15:33:11 2011 -0500
input: warning fix
getevents.c:770:5: warning: suggest parentheses around '&&' within '||'
Introduced with dc57f89959e549403f8488eb9f23425bd7118b22:
- if(dev->u.master && dev->valuator) {
+ if(dev->valuator && IsMaster(dev) || !IsFloating(dev)) {
So I'm assuming the two terms around the || are meant to be a unit.
Signed-off-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/dix/getevents.c b/dix/getevents.c
index 1403ccc..441c20f 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -767,7 +767,7 @@ moveRelative(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask)
/* if attached, clip both x and y to the defined limits (usually
* co-ord space limit). If it is attached, we need x/y to go over the
* limits to be able to change screens. */
- if(dev->valuator && IsMaster(dev) || !IsFloating(dev)) {
+ if (dev->valuator && (IsMaster(dev) || !IsFloating(dev))) {
if (valuator_get_mode(dev, 0) == Absolute)
clipAxis(dev, 0, x);
if (valuator_get_mode(dev, 1) == Absolute)
commit 33fee13361e745e1db29e250b08622c83046d488
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Tue Mar 8 14:41:21 2011 +1000
Xi: fix XI2 passive grab reply length calculation
If modifiers failed, the reply length was 4 bytes too short.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Julien Cristau <jcristau at debian.org>
Reviewed-by: Daniel Stone <daniel at fooishbar.org>
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index 8663d12..3319ef9 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -191,7 +191,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
info->status = status;
info->modifiers = *modifiers;
rep.num_modifiers++;
- rep.length++;
+ rep.length += bytes_to_int32(sizeof(xXIGrabModifierInfo));
}
}
@@ -199,7 +199,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
if (rep.num_modifiers)
{
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
- WriteSwappedDataToClient(client, rep.num_modifiers * 4, (char*)modifiers_failed);
+ WriteSwappedDataToClient(client, rep.length * 4, (char*)modifiers_failed);
}
free(modifiers_failed);
return ret;
commit eb8141b6edd8b477c0ba796be71e985c35520a9b
Author: Julien Cristau <jcristau at debian.org>
Date: Mon Mar 7 18:55:19 2011 +0100
Xi: fix length checks for swapped clients
ChangeDeviceProperty and XIChangeProperty are followed by some data, so
use REQUEST_AT_LEAST_SIZE instead of REQUEST_SIZE_MATCH.
X.Org bug#35082 <https://bugs.freedesktop.org/show_bug.cgi?id=35082>
Reported-by: Markus Fleschutz <markus.fleschutz at x-software.com>
Signed-off-by: Julien Cristau <jcristau at debian.org>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 17835e2..83ce930 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -1051,11 +1051,11 @@ SProcXChangeDeviceProperty (ClientPtr client)
char n;
REQUEST(xChangeDevicePropertyReq);
+ REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq);
swaps(&stuff->length, n);
swapl(&stuff->property, n);
swapl(&stuff->type, n);
swapl(&stuff->nUnits, n);
- REQUEST_SIZE_MATCH(xChangeDevicePropertyReq);
return (ProcXChangeDeviceProperty(client));
}
@@ -1295,12 +1295,12 @@ SProcXIChangeProperty(ClientPtr client)
char n;
REQUEST(xXIChangePropertyReq);
+ REQUEST_AT_LEAST_SIZE(xXIChangePropertyReq);
swaps(&stuff->length, n);
swaps(&stuff->deviceid, n);
swapl(&stuff->property, n);
swapl(&stuff->type, n);
swapl(&stuff->num_items, n);
- REQUEST_SIZE_MATCH(xXIChangePropertyReq);
return (ProcXIChangeProperty(client));
}
commit 4114533db6704324fc26f28a444415e325ace8e0
Author: Rami Ylimäki <rami.ylimaki at vincit.fi>
Date: Fri Mar 4 17:55:33 2011 +0200
config: Ensure that stolen option list elements are released.
NewInputDeviceRequest steals the contents of option list elements but
doesn't use the elements themselves for anything. Therefore the list
elements need to be released always.
Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/config/hal.c b/config/hal.c
index 0b848a0..297520a 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -392,10 +392,10 @@ unwind:
free(driver);
free(name);
free(config_info);
- while (!dev && (tmpo = options)) {
+ while ((tmpo = options)) {
options = tmpo->next;
- free(tmpo->key);
- free(tmpo->value);
+ free(tmpo->key); /* NULL if dev != NULL */
+ free(tmpo->value); /* NULL if dev != NULL */
free(tmpo);
}
diff --git a/config/udev.c b/config/udev.c
index ab27c98..678e47a 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -197,10 +197,10 @@ device_added(struct udev_device *udev_device)
unwind:
free(config_info);
- while (!dev && (tmpo = options)) {
+ while ((tmpo = options)) {
options = tmpo->next;
- free(tmpo->key);
- free(tmpo->value);
+ free(tmpo->key); /* NULL if dev != NULL */
+ free(tmpo->value); /* NULL if dev != NULL */
free(tmpo);
}
commit 8d30aff4aa708b9b885d492602ced7493a96a4df
Author: Rami Ylimäki <rami.ylimaki at vincit.fi>
Date: Fri Mar 4 17:55:32 2011 +0200
dix: Release input device config info when the device disconnects.
Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/dix/devices.c b/dix/devices.c
index b8d8e7b..f1ba31e 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -938,6 +938,8 @@ CloseDevice(DeviceIntPtr dev)
}
free(dev->deviceGrab.sync.event);
+ free(dev->config_info); /* Allocated in xf86ActivateDevice. */
+ dev->config_info = NULL;
dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE);
}
commit 40e56d34538f4663426db50893c231a2b5d760dc
Author: Rami Ylimäki <rami.ylimaki at vincit.fi>
Date: Fri Mar 4 17:55:31 2011 +0200
xkb: Ensure that XKB device private won't leak on device disconnect.
Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 65c678a..c4336d7 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -68,20 +68,13 @@ xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
Bool
XkbInitPrivates(void)
{
- return dixRegisterPrivateKey(&xkbDevicePrivateKeyRec, PRIVATE_DEVICE, 0);
+ return dixRegisterPrivateKey(&xkbDevicePrivateKeyRec, PRIVATE_DEVICE, sizeof(xkbDeviceInfoRec));
}
void
XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
{
- xkbDeviceInfoPtr xkbPrivPtr;
-
- xkbPrivPtr = (xkbDeviceInfoPtr) calloc(1, sizeof(xkbDeviceInfoRec));
- if (!xkbPrivPtr)
- return;
- xkbPrivPtr->unwrapProc = NULL;
-
- dixSetPrivate(&device->devPrivates, xkbDevicePrivateKey, xkbPrivPtr);
+ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc);
}
commit 18413f55089623123537c1499b02aa95ca2014d2
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Mar 3 14:15:55 2011 +1000
xfree86: block signals between EnableDevice and first CheckMotion()
Devices usually enable SIGIO processing in EnableDevice. CheckMotion
initialises the pointer sprite, sends Enter/Leave events, etc. This leaves
us with a small window where events may be processed without the sprite or
pointer position (as seen from the protocol) is valid.
Block signals during this window.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Daniel Stone <daniel at fooishbar.org>
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 74365e1..e3264e6 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -817,15 +817,18 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
/* Enable it if it's properly initialised and we're currently in the VT */
if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
{
+ OsBlockSignals();
EnableDevice(dev, TRUE);
if (!dev->enabled)
{
+ OsReleaseSignals();
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
rval = BadMatch;
goto unwind;
}
/* send enter/leave event, update sprite window */
CheckMotion(NULL, dev);
+ OsReleaseSignals();
}
*pdev = dev;
commit 1c008e7e7865b405b8033f625333cd64ece4499e
Author: Simon Thum <simon.thum at gmx.de>
Date: Wed Feb 23 02:29:35 2011 +0100
dix: change all timestamps in pointer acceleration to CARD32
CARD32 is being returned by GetTimeInMilis(), so use it consistently.
Signed-off-by: Simon Thum <simon.thum at gmx.de>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index ed80af5..ccd445e 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -1072,7 +1072,7 @@ void
acceleratePointerPredictable(
DeviceIntPtr dev,
ValuatorMask* val,
- int evtime)
+ CARD32 evtime)
{
float fdx, fdy, tmp, mult; /* no need to init */
int dx = 0, dy = 0, tmpi;
@@ -1151,7 +1151,7 @@ void
acceleratePointerLightweight(
DeviceIntPtr dev,
ValuatorMask* val,
- int ignored)
+ CARD32 ignored)
{
float mult = 0.0, tmpf;
int dx = 0, dy = 0, tmpi;
diff --git a/include/input.h b/include/input.h
index 165992a..bdef038 100644
--- a/include/input.h
+++ b/include/input.h
@@ -145,7 +145,7 @@ typedef void (*DeviceUnwrapProc)(
typedef void (*PointerAccelSchemeProc)(
DeviceIntPtr /*device*/,
ValuatorMask* /*valuators*/,
- int /*evtime*/);
+ CARD32 /*evtime*/);
typedef void (*DeviceCallbackProc)(
DeviceIntPtr /*pDev*/);
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index a1165b1..c14e12d 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -134,9 +134,11 @@ InitPredictableAccelerationScheme(DeviceIntPtr dev,
struct _ValuatorAccelerationRec* protoScheme);
extern _X_INTERNAL void
-acceleratePointerPredictable(DeviceIntPtr dev, ValuatorMask* val, int evtime);
+acceleratePointerPredictable(DeviceIntPtr dev, ValuatorMask* val,
+ CARD32 evtime);
extern _X_INTERNAL void
-acceleratePointerLightweight(DeviceIntPtr dev, ValuatorMask* val, int evtime);
+acceleratePointerLightweight(DeviceIntPtr dev, ValuatorMask* val,
+ CARD32 evtime);
#endif /* POINTERVELOCITY_H */
commit a4b85261859b17dba9ad8f7f1ce650133f0235d4
Author: Simon Thum <simon.thum at gmx.de>
Date: Wed Feb 23 02:29:34 2011 +0100
dix: update pointer acceleration code to use ValuatorMask
Signed-off-by: Simon Thum <simon.thum at gmx.de>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/dix/getevents.c b/dix/getevents.c
index 5b8e379..1403ccc 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -791,17 +791,14 @@ moveRelative(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask)
* Accelerate the data in valuators based on the device's acceleration scheme.
*
* @param dev The device which's pointer is to be moved.
- * @param first The first valuator in @valuators
- * @param num Total number of valuators in @valuators.
- * @param valuators Valuator data for each axis between @first and
- * @first+ at num.
+ * @param valuators Valuator mask
* @param ms Current time.
*/
static void
-accelPointer(DeviceIntPtr dev, int first, int num, int *valuators, CARD32 ms)
+accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms)
{
if (dev->valuator->accelScheme.AccelSchemeProc)
- dev->valuator->accelScheme.AccelSchemeProc(dev, first, num, valuators, ms);
+ dev->valuator->accelScheme.AccelSchemeProc(dev, valuators, ms);
}
/**
@@ -1170,20 +1167,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
moveAbsolute(pDev, &x, &y, &mask);
} else {
if (flags & POINTER_ACCELERATE) {
- /* FIXME: Pointer acceleration only requires X and Y values. This
- * should be converted to masked valuators. */
- int vals[2];
- vals[0] = valuator_mask_isset(&mask, 0) ?
- valuator_mask_get(&mask, 0) : 0;
- vals[1] = valuator_mask_isset(&mask, 1) ?
- valuator_mask_get(&mask, 1) : 0;
- accelPointer(pDev, 0, 2, vals, ms);
-
- if (valuator_mask_isset(&mask, 0))
- valuator_mask_set(&mask, 0, vals[0]);
- if (valuator_mask_isset(&mask, 1))
- valuator_mask_set(&mask, 1, vals[1]);
-
+ accelPointer(pDev, &mask, ms);
/* The pointer acceleration code modifies the fractional part
* in-place, so we need to extract this information first */
x_frac = pDev->last.remainder[0];
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 3b0c75a..ed80af5 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -1071,32 +1071,28 @@ GetDevicePredictableAccelData(
void
acceleratePointerPredictable(
DeviceIntPtr dev,
- int first_valuator,
- int num_valuators,
- int *valuators,
+ ValuatorMask* val,
int evtime)
{
float fdx, fdy, tmp, mult; /* no need to init */
- int dx = 0, dy = 0;
- int *px = NULL, *py = NULL;
+ int dx = 0, dy = 0, tmpi;
DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev);
Bool soften = TRUE;
- if (!num_valuators || !valuators || !velocitydata)
+ if (!velocitydata)
return;
if (velocitydata->statistics.profile_number == AccelProfileNone &&
- velocitydata->const_acceleration == 1.0f) {
- return; /*we're inactive anyway, so skip the whole thing.*/
+ velocitydata->const_acceleration == 1.0f) {
+ return; /*we're inactive anyway, so skip the whole thing.*/
}
- if (first_valuator == 0) {
- dx = valuators[0];
- px = &valuators[0];
+ if (valuator_mask_isset(val, 0)) {
+ dx = valuator_mask_get(val, 0);
}
- if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
- dy = valuators[1 - first_valuator];
- py = &valuators[1 - first_valuator];
+
+ if (valuator_mask_isset(val, 1)) {
+ dy = valuator_mask_get(val, 1);
}
if (dx || dy){
@@ -1108,15 +1104,15 @@ acceleratePointerPredictable(
if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
/* invoke acceleration profile to determine acceleration */
mult = ComputeAcceleration (dev, velocitydata,
- dev->ptrfeed->ctrl.threshold,
- (float)dev->ptrfeed->ctrl.num /
- (float)dev->ptrfeed->ctrl.den);
+ dev->ptrfeed->ctrl.threshold,
+ (float)dev->ptrfeed->ctrl.num /
+ (float)dev->ptrfeed->ctrl.den);
if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) {
- ApplySofteningAndConstantDeceleration( velocitydata,
- dx, dy,
- &fdx, &fdy,
- (mult > 1.0f) && soften);
+ ApplySofteningAndConstantDeceleration(velocitydata,
+ dx, dy,
+ &fdx, &fdy,
+ (mult > 1.0f) && soften);
if (dx) {
tmp = mult * fdx + dev->last.remainder[0];
@@ -1125,13 +1121,15 @@ acceleratePointerPredictable(
* process each axis conditionally, there's no danger
* of a toggling remainder. Its lack of guarantees likely
* makes it faster on the average target. */
- *px = lrintf(tmp);
- dev->last.remainder[0] = tmp - (float)*px;
+ tmpi = lrintf(tmp);
+ valuator_mask_set(val, 0, tmpi);
+ dev->last.remainder[0] = tmp - (float)tmpi;
}
if (dy) {
tmp = mult * fdy + dev->last.remainder[1];
- *py = lrintf(tmp);
- dev->last.remainder[1] = tmp - (float)*py;
+ tmpi = lrintf(tmp);
+ valuator_mask_set(val, 1, tmpi);
+ dev->last.remainder[1] = tmp - (float)tmpi;
}
DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n",
*px, *py, dev->last.remainder[0], dev->last.remainder[1], fdx, fdy);
@@ -1152,25 +1150,18 @@ acceleratePointerPredictable(
void
acceleratePointerLightweight(
DeviceIntPtr dev,
- int first_valuator,
- int num_valuators,
- int *valuators,
+ ValuatorMask* val,
int ignored)
{
- float mult = 0.0;
- int dx = 0, dy = 0;
- int *px = NULL, *py = NULL;
-
- if (!num_valuators || !valuators)
- return;
+ float mult = 0.0, tmpf;
+ int dx = 0, dy = 0, tmpi;
- if (first_valuator == 0) {
- dx = valuators[0];
- px = &valuators[0];
+ if (valuator_mask_isset(val, 0)) {
+ dx = valuator_mask_get(val, 0);
}
- if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
- dy = valuators[1 - first_valuator];
- py = &valuators[1 - first_valuator];
+
+ if (valuator_mask_isset(val, 1)) {
+ dy = valuator_mask_get(val, 1);
}
if (!dx && !dy)
@@ -1180,45 +1171,45 @@ acceleratePointerLightweight(
/* modeled from xf86Events.c */
if (dev->ptrfeed->ctrl.threshold) {
if ((abs(dx) + abs(dy)) >= dev->ptrfeed->ctrl.threshold) {
- dev->last.remainder[0] = ((float)dx *
- (float)(dev->ptrfeed->ctrl.num)) /
- (float)(dev->ptrfeed->ctrl.den) +
- dev->last.remainder[0];
- if (px) {
- *px = (int)dev->last.remainder[0];
- dev->last.remainder[0] = dev->last.remainder[0] -
- (float)(*px);
+ tmpf = ((float)dx *
+ (float)(dev->ptrfeed->ctrl.num)) /
+ (float)(dev->ptrfeed->ctrl.den) +
+ dev->last.remainder[0];
+ if (dx) {
+ tmpi = (int) tmpf;
+ valuator_mask_set(val, 0, tmpi);
+ dev->last.remainder[0] = tmpf - (float)tmpi;
}
- dev->last.remainder[1] = ((float)dy *
- (float)(dev->ptrfeed->ctrl.num)) /
- (float)(dev->ptrfeed->ctrl.den) +
- dev->last.remainder[1];
- if (py) {
- *py = (int)dev->last.remainder[1];
- dev->last.remainder[1] = dev->last.remainder[1] -
- (float)(*py);
+ tmpf = ((float)dy *
+ (float)(dev->ptrfeed->ctrl.num)) /
+ (float)(dev->ptrfeed->ctrl.den) +
+ dev->last.remainder[1];
+ if (dy) {
+ tmpi = (int) tmpf;
+ valuator_mask_set(val, 1, tmpi);
+ dev->last.remainder[1] = tmpf - (float)tmpi;
}
}
}
else {
- mult = pow((float)dx * (float)dx + (float)dy * (float)dy,
+ mult = pow((float)dx * (float)dx + (float)dy * (float)dy,
((float)(dev->ptrfeed->ctrl.num) /
(float)(dev->ptrfeed->ctrl.den) - 1.0) /
2.0) / 2.0;
if (dx) {
- dev->last.remainder[0] = mult * (float)dx +
- dev->last.remainder[0];
- *px = (int)dev->last.remainder[0];
- dev->last.remainder[0] = dev->last.remainder[0] -
- (float)(*px);
+ tmpf = mult * (float)dx +
+ dev->last.remainder[0];
+ tmpi = (int) tmpf;
+ valuator_mask_set(val, 0, tmpi);
+ dev->last.remainder[0] = tmpf - (float)tmpi;
}
if (dy) {
- dev->last.remainder[1] = mult * (float)dy +
- dev->last.remainder[1];
- *py = (int)dev->last.remainder[1];
- dev->last.remainder[1] = dev->last.remainder[1] -
- (float)(*py);
+ tmpf = mult * (float)dy +
+ dev->last.remainder[1];
+ tmpi = (int)tmpf;
+ valuator_mask_set(val, 1, tmpi);
+ dev->last.remainder[1] = tmpf - (float)tmpi;
}
}
}
diff --git a/include/input.h b/include/input.h
index 643866f..165992a 100644
--- a/include/input.h
+++ b/include/input.h
@@ -106,6 +106,8 @@ typedef struct _ClassesRec *ClassesPtr;
typedef struct _SpriteRec *SpritePtr;
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
@@ -141,10 +143,8 @@ typedef void (*DeviceUnwrapProc)(
/* pointer acceleration handling */
typedef void (*PointerAccelSchemeProc)(
- DeviceIntPtr /*pDev*/,
- int /*first_valuator*/,
- int /*num_valuators*/,
- int* /*valuators*/,
+ DeviceIntPtr /*device*/,
+ ValuatorMask* /*valuators*/,
int /*evtime*/);
typedef void (*DeviceCallbackProc)(
@@ -163,8 +163,6 @@ typedef struct _DeviceRec {
Bool on; /* used by DDX to keep state */
} DeviceRec, *DevicePtr;
-typedef struct _ValuatorMask ValuatorMask;
-
typedef struct {
int click, bell, bell_pitch, bell_duration;
Bool autoRepeat;
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 5c57d42..a1165b1 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright © 2006-2009 Simon Thum simon dot thum at gmx dot de
+ * Copyright © 2006-2011 Simon Thum simon dot thum at gmx dot de
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,7 +25,7 @@
#ifndef POINTERVELOCITY_H
#define POINTERVELOCITY_H
-#include <input.h> /* DeviceIntPtr */
+#include <input.h>
/* constants for acceleration profiles */
@@ -134,11 +134,9 @@ InitPredictableAccelerationScheme(DeviceIntPtr dev,
struct _ValuatorAccelerationRec* protoScheme);
extern _X_INTERNAL void
-acceleratePointerPredictable(DeviceIntPtr dev, int first_valuator,
- int num_valuators, int *valuators, int evtime);
+acceleratePointerPredictable(DeviceIntPtr dev, ValuatorMask* val, int evtime);
extern _X_INTERNAL void
-acceleratePointerLightweight(DeviceIntPtr dev, int first_valuator,
- int num_valuators, int *valuators, int ignored);
+acceleratePointerLightweight(DeviceIntPtr dev, ValuatorMask* val, int evtime);
#endif /* POINTERVELOCITY_H */
commit 8128846e16b406c7d459ae7556f7cd09bdc24c91
Author: Simon Thum <simon.thum at gmx.de>
Date: Wed Feb 23 02:29:33 2011 +0100
dix: refactor predictable scheme initialization
This intends to clean up the predictable accel struct
from purely scheme-related things like input properties,
as they would be useless in other use cases such
as wheel acceleration.
Signed-off-by: Simon Thum <simon.thum at gmx.de>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index e6ac2ed..3b0c75a 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -30,6 +30,7 @@
#include <ptrveloc.h>
#include <exevents.h>
#include <X11/Xatom.h>
+#include <os.h>
#include <xserver-properties.h>
@@ -68,9 +69,12 @@ SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr vel, float velocity,
static PointerAccelerationProfileFunc
GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
static BOOL
-InitializePredictableAccelerationProperties(DeviceIntPtr dev);
+InitializePredictableAccelerationProperties(DeviceIntPtr,
+ DeviceVelocityPtr,
+ PredictableAccelSchemePtr);
static BOOL
-DeletePredictableAccelerationProperties(DeviceIntPtr dev);
+DeletePredictableAccelerationProperties(DeviceIntPtr,
+ PredictableAccelSchemePtr);
/*#define PTRACCEL_DEBUGGING*/
@@ -87,7 +91,6 @@ DeletePredictableAccelerationProperties(DeviceIntPtr dev);
/* some int which is not a profile number */
#define PROFILE_UNINITIALIZE (-100)
-
/**
* Init DeviceVelocity struct so it should match the average case
*/
@@ -125,17 +128,22 @@ FreeVelocityData(DeviceVelocityPtr vel){
*/
Bool
InitPredictableAccelerationScheme(DeviceIntPtr dev,
- ValuatorAccelerationPtr protoScheme) {
+ ValuatorAccelerationPtr protoScheme) {
DeviceVelocityPtr vel;
ValuatorAccelerationRec scheme;
+ PredictableAccelSchemePtr schemeData;
scheme = *protoScheme;
vel = calloc(1, sizeof(DeviceVelocityRec));
- if (!vel)
- return FALSE;
+ schemeData = calloc(1, sizeof(PredictableAccelSchemeRec));
+ if (!vel || !schemeData)
+ return FALSE;
InitVelocityData(vel);
- scheme.accelData = vel;
+ schemeData->vel = vel;
+ scheme.accelData = schemeData;
+ if (!InitializePredictableAccelerationProperties(dev, vel, schemeData))
+ return FALSE;
+ /* all fine, assign scheme to device */
dev->valuator->accelScheme = scheme;
- InitializePredictableAccelerationProperties(dev);
return TRUE;
}
@@ -146,14 +154,21 @@ InitPredictableAccelerationScheme(DeviceIntPtr dev,
void
AccelerationDefaultCleanup(DeviceIntPtr dev)
{
- /*sanity check*/
- if( dev->valuator->accelScheme.AccelSchemeProc == acceleratePointerPredictable
- && dev->valuator->accelScheme.accelData != NULL){
+ DeviceVelocityPtr vel = GetDevicePredictableAccelData(dev);
+ if (vel) {
+ /* the proper guarantee would be that we're not inside of
+ * AccelSchemeProc(), but that seems impossible. Schemes don't get
+ * switched often anyway.
+ */
+ OsBlockSignals();
dev->valuator->accelScheme.AccelSchemeProc = NULL;
- FreeVelocityData(dev->valuator->accelScheme.accelData);
+ FreeVelocityData(vel);
+ free(vel);
+ DeletePredictableAccelerationProperties(dev,
+ (PredictableAccelSchemePtr) dev->valuator->accelScheme.accelData);
free(dev->valuator->accelScheme.accelData);
dev->valuator->accelScheme.accelData = NULL;
- DeletePredictableAccelerationProperties(dev);
+ OsReleaseSignals();
}
}
@@ -345,26 +360,34 @@ AccelInitScaleProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
return XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL);
}
-BOOL
-InitializePredictableAccelerationProperties(DeviceIntPtr dev)
+static BOOL
+InitializePredictableAccelerationProperties(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ PredictableAccelSchemePtr schemeData)
{
- DeviceVelocityPtr vel = GetDevicePredictableAccelData(dev);
-
+ int num_handlers = 4;
if(!vel)
- return FALSE;
+ return FALSE;
- vel->prop_handlers[0] = AccelInitProfileProperty(dev, vel);
- vel->prop_handlers[1] = AccelInitDecelProperty(dev, vel);
- vel->prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel);
- vel->prop_handlers[3] = AccelInitScaleProperty(dev, vel);
+ schemeData->prop_handlers = calloc(num_handlers, sizeof(long));
+ if (!schemeData->prop_handlers)
+ return FALSE;
+ schemeData->num_prop_handlers = num_handlers;
+ schemeData->prop_handlers[0] = AccelInitProfileProperty(dev, vel);
+ schemeData->prop_handlers[1] = AccelInitDecelProperty(dev, vel);
+ schemeData->prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel);
+ schemeData->prop_handlers[3] = AccelInitScaleProperty(dev, vel);
return TRUE;
}
BOOL
-DeletePredictableAccelerationProperties(DeviceIntPtr dev)
+DeletePredictableAccelerationProperties(
+ DeviceIntPtr dev,
+ PredictableAccelSchemePtr scheme)
{
- DeviceVelocityPtr vel;
+ DeviceVelocityPtr vel;
Atom prop;
int i;
@@ -378,10 +401,15 @@ DeletePredictableAccelerationProperties(DeviceIntPtr dev)
XIDeleteDeviceProperty(dev, prop, FALSE);
vel = GetDevicePredictableAccelData(dev);
- for (i = 0; vel && i < NPROPS_PREDICTABLE_ACCEL; i++)
- if (vel->prop_handlers[i])
- XIUnregisterPropertyHandler(dev, vel->prop_handlers[i]);
+ if (vel) {
+ for (i = 0; i < scheme->num_prop_handlers; i++)
+ if (scheme->prop_handlers[i])
+ XIUnregisterPropertyHandler(dev, scheme->prop_handlers[i]);
+ }
+ free(scheme->prop_handlers);
+ scheme->prop_handlers = NULL;
+ scheme->num_prop_handlers = 0;
return TRUE;
}
@@ -397,8 +425,7 @@ InitTrackers(DeviceVelocityPtr vel, int ntracker)
return;
}
free(vel->tracker);
- vel->tracker = (MotionTrackerPtr)malloc(ntracker * sizeof(MotionTracker));
- memset(vel->tracker, 0, ntracker * sizeof(MotionTracker));
+ vel->tracker = (MotionTrackerPtr)calloc(ntracker, sizeof(MotionTracker));
vel->num_tracker = ntracker;
}
@@ -1026,7 +1053,8 @@ GetDevicePredictableAccelData(
acceleratePointerPredictable &&
dev->valuator->accelScheme.accelData != NULL){
- return (DeviceVelocityPtr)dev->valuator->accelScheme.accelData;
+ return ((PredictableAccelSchemePtr)
+ dev->valuator->accelScheme.accelData)->vel;
}
return NULL;
}
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 8c59c03..5c57d42 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -62,9 +62,6 @@ typedef struct _MotionTracker {
int dir; /* initial direction bitfield */
} MotionTracker, *MotionTrackerPtr;
-/* number of properties for predictable acceleration */
-#define NPROPS_PREDICTABLE_ACCEL 4
-
/**
* Contains all data needed to implement mouse ballistics
*/
@@ -91,9 +88,18 @@ typedef struct _DeviceVelocityRec {
struct { /* to be able to query this information */
int profile_number;
} statistics;
- long prop_handlers[NPROPS_PREDICTABLE_ACCEL];
} DeviceVelocityRec, *DeviceVelocityPtr;
+/**
+ * contains the run-time data for the predictable scheme, that is, a
+ * DeviceVelocityPtr and the property handlers.
+ */
+typedef struct _PredictableAccelSchemeRec {
+ DeviceVelocityPtr vel;
+ long* prop_handlers;
+ int num_prop_handlers;
+} PredictableAccelSchemeRec, *PredictableAccelSchemePtr;
+
extern _X_EXPORT void
InitVelocityData(DeviceVelocityPtr vel);
More information about the xorg-commit
mailing list