dix: Untwist transformAbsolute logic, eliminate uninitialized value warnings
tranformAbsolute has a pretty simple job, that of running the X/Y values from a device through the transformation matrix. The tricky bit comes when the current device state doesn't include one of the values. In that case, the last delivered value is back-converted to device space and used instead. The logic was twisted though, confusing GCC's uninitialized value detection logic and emitting warnings. This has been fixed by changing the code to: 1) Detect whether the ValuatorMask includes X/Y values 2) If either are missing, back-convert the current values into ox/oy 3) When X/Y are present, set ox/oy to the current value 4) Transform 5) Store X/Y values if changed or if they were set before. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
0fbbdb37c8
commit
65dd1ba7b3
|
@ -1248,8 +1248,8 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
|
||||||
double x, y, ox, oy;
|
double x, y, ox, oy;
|
||||||
int has_x, has_y;
|
int has_x, has_y;
|
||||||
|
|
||||||
has_x = valuator_mask_fetch_double(mask, 0, &ox);
|
has_x = valuator_mask_isset(mask, 0);
|
||||||
has_y = valuator_mask_fetch_double(mask, 1, &oy);
|
has_y = valuator_mask_isset(mask, 1);
|
||||||
|
|
||||||
if (!has_x && !has_y)
|
if (!has_x && !has_y)
|
||||||
return;
|
return;
|
||||||
|
@ -1263,23 +1263,23 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
|
||||||
|
|
||||||
pixman_f_transform_invert(&invert, &dev->scale_and_transform);
|
pixman_f_transform_invert(&invert, &dev->scale_and_transform);
|
||||||
transform(&invert, &ox, &oy);
|
transform(&invert, &ox, &oy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_x)
|
||||||
|
ox = valuator_mask_get_double(mask, 0);
|
||||||
|
|
||||||
|
if (has_y)
|
||||||
|
oy = valuator_mask_get_double(mask, 1);
|
||||||
|
|
||||||
x = ox;
|
x = ox;
|
||||||
y = oy;
|
y = oy;
|
||||||
}
|
|
||||||
|
|
||||||
if (valuator_mask_isset(mask, 0))
|
|
||||||
ox = x = valuator_mask_get_double(mask, 0);
|
|
||||||
|
|
||||||
if (valuator_mask_isset(mask, 1))
|
|
||||||
oy = y = valuator_mask_get_double(mask, 1);
|
|
||||||
|
|
||||||
transform(&dev->scale_and_transform, &x, &y);
|
transform(&dev->scale_and_transform, &x, &y);
|
||||||
|
|
||||||
if (valuator_mask_isset(mask, 0) || ox != x)
|
if (has_x || ox != x)
|
||||||
valuator_mask_set_double(mask, 0, x);
|
valuator_mask_set_double(mask, 0, x);
|
||||||
|
|
||||||
if (valuator_mask_isset(mask, 1) || oy != y)
|
if (has_y || oy != y)
|
||||||
valuator_mask_set_double(mask, 1, y);
|
valuator_mask_set_double(mask, 1, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue