On Wed, Aug 10, 2011 at 6:51 PM, Peter Hutterer
<peter.hutte...@who-t.net> wrote:
> On Tue, Aug 09, 2011 at 05:50:13PM -0700, Jason Gerecke wrote:
>> Things get confusing when one helper function reports that it
>> couldn't find an output, but the next doesn't report success.
>> This change moves most of the output from the helper functions
>> into TRACE() calls that can be investigated if need be, and
>> adds a fallthrough failure message to 'set_output'.
>>
>> For informational purposes, the helper functions now also
>> directly report to the user if it has succeeded in obtaining
>> the information necessary to remap the output (with an indication of
>> just what extension was responsible).
>> ---
>>  tools/xsetwacom.c |   26 ++++++++++++--------------
>>  1 files changed, 12 insertions(+), 14 deletions(-)
>>
>> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
>> index 2e7f3f2..dbfe4b6 100644
>> --- a/tools/xsetwacom.c
>> +++ b/tools/xsetwacom.c
>> @@ -2056,18 +2056,16 @@ static Bool set_output_xrandr(Display *dpy, XDevice 
>> *dev, param_t *param, int ar
>>       /* crtc holds our screen info, need to compare to actual screen size */
>>       if (found)
>>       {
>> -             TRACE("Setting CRTC %s\n", output_name);
>> +             fprintf(stderr, "Remapping to output area obtained via 
>> RandR.\n", output_name);
>>               _set_matrix(dpy, dev, crtc_info->x, crtc_info->y,
>>                           crtc_info->width, crtc_info->height);
>>
>>               return True;
>>       } else
>> -     {
>> -             printf("Unable to find output '%s'. "
>> +             TRACE("Unable to find output '%s' through RandR. "
>>                       "Output may not be connected.\n", output_name);
>
> whoah. this seems the wrong way round, reporting success but not reporting
> error. Convention in most cmdline tools is to be quiet on success and
> complain when something goes wrong.
>
> in this case, I'd have to run xsetacom once to get a nondescript error
> message ("Unable to map tablet output...") and then run again with -v to
> figure out what is actually going wrong.
>

That's a good point. Though, I'm not sure how to better handle it.
Since the errors are non-fatal unless all handlers fail, its a little
difficult to get a good error message. We could print out "The
parameter 'SAMPLE' could not be understood as an RandR screen, a
Xinerama head, or a desktop region." but that seems needlessly verbose
while still not providing much information.

I'm open to ideas though :)

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;
>> -     }
>> +     return False;
>>  }
>>
>>  /**
>> @@ -2086,14 +2084,14 @@ static Bool set_output_xinerama(Display *dpy, 
>> XDevice *dev, param_t *param, int
>>
>>       if (!XineramaQueryExtension(dpy, &event, &error))
>>       {
>> -             fprintf(stderr, "Unable to set screen mapping. Xinerama 
>> extension not found\n");
>> +             TRACE("Xinerama extension not found.\n");
>>               return False;
>>       }
>>
>>       if (!convert_value_from_user(param, argv[0], &head))
>>       {
>> -             fprintf(stderr, "Please specify the output name as HEAD-X,"
>> -                             "where X is the screen number\n");
>> +             TRACE("Please specify the output name as HEAD-X, "
>> +                             "where X is the screen number.\n");
>>               return False;
>>       }
>>
>> @@ -2101,17 +2099,16 @@ static Bool set_output_xinerama(Display *dpy, 
>> XDevice *dev, param_t *param, int
>>
>>       if (nscreens == 0)
>>       {
>> -             fprintf(stderr, "Xinerama failed to query screens.\n");
>> +             TRACE("Failed to query screens through Xinerama.\n");
>>               goto out;
>>       } else if (nscreens <= head)
>>       {
>> -             fprintf(stderr, "Found %d screens, but you requested %s.\n",
>> -                             nscreens, argv[0]);
>> +             TRACE("You requested %s, but Xinerama only found %d 
>> screens.\n",
>> +                             argv[0], nscreens);
>>               goto out;
>>       }
>>
>> -     TRACE("Setting xinerama head %d\n", head);
>> -
>> +     fprintf(stderr, "Remapping to output area obtained via Xinerama.\n", 
>> argv[0]);
>>       _set_matrix(dpy, dev,
>>                   screens[head].x_org, screens[head].y_org,
>>                   screens[head].width, screens[head].height);
>> @@ -2160,7 +2157,8 @@ static void set_output(Display *dpy, XDevice *dev, 
>> param_t *param, int argc, cha
>>
>>       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);
>> +                     if (!set_output_xrandr(dpy, dev, param, argc, argv))
>> +                             fprintf(stderr, "Unable to map tablet to 
>> output '%s'.\n", argv);
>>  }
>>
>>
>> --
>> 1.7.5.2
>

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
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