Xlib for XI 1 expects 32 bit properties as long, even if on the given
machine architecture the size of long is actually 64 bit. Hilarity ensues.

Convert the floats to longs before passing it to XChangeDeviceProperty.

Signed-off-by: Peter Hutterer <[email protected]>
---
this must be the 10th time this api stupidity has bitten me...

sorry for the cross-post, patches should go to -devel but this is in
response to a -discuss thread.

 tools/xsetwacom.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 72c46ec..26d822f 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1966,13 +1966,15 @@ static void get_button(Display *dpy, XDevice *dev, 
param_t *param, int argc,
        XFlush(dpy);
 }
 
-static void _set_matrix_prop(Display *dpy, XDevice *dev, const float matrix[9])
+static void _set_matrix_prop(Display *dpy, XDevice *dev, const float 
fmatrix[9])
 {
        Atom matrix_prop = XInternAtom(dpy, "Coordinate Transformation Matrix", 
True);
        Atom type;
        int format;
        unsigned long nitems, bytes_after;
        float *data;
+       long matrix[9] = {0};
+       int i;
 
        if (!matrix_prop)
        {
@@ -1980,6 +1982,11 @@ static void _set_matrix_prop(Display *dpy, XDevice *dev, 
const float matrix[9])
                return;
        }
 
+       /* XI1 expects 32 bit properties (including float) as long,
+        * regardless of architecture */
+       for (i = 0; i < sizeof(matrix)/sizeof(matrix[0]); i++)
+               *(float*)(matrix + i) = fmatrix[i];
+
        XGetDeviceProperty(dpy, dev, matrix_prop, 0, 9, False,
                                AnyPropertyType, &type, &format, &nitems,
                                &bytes_after, (unsigned char**)&data);
-- 
1.7.3.4


------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to