diff options
author | Jason Gerecke <killertofu@gmail.com> | 2015-04-24 09:16:59 -0700 |
---|---|---|
committer | Jason Gerecke <killertofu@gmail.com> | 2015-04-28 12:39:20 -0700 |
commit | c14e9b485d2690245ba347879d2dd9fec9e7030f (patch) | |
tree | 3ef49ec9563beaebe4027a0992a3eea9ecbecece /tools | |
parent | 273ecfeccfceb2c2a92cfb4e26078c11a3454396 (diff) | |
download | xf86-input-wacom-c14e9b485d2690245ba347879d2dd9fec9e7030f.tar.gz |
xsetwacom: Fix 'get_mapped_area' ("maptooutput next") on 64-bit
Using the "maptooutput next" command fails on 64-bit systems,
with results ranging from always mapping the pointer to the
first head to displaying errors about the transformation matrix
being non-rectangular.
This is a result of the 'get_mapped_area' function expecting
32-bit properties returned by the server to take up only 4
bytes of memory. This is the case on 32-bit systems, but not
on 64-bit ones. This was partially addressed in bc5fd9e, but
not here.
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/xsetwacom.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index f15b088..b9e8c0f 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -2194,9 +2194,10 @@ static Bool get_mapped_area(Display *dpy, XDevice *dev, int *width, int *height, { Atom matrix_prop = XInternAtom(dpy, "Coordinate Transformation Matrix", True); Atom type; - int format; + int format, i; unsigned long nitems, bytes_after; - float *data; + unsigned long *data; + float matrix[9]; Bool matrix_is_valid = True; int display_width = DisplayWidth(dpy, DefaultScreen(dpy)); @@ -2221,17 +2222,22 @@ static Bool get_mapped_area(Display *dpy, XDevice *dev, int *width, int *height, return False; } + /* XI1 stores 32 bit properties (including float) as long, + * regardless of architecture */ + for (i = 0; i < ARRAY_SIZE(matrix); i++) + matrix[i] = *(float*)(&data[i]); + TRACE("Current transformation matrix:\n"); - TRACE(" [ %f %f %f ]\n", data[0], data[1], data[2]); - TRACE(" [ %f %f %f ]\n", data[3], data[4], data[5]); - TRACE(" [ %f %f %f ]\n", data[6], data[7], data[8]); - - *width = rint(display_width * data[0]); - *x_org = rint(display_width * data[2]); - *height = rint(display_height * data[4]); - *y_org = rint(display_height * data[5]); - if ((data[1] != 0 || data[3] != 0 || data[6] != 0 || data[7] != 0) || - (data[8] != 1)) { + TRACE(" [ %f %f %f ]\n", matrix[0], matrix[1], matrix[2]); + TRACE(" [ %f %f %f ]\n", matrix[3], matrix[4], matrix[5]); + TRACE(" [ %f %f %f ]\n", matrix[6], matrix[7], matrix[8]); + + *width = rint(display_width * matrix[0]); + *x_org = rint(display_width * matrix[2]); + *height = rint(display_height * matrix[4]); + *y_org = rint(display_height * matrix[5]); + if ((matrix[1] != 0 || matrix[3] != 0 || matrix[6] != 0 || matrix[7] != 0) || + (matrix[8] != 1)) { fprintf(stderr, "Non-rectangular transformation matrix detected.\n"); matrix_is_valid = False; } |