aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix')
-rw-r--r--xorg-server/dix/devices.c2
-rw-r--r--xorg-server/dix/eventconvert.c3
-rw-r--r--xorg-server/dix/getevents.c38
-rw-r--r--xorg-server/dix/ptrveloc.c217
4 files changed, 137 insertions, 123 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index 03a4bee97..925cf0979 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -942,6 +942,8 @@ CloseDevice(DeviceIntPtr dev)
}
free(dev->deviceGrab.sync.event);
+ free(dev->config_info); /* Allocated in xf86ActivateDevice. */
+ dev->config_info = NULL;
dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE);
}
diff --git a/xorg-server/dix/eventconvert.c b/xorg-server/dix/eventconvert.c
index 93715f35d..d5ac54796 100644
--- a/xorg-server/dix/eventconvert.c
+++ b/xorg-server/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;
}
}
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c
index 73fb2370f..7f273fb2d 100644
--- a/xorg-server/dix/getevents.c
+++ b/xorg-server/dix/getevents.c
@@ -782,7 +782,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)
@@ -806,17 +806,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+@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);
}
/**
@@ -827,7 +824,11 @@ accelPointer(DeviceIntPtr dev, int first, int num, int *valuators, CARD32 ms)
* miPointerSetPosition() and then scale back into device coordinates (if
* needed). miPSP will change x/y if the screen was crossed.
*
+ * The coordinates provided are always absolute. The parameter mode whether
+ * it was relative or absolute movement that landed us at those coordinates.
+ *
* @param dev The device to be moved.
+ * @param mode Movement mode (Absolute or Relative)
* @param x Pointer to current x-axis value, may be modified.
* @param y Pointer to current y-axis value, may be modified.
* @param x_frac Fractional part of current x-axis value, may be modified.
@@ -839,7 +840,8 @@ accelPointer(DeviceIntPtr dev, int first, int num, int *valuators, CARD32 ms)
* @param screeny_frac Fractional part of screen y coordinate, as above.
*/
static void
-positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac,
+positionSprite(DeviceIntPtr dev, int mode,
+ int *x, int *y, float x_frac, float y_frac,
ScreenPtr scr, int *screenx, int *screeny, float *screenx_frac, float *screeny_frac)
{
int old_screenx, old_screeny;
@@ -878,7 +880,7 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac,
old_screeny = *screeny;
/* This takes care of crossing screens for us, as well as clipping
* to the current screen. */
- miPointerSetPosition(dev, screenx, screeny);
+ miPointerSetPosition(dev, mode, screenx, screeny);
if(!IsMaster(dev) || !IsFloating(dev)) {
DeviceIntPtr master = GetMaster(dev, MASTER_POINTER);
@@ -1185,20 +1187,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];
@@ -1209,7 +1198,8 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
set_raw_valuators(raw, &mask, raw->valuators.data);
- positionSprite(pDev, &x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac);
+ positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
+ &x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac);
updateHistory(pDev, &mask, ms);
/* Update the valuators with the true value sent to the client*/
diff --git a/xorg-server/dix/ptrveloc.c b/xorg-server/dix/ptrveloc.c
index 1170e767d..2ffc984c3 100644
--- a/xorg-server/dix/ptrveloc.c
+++ b/xorg-server/dix/ptrveloc.c
@@ -34,6 +34,7 @@
#include <ptrveloc.h>
#include <exevents.h>
#include <X11/Xatom.h>
+#include <os.h>
#include <xserver-properties.h>
@@ -77,9 +78,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*/
@@ -96,7 +100,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
*/
@@ -134,17 +137,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;
}
@@ -155,14 +163,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();
}
}
@@ -354,26 +369,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;
@@ -387,10 +410,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;
}
@@ -406,8 +434,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;
}
@@ -1035,7 +1062,8 @@ GetDevicePredictableAccelData(
acceleratePointerPredictable &&
dev->valuator->accelScheme.accelData != NULL){
- return (DeviceVelocityPtr)dev->valuator->accelScheme.accelData;
+ return ((PredictableAccelSchemePtr)
+ dev->valuator->accelScheme.accelData)->vel;
}
return NULL;
}
@@ -1052,32 +1080,28 @@ GetDevicePredictableAccelData(
void
acceleratePointerPredictable(
DeviceIntPtr dev,
- int first_valuator,
- int num_valuators,
- int *valuators,
- int evtime)
+ ValuatorMask* val,
+ CARD32 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){
@@ -1089,15 +1113,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];
@@ -1106,13 +1130,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);
@@ -1133,25 +1159,18 @@ acceleratePointerPredictable(
void
acceleratePointerLightweight(
DeviceIntPtr dev,
- int first_valuator,
- int num_valuators,
- int *valuators,
- int ignored)
+ ValuatorMask* val,
+ CARD32 ignored)
{
- float mult = 0.0;
- int dx = 0, dy = 0;
- int *px = NULL, *py = NULL;
+ float mult = 0.0, tmpf;
+ int dx = 0, dy = 0, tmpi;
- if (!num_valuators || !valuators)
- return;
-
- 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)
@@ -1161,45 +1180,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;
}
}
}