diff options
author | Keith Packard <keithp@keithp.com> | 2014-10-22 14:48:10 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-10-28 20:56:37 -0700 |
commit | 65dd1ba7b3e00243a76ec691e566ef7c8dd94855 (patch) | |
tree | a98b66315bc7c84b43b3ae5c372631a8cb039082 /dix | |
parent | 0fbbdb37c87b5824729f65c7fbac05223024fd27 (diff) |
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>
Diffstat (limited to 'dix')
-rw-r--r-- | dix/getevents.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/dix/getevents.c b/dix/getevents.c index ffa89fad2..dd9626526 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1248,8 +1248,8 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask) double x, y, ox, oy; int has_x, has_y; - has_x = valuator_mask_fetch_double(mask, 0, &ox); - has_y = valuator_mask_fetch_double(mask, 1, &oy); + has_x = valuator_mask_isset(mask, 0); + has_y = valuator_mask_isset(mask, 1); if (!has_x && !has_y) return; @@ -1263,23 +1263,23 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask) pixman_f_transform_invert(&invert, &dev->scale_and_transform); transform(&invert, &ox, &oy); - - x = ox; - y = oy; } - if (valuator_mask_isset(mask, 0)) - ox = x = valuator_mask_get_double(mask, 0); + if (has_x) + ox = valuator_mask_get_double(mask, 0); - if (valuator_mask_isset(mask, 1)) - oy = y = valuator_mask_get_double(mask, 1); + if (has_y) + oy = valuator_mask_get_double(mask, 1); + + x = ox; + y = oy; 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); - if (valuator_mask_isset(mask, 1) || oy != y) + if (has_y || oy != y) valuator_mask_set_double(mask, 1, y); } |