Re: [Linuxwacom-devel] [PATCH] Export current tool ID in the property too

2012-02-29 Thread Peter Hutterer
On Wed, Feb 29, 2012 at 04:09:13PM -0800, Jason Gerecke wrote:
> On Tue, Feb 21, 2012 at 10:54 PM, Peter Hutterer
>  wrote:
> > Previously, we exported old serial number, old tool ID and current serial
> > number. Export the current tool ID as well.
> >
> > Signed-off-by: Peter Hutterer 
> > ---
> >  include/wacom-properties.h |    6 --
> >  src/wcmCommon.c            |    6 +++---
> >  src/wcmXCommand.c          |   16 ++--
> >  src/xf86Wacom.h            |    2 +-
> >  src/xf86WacomDefs.h        |    1 +
> >  5 files changed, 19 insertions(+), 12 deletions(-)
> >
> > diff --git a/include/wacom-properties.h b/include/wacom-properties.h
> > index 0bb84b1..2bb86ab 100644
> > --- a/include/wacom-properties.h
> > +++ b/include/wacom-properties.h
> > @@ -33,8 +33,10 @@
> >  /* 32 bit, 4 values */
> >  #define WACOM_PROP_PRESSURECURVE "Wacom Pressurecurve"
> >
> > -/* CARD32, 4 values, tablet id, old serial, old hw device id, current 
> > serial
> > -   read-only */
> > +/* CARD32, 4 values, tablet id, old serial, old hw device id,
> Should be 5 values, not 4

fixed

> 
> > +   current serial, current device id
> > +   read-only
> > + */
> >  #define WACOM_PROP_SERIALIDS "Wacom Serial IDs"
> >
> >  /* CARD32, 1 value */
> > diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> > index 11340ea..65b0390 100644
> > --- a/src/wcmCommon.c
> > +++ b/src/wcmCommon.c
> > @@ -730,8 +730,8 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> > WacomDeviceState* ds)
> >                return;
> >        }
> >
> > -       if (priv->cur_serial != serial)
> > -               wcmUpdateSerial(pInfo, serial);
> > +       if (priv->cur_serial != serial || priv->cur_device_id != id)
> > +               wcmUpdateSerial(pInfo, serial, id);
> >
> >        /* don't move the cursor when going out-prox */
> >        if (!ds->proximity)
> > @@ -833,7 +833,7 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> > WacomDeviceState* ds)
> >                priv->devReverseCount = 0;
> >                priv->old_serial = serial;
> >                priv->old_device_id = id;
> > -               wcmUpdateSerial(pInfo, 0);
> > +               wcmUpdateSerial(pInfo, 0, 0);
> >        }
> >  }
> >
> > diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
> > index 0fd5664..57b3f20 100644
> > --- a/src/wcmXCommand.c
> > +++ b/src/wcmXCommand.c
> > @@ -190,7 +190,8 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
> >        values[1] = priv->old_serial;
> >        values[2] = priv->old_device_id;
> >        values[3] = priv->cur_serial;
> > -       prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 
> > XA_INTEGER, 32, 4, values);
> > +       values[4] = priv->cur_device_id;
> > +       prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 
> > XA_INTEGER, 32, 5, values);
> >
> >        values[0] = priv->serial;
> >        prop_serial_binding = InitWcmAtom(pInfo->dev, 
> > WACOM_PROP_SERIAL_BIND, XA_INTEGER, 32, 1, values);
> > @@ -718,7 +719,7 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, 
> > XIPropertyValuePtr prop,
> >                 * set it at runtime. If we get here from wcmUpdateSerial,
> >                 * we know the serial has ben set internally already, so we
> >                 * can reply with success. */
> > -               if (prop->size == 4 && prop->format == 32)
> > +               if (prop->size == 5 && prop->format == 32)
> >                        if (((CARD32*)prop->data)[3] == priv->cur_serial)
> >                                return Success;
> >
> > @@ -875,11 +876,12 @@ int wcmGetProperty (DeviceIntPtr dev, Atom property)
> >                values[1] = priv->old_serial;
> >                values[2] = priv->old_device_id;
> >                values[3] = priv->cur_serial;
> > +               values[4] = priv->cur_device_id;
> >
> >                DBG(10, priv, "Update to serial: %d\n", priv->old_serial);
> >
> >                return XIChangeDeviceProperty(dev, property, XA_INTEGER, 32,
> > -                                             PropModeReplace, 4,
> > +                                             PropModeReplace, 5,
> >                                              values, FALSE);
> >        }
> >
> > @@ -892,14 +894,14 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer 
> > arg)
> >        InputInfoPtr pInfo = arg;
> >        WacomDevicePtr priv = pInfo->private;
> >        XIPropertyValuePtr prop;
> > -       CARD32 prop_value[4];
> > +       CARD32 prop_value[5];
> >        int sigstate;
> >        int rc;
> >
> >        sigstate = xf86BlockSIGIO();
> >
> >        rc = XIGetDeviceProperty(pInfo->dev, prop_serials, &prop);
> > -       if (rc != Success || prop->format != 32 || prop->size != 4)
> > +       if (rc != Success || prop->format != 32 || prop->size != 5)
> >        {
> >                xf86Msg(X_ERROR, "%s: Failed to update serial number.\n",
> >                        pInfo->name);
> > @@ -908,6 +910,7 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer 
> > ar

Re: [Linuxwacom-devel] [PATCH] Export current tool ID in the property too

2012-02-29 Thread Jason Gerecke
On Tue, Feb 21, 2012 at 10:54 PM, Peter Hutterer
 wrote:
> Previously, we exported old serial number, old tool ID and current serial
> number. Export the current tool ID as well.
>
> Signed-off-by: Peter Hutterer 
> ---
>  include/wacom-properties.h |    6 --
>  src/wcmCommon.c            |    6 +++---
>  src/wcmXCommand.c          |   16 ++--
>  src/xf86Wacom.h            |    2 +-
>  src/xf86WacomDefs.h        |    1 +
>  5 files changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/include/wacom-properties.h b/include/wacom-properties.h
> index 0bb84b1..2bb86ab 100644
> --- a/include/wacom-properties.h
> +++ b/include/wacom-properties.h
> @@ -33,8 +33,10 @@
>  /* 32 bit, 4 values */
>  #define WACOM_PROP_PRESSURECURVE "Wacom Pressurecurve"
>
> -/* CARD32, 4 values, tablet id, old serial, old hw device id, current serial
> -   read-only */
> +/* CARD32, 4 values, tablet id, old serial, old hw device id,
Should be 5 values, not 4

> +   current serial, current device id
> +   read-only
> + */
>  #define WACOM_PROP_SERIALIDS "Wacom Serial IDs"
>
>  /* CARD32, 1 value */
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 11340ea..65b0390 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -730,8 +730,8 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds)
>                return;
>        }
>
> -       if (priv->cur_serial != serial)
> -               wcmUpdateSerial(pInfo, serial);
> +       if (priv->cur_serial != serial || priv->cur_device_id != id)
> +               wcmUpdateSerial(pInfo, serial, id);
>
>        /* don't move the cursor when going out-prox */
>        if (!ds->proximity)
> @@ -833,7 +833,7 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds)
>                priv->devReverseCount = 0;
>                priv->old_serial = serial;
>                priv->old_device_id = id;
> -               wcmUpdateSerial(pInfo, 0);
> +               wcmUpdateSerial(pInfo, 0, 0);
>        }
>  }
>
> diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
> index 0fd5664..57b3f20 100644
> --- a/src/wcmXCommand.c
> +++ b/src/wcmXCommand.c
> @@ -190,7 +190,8 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
>        values[1] = priv->old_serial;
>        values[2] = priv->old_device_id;
>        values[3] = priv->cur_serial;
> -       prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 
> XA_INTEGER, 32, 4, values);
> +       values[4] = priv->cur_device_id;
> +       prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 
> XA_INTEGER, 32, 5, values);
>
>        values[0] = priv->serial;
>        prop_serial_binding = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIAL_BIND, 
> XA_INTEGER, 32, 1, values);
> @@ -718,7 +719,7 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, 
> XIPropertyValuePtr prop,
>                 * set it at runtime. If we get here from wcmUpdateSerial,
>                 * we know the serial has ben set internally already, so we
>                 * can reply with success. */
> -               if (prop->size == 4 && prop->format == 32)
> +               if (prop->size == 5 && prop->format == 32)
>                        if (((CARD32*)prop->data)[3] == priv->cur_serial)
>                                return Success;
>
> @@ -875,11 +876,12 @@ int wcmGetProperty (DeviceIntPtr dev, Atom property)
>                values[1] = priv->old_serial;
>                values[2] = priv->old_device_id;
>                values[3] = priv->cur_serial;
> +               values[4] = priv->cur_device_id;
>
>                DBG(10, priv, "Update to serial: %d\n", priv->old_serial);
>
>                return XIChangeDeviceProperty(dev, property, XA_INTEGER, 32,
> -                                             PropModeReplace, 4,
> +                                             PropModeReplace, 5,
>                                              values, FALSE);
>        }
>
> @@ -892,14 +894,14 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer 
> arg)
>        InputInfoPtr pInfo = arg;
>        WacomDevicePtr priv = pInfo->private;
>        XIPropertyValuePtr prop;
> -       CARD32 prop_value[4];
> +       CARD32 prop_value[5];
>        int sigstate;
>        int rc;
>
>        sigstate = xf86BlockSIGIO();
>
>        rc = XIGetDeviceProperty(pInfo->dev, prop_serials, &prop);
> -       if (rc != Success || prop->format != 32 || prop->size != 4)
> +       if (rc != Success || prop->format != 32 || prop->size != 5)
>        {
>                xf86Msg(X_ERROR, "%s: Failed to update serial number.\n",
>                        pInfo->name);
> @@ -908,6 +910,7 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
>
>        memcpy(prop_value, prop->data, sizeof(prop_value));
>        prop_value[3] = priv->cur_serial;
> +       prop_value[4] = priv->cur_device_id;
>
>        XIChangeDeviceProperty(pInfo->dev, prop_serials, XA_INTEGER,
>                               prop->format, PropModeReplace,
> @@ -919,7 +922,7 @@ serial

Re: [Linuxwacom-devel] [PATCH] Export current tool ID in the property too

2012-02-22 Thread Chris Bagwell
I believe I get it.  I was thinking about advertising the old value
change but this instead looks like it advertises missing device ID
change which indirectly covers all the cases were old values need
updating... and old values only get updated on demand.

Reviewed-by: Chris Bagwell 


On Wed, Feb 22, 2012 at 12:54 AM, Peter Hutterer
 wrote:
> Previously, we exported old serial number, old tool ID and current serial
> number. Export the current tool ID as well.
>
> Signed-off-by: Peter Hutterer 
> ---
>  include/wacom-properties.h |    6 --
>  src/wcmCommon.c            |    6 +++---
>  src/wcmXCommand.c          |   16 ++--
>  src/xf86Wacom.h            |    2 +-
>  src/xf86WacomDefs.h        |    1 +
>  5 files changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/include/wacom-properties.h b/include/wacom-properties.h
> index 0bb84b1..2bb86ab 100644
> --- a/include/wacom-properties.h
> +++ b/include/wacom-properties.h
> @@ -33,8 +33,10 @@
>  /* 32 bit, 4 values */
>  #define WACOM_PROP_PRESSURECURVE "Wacom Pressurecurve"
>
> -/* CARD32, 4 values, tablet id, old serial, old hw device id, current serial
> -   read-only */
> +/* CARD32, 4 values, tablet id, old serial, old hw device id,
> +   current serial, current device id
> +   read-only
> + */
>  #define WACOM_PROP_SERIALIDS "Wacom Serial IDs"
>
>  /* CARD32, 1 value */
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 11340ea..65b0390 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -730,8 +730,8 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds)
>                return;
>        }
>
> -       if (priv->cur_serial != serial)
> -               wcmUpdateSerial(pInfo, serial);
> +       if (priv->cur_serial != serial || priv->cur_device_id != id)
> +               wcmUpdateSerial(pInfo, serial, id);
>
>        /* don't move the cursor when going out-prox */
>        if (!ds->proximity)
> @@ -833,7 +833,7 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds)
>                priv->devReverseCount = 0;
>                priv->old_serial = serial;
>                priv->old_device_id = id;
> -               wcmUpdateSerial(pInfo, 0);
> +               wcmUpdateSerial(pInfo, 0, 0);
>        }
>  }
>
> diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
> index 0fd5664..57b3f20 100644
> --- a/src/wcmXCommand.c
> +++ b/src/wcmXCommand.c
> @@ -190,7 +190,8 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
>        values[1] = priv->old_serial;
>        values[2] = priv->old_device_id;
>        values[3] = priv->cur_serial;
> -       prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 
> XA_INTEGER, 32, 4, values);
> +       values[4] = priv->cur_device_id;
> +       prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 
> XA_INTEGER, 32, 5, values);
>
>        values[0] = priv->serial;
>        prop_serial_binding = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIAL_BIND, 
> XA_INTEGER, 32, 1, values);
> @@ -718,7 +719,7 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, 
> XIPropertyValuePtr prop,
>                 * set it at runtime. If we get here from wcmUpdateSerial,
>                 * we know the serial has ben set internally already, so we
>                 * can reply with success. */
> -               if (prop->size == 4 && prop->format == 32)
> +               if (prop->size == 5 && prop->format == 32)
>                        if (((CARD32*)prop->data)[3] == priv->cur_serial)
>                                return Success;
>
> @@ -875,11 +876,12 @@ int wcmGetProperty (DeviceIntPtr dev, Atom property)
>                values[1] = priv->old_serial;
>                values[2] = priv->old_device_id;
>                values[3] = priv->cur_serial;
> +               values[4] = priv->cur_device_id;
>
>                DBG(10, priv, "Update to serial: %d\n", priv->old_serial);
>
>                return XIChangeDeviceProperty(dev, property, XA_INTEGER, 32,
> -                                             PropModeReplace, 4,
> +                                             PropModeReplace, 5,
>                                              values, FALSE);
>        }
>
> @@ -892,14 +894,14 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer 
> arg)
>        InputInfoPtr pInfo = arg;
>        WacomDevicePtr priv = pInfo->private;
>        XIPropertyValuePtr prop;
> -       CARD32 prop_value[4];
> +       CARD32 prop_value[5];
>        int sigstate;
>        int rc;
>
>        sigstate = xf86BlockSIGIO();
>
>        rc = XIGetDeviceProperty(pInfo->dev, prop_serials, &prop);
> -       if (rc != Success || prop->format != 32 || prop->size != 4)
> +       if (rc != Success || prop->format != 32 || prop->size != 5)
>        {
>                xf86Msg(X_ERROR, "%s: Failed to update serial number.\n",
>                        pInfo->name);
> @@ -908,6 +910,7 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
>
>        memcpy(prop_value, prop->data, sizeof(prop_va

Re: [Linuxwacom-devel] [PATCH] Export current tool ID in the property too

2012-02-22 Thread Bastien Nocera
Em Wed, 2012-02-22 às 16:54 +1000, Peter Hutterer escreveu:
> Previously, we exported old serial number, old tool ID and current serial
> number. Export the current tool ID as well.

Just what I needed. I changed the code in gnome-settings-daemon and
gnome-control-center to check for the current tool ID before the old
one, and the panel switches styli as needed.

Tested-by: Bastien Nocera 

Cheers


--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


[Linuxwacom-devel] [PATCH] Export current tool ID in the property too

2012-02-21 Thread Peter Hutterer
Previously, we exported old serial number, old tool ID and current serial
number. Export the current tool ID as well.

Signed-off-by: Peter Hutterer 
---
 include/wacom-properties.h |6 --
 src/wcmCommon.c|6 +++---
 src/wcmXCommand.c  |   16 ++--
 src/xf86Wacom.h|2 +-
 src/xf86WacomDefs.h|1 +
 5 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/include/wacom-properties.h b/include/wacom-properties.h
index 0bb84b1..2bb86ab 100644
--- a/include/wacom-properties.h
+++ b/include/wacom-properties.h
@@ -33,8 +33,10 @@
 /* 32 bit, 4 values */
 #define WACOM_PROP_PRESSURECURVE "Wacom Pressurecurve"
 
-/* CARD32, 4 values, tablet id, old serial, old hw device id, current serial
-   read-only */
+/* CARD32, 4 values, tablet id, old serial, old hw device id,
+   current serial, current device id
+   read-only
+ */
 #define WACOM_PROP_SERIALIDS "Wacom Serial IDs"
 
 /* CARD32, 1 value */
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 11340ea..65b0390 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -730,8 +730,8 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds)
return;
}
 
-   if (priv->cur_serial != serial)
-   wcmUpdateSerial(pInfo, serial);
+   if (priv->cur_serial != serial || priv->cur_device_id != id)
+   wcmUpdateSerial(pInfo, serial, id);
 
/* don't move the cursor when going out-prox */
if (!ds->proximity)
@@ -833,7 +833,7 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds)
priv->devReverseCount = 0;
priv->old_serial = serial;
priv->old_device_id = id;
-   wcmUpdateSerial(pInfo, 0);
+   wcmUpdateSerial(pInfo, 0, 0);
}
 }
 
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index 0fd5664..57b3f20 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -190,7 +190,8 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
values[1] = priv->old_serial;
values[2] = priv->old_device_id;
values[3] = priv->cur_serial;
-   prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 
XA_INTEGER, 32, 4, values);
+   values[4] = priv->cur_device_id;
+   prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 
XA_INTEGER, 32, 5, values);
 
values[0] = priv->serial;
prop_serial_binding = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIAL_BIND, 
XA_INTEGER, 32, 1, values);
@@ -718,7 +719,7 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, 
XIPropertyValuePtr prop,
 * set it at runtime. If we get here from wcmUpdateSerial,
 * we know the serial has ben set internally already, so we
 * can reply with success. */
-   if (prop->size == 4 && prop->format == 32)
+   if (prop->size == 5 && prop->format == 32)
if (((CARD32*)prop->data)[3] == priv->cur_serial)
return Success;
 
@@ -875,11 +876,12 @@ int wcmGetProperty (DeviceIntPtr dev, Atom property)
values[1] = priv->old_serial;
values[2] = priv->old_device_id;
values[3] = priv->cur_serial;
+   values[4] = priv->cur_device_id;
 
DBG(10, priv, "Update to serial: %d\n", priv->old_serial);
 
return XIChangeDeviceProperty(dev, property, XA_INTEGER, 32,
- PropModeReplace, 4,
+ PropModeReplace, 5,
  values, FALSE);
}
 
@@ -892,14 +894,14 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
InputInfoPtr pInfo = arg;
WacomDevicePtr priv = pInfo->private;
XIPropertyValuePtr prop;
-   CARD32 prop_value[4];
+   CARD32 prop_value[5];
int sigstate;
int rc;
 
sigstate = xf86BlockSIGIO();
 
rc = XIGetDeviceProperty(pInfo->dev, prop_serials, &prop);
-   if (rc != Success || prop->format != 32 || prop->size != 4)
+   if (rc != Success || prop->format != 32 || prop->size != 5)
{
xf86Msg(X_ERROR, "%s: Failed to update serial number.\n",
pInfo->name);
@@ -908,6 +910,7 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
 
memcpy(prop_value, prop->data, sizeof(prop_value));
prop_value[3] = priv->cur_serial;
+   prop_value[4] = priv->cur_device_id;
 
XIChangeDeviceProperty(pInfo->dev, prop_serials, XA_INTEGER,
   prop->format, PropModeReplace,
@@ -919,7 +922,7 @@ serialTimerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
 }
 
 void
-wcmUpdateSerial(InputInfoPtr pInfo, unsigned int serial)
+wcmUpdateSerial(InputInfoPtr pInfo, unsigned int serial, int id)
 {
WacomDevicePtr priv = pInfo->private;
 
@@ -927,6 +930,7 @@ wcm