On Sun, Aug 21, 2011 at 11:41 PM, Peter Hutterer
<peter.hutte...@who-t.net> wrote:
> On Fri, Aug 19, 2011 at 05:23:54PM -0700, Jason Gerecke wrote:
>> This patch adds a function 'set_output_area' which attempts to parse
>> the commandline argument as a tring of the form "WIDTHxHEIGHT@X,Y".
>> If it succeeds, the transformation matrix will be set appropriately.
>> ---
>> Changes from v1:
>>  * Add man page entry
>>  * Document the function
>>
>>  man/xsetwacom.man |   18 ++++++++++--------
>>  tools/xsetwacom.c |   30 ++++++++++++++++++++++++++++--
>>  2 files changed, 38 insertions(+), 10 deletions(-)
>>
>> diff --git a/man/xsetwacom.man b/man/xsetwacom.man
>> index 539f405..68599b8 100644
>> --- a/man/xsetwacom.man
>> +++ b/man/xsetwacom.man
>> @@ -120,16 +120,18 @@ device is unbound and will react to any tool of the 
>> matching type.
>>  Default: 0
>>  .TP
>>  \fBMapToOutput\fR [output]
>> -Map the tablet's input area to the given output (e.g. "VGA1"). The output
>> -must specify one of those available through the XRandR extension. A list of
>> -outputs may be obtained with the xrandr tool. If no output is provided,
>> -the tablet is mapped to the entire desktop. The output mapping
>> -configuration is a onetime setting and does not track output
>> +Map the tablet's input area to the given output (e.g. "VGA1"), or the entire
>> +desktop if no output is provided. Output names may either be the name of
>> +a head available through the XRandR extension, or an defined area of the
>> +desktop with the form WIDTHxHEIGHT@X,Y. Users of the NVIDIA binary driver
>> +should use the output names "HEAD-0" and "HEAD-1" until proper XRandR 
>> support
>> +is included.
>> +
>> +The output mapping configuration is a onetime setting and does not track 
>> output
>>  reconfigurations; the command needs to be re-run whenever the output
>>  configuration changes. When used with tablet rotation, the tablet must be
>> -rotated before it is mapped to the new screen. When running the NVIDIA
>> -binary driver, the output names are "HEAD-0" and "HEAD-1".
>> -This parameter is write-only and cannot be queried.
>> +rotated before it is mapped to the new screen. This parameter is write-only
>> +and cannot be queried.
>>  .TP
>>  \fBMode\fR Absolute|Relative
>>  Set the device mode as either Relative or Absolute. Relative means pointer
>> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
>> index ffb2875..5a3e791 100644
>> --- a/tools/xsetwacom.c
>> +++ b/tools/xsetwacom.c
>> @@ -2152,6 +2152,31 @@ out:
>>       return success;
>>  }
>>
>> +/**
>> + * Adjust the transformation matrix based on a user-defined area.
>> + * This function will attempt to map the given pointer to the area defined
>> + * in the first command-line argument (which should be formatted as
>> + * 'WIDTHxHEIGHT@X,Y'). If this function succeeds in modifying the
>> + * transformation matrix, it returns 'true'.
>> + */
>> +static Bool set_output_area(Display *dpy, XDevice *dev, param_t *param, int 
>> argc, char **argv)
>> +{
>> +     int width, height, xorig, yorig;
>> +
>> +     if (sscanf(argv[0], "%dx%d@%d,%d", &width, &height, &xorig, &yorig) == 
>> 4)
>> +     {
>> +             fprintf(stderr, "Remapping to output area obtained via 
>> parsing.\n", argv[0]);
>> +             _set_matrix(dpy, dev, xorig, yorig, width, height);
>> +             return True;
>> +     }
>> +     else
>> +     {
>> +             TRACE("Unable to parse '%s' as a string of format 
>> WIDTHxHEIGHT@X,Y.\n", argv[0]);
>
> shouldn't this be the fprintf(stderr) and the hunk above the TRACE?
> this has the same problem as the 4/9 patch that TRACEs all the errors but
> stderrs all the debugging information. I really don't think that's a good
> idea.
>
> also, on that note, it might be worth replacing the fprintf(stderr), with a
> ERROR macro or function.
>
> Cheers,
>  Peter
>
I'm still hesitant to have it blurt out two or three "errors" followed
by a single success. Even though they're non-fatal, if I saw that kind
of output I'd be wondering just how successful it has really been.

Hopefully I can get a parser working so that only one function is ever
called, and this will be a non-issue.

Jason

---
Day xee-nee-svsh duu-'ushtlh-ts'it;
nuu-wee-ya' duu-xan' 'vm-nvshtlh-ts'it.
Huu-chan xuu naa~-gha.


>> +     }
>> +
>> +     return False;
>> +}
>> +
>>  static void set_output(Display *dpy, XDevice *dev, param_t *param, int 
>> argc, char **argv)
>>  {
>>       if (argc == 0)
>> @@ -2169,8 +2194,9 @@ static void set_output(Display *dpy, XDevice *dev, 
>> param_t *param, int argc, cha
>>               return;
>>       }
>>
>> -     if (!set_output_xinerama(dpy, dev, param, argc, argv))
>> -             set_output_xrandr(dpy, dev, param, argc, argv);
>> +     if (!set_output_area(dpy, dev, param, argc, argv))
>> +             if (!set_output_xinerama(dpy, dev, param, argc, argv))
>> +                     set_output_xrandr(dpy, dev, param, argc, argv);
>>  }
>>
>>
>> --
>> 1.7.6
>

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to