On Thu, Feb 23, 2012 at 01:26:24AM +0100, Chase Douglas wrote:
> On 02/21/2012 02:57 AM, Peter Hutterer wrote:
> >Signed-off-by: Peter Hutterer<[email protected]>
> >---
> >  src/property.c |   32 ++++++++++++++++++++++++++++++--
> >  1 files changed, 30 insertions(+), 2 deletions(-)
> >
> >diff --git a/src/property.c b/src/property.c
> >index 7723445..3ab2cb0 100644
> >--- a/src/property.c
> >+++ b/src/property.c
> >@@ -97,6 +97,20 @@ print_property(Display *dpy, XDevice* dev, Atom property)
> >                              break;
> >                      }
> >                      break;
> >+                case XA_CARDINAL:
> >+                    switch(act_format)
> >+                    {
> >+                        case 8:
> >+                            printf("%u", *((unsigned char*)ptr));
> >+                            break;
> >+                        case 16:
> >+                            printf("%u", *((unsigned short*)ptr));
> >+                            break;
> >+                        case 32:
> >+                            printf("%lu", *((unsigned long*)ptr));
> 
> I think a comment here would help, even if it's just "This really
> isn't a bug, 32 format properties are 64-bits on 64-bit machines!"
> Super ugly...

>From XChangeProperty(3):
    If the returned format is 32, the property data will be stored as an
    array of longs (which in a 64-bit application will be 64-bit values that
    are padded in the upper 4 bytes).

I think this should be documentation enough, it's explicitly documented in
the API.

> >+                            break;
> >+                    }
> >+                    break;
> >                  case XA_STRING:
> >                      if (act_format != 8)
> >                      {
> >@@ -353,7 +367,7 @@ do_set_prop_xi1(Display *dpy, Atom type, int format, int 
> >argc, char **argv, char
> >
> >      for (i = 0; i<  nelements; i++)
> >      {
> >-        if (type == XA_INTEGER) {
> >+        if (type == XA_INTEGER || type == XA_CARDINAL) {
> >              switch (format)
> >              {
> >                  case 8:
> >@@ -443,6 +457,20 @@ print_property_xi2(Display *dpy, int deviceid, Atom 
> >property)
> >                              break;
> >                      }
> >                      break;
> >+                case XA_CARDINAL:
> >+                    switch(act_format)
> >+                    {
> >+                        case 8:
> >+                            printf("%u", *((uint8_t*)ptr));
> >+                            break;
> >+                        case 16:
> >+                            printf("%u", *((uint16_t*)ptr));
> >+                            break;
> >+                        case 32:
> >+                            printf("%u", *((uint32_t*)ptr));
> >+                            break;
> >+                    }
> >+                    break;
> >                  case XA_STRING:
> >                      if (act_format != 8)
> >                      {
> >@@ -626,7 +654,7 @@ do_set_prop_xi2(Display *dpy, Atom type, int format, int 
> >argc, char **argv, char
> >
> >      for (i = 0; i<  nelements; i++)
> >      {
> >-        if (type == XA_INTEGER) {
> >+        if (type == XA_INTEGER || type == XA_CARDINAL) {
> >              switch (format)
> >              {
> >                  case 8:
> 
> Otherwise,
> 
> Reviewed-by: Chase Douglas <[email protected]>

Thanks.

Cheers,
  Peter
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to