On Tue, Sep 20, 2011 at 03:54:28PM -0700, Jason Gerecke wrote:
> MapToOutput helper functions now return 'true' when they sucessfully
> change the transformation matrix, and 'false' otherwise. Though this
> information is not used at the moment, it will be used with the
> KeepShape patch to ensure that the active area is only modified if
> the output mapping occured sucessfully.
>
> Signed-off-by: Jason Gerecke <[email protected]>
> ---
> Changes from v3:
>
> * Broken out from patch v3 7/7
> * Introduces only the change to return type
>
> tools/xsetwacom.c | 79
> ++++++++++++++++++++++++++++++++++-------------------
> 1 files changed, 51 insertions(+), 28 deletions(-)
>
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index 722e32c..a3998d2 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -2024,7 +2024,13 @@ Bool get_mapped_area(Display *dpy, XDevice *dev, int
> *width, int *height, int *x
> return matrix_is_valid;
> }
>
> -static void _set_matrix_prop(Display *dpy, XDevice *dev, const float
> fmatrix[9])
> +/**
> + * Modifies the server's transformation matrix property for the given
> + * device. It takes as input a 9-element array of floats interpreted
> + * as the row-major 3x3 matrix to be set. If this function succeeds
> + * in modifying the transformation matrix, it returns 'true'.
Should be proper doxygen javadoc style
* @return True if the matrix was successfuly modified or False otherwise.
The same goes for all other functions that now return Bool.
> + */
> +static Bool _set_matrix_prop(Display *dpy, XDevice *dev, const float
> fmatrix[9])
> {
> Atom matrix_prop = XInternAtom(dpy, "Coordinate Transformation Matrix",
> True);
> Atom type;
> @@ -2037,7 +2043,7 @@ static void _set_matrix_prop(Display *dpy, XDevice
> *dev, const float fmatrix[9])
> if (!matrix_prop)
> {
> fprintf(stderr, "Server does not support transformation\n");
> - return;
> + return False;
> }
>
> /* XI1 expects 32 bit properties (including float) as long,
> @@ -2053,21 +2059,24 @@ static void _set_matrix_prop(Display *dpy, XDevice
> *dev, const float fmatrix[9])
> {
> fprintf(stderr, "Property for '%s' has unexpected type - this
> is a bug.\n",
> "Coordinate Transformation Matrix");
> - return;
> + return False;
> }
>
> XChangeDeviceProperty(dpy, dev, matrix_prop, type, format,
> PropModeReplace, (unsigned char*)matrix, 9);
> XFree(data);
> XFlush(dpy);
> +
> + return True;
> }
>
> /**
> * Adjust the transformation matrix based on a user-defined area.
> * This function will attempt to map the given pointer to an arbitrary
> - * rectangular portion of the desktop.
> + * rectangular portion of the desktop. If this function succeeds in
> + * modifying the transformation matrix, it returns 'true'.
> */
> -static void set_output_area(Display *dpy, XDevice *dev,
> +static Bool set_output_area(Display *dpy, XDevice *dev,
> int offset_x, int offset_y,
> int output_width, int output_height)
> {
> @@ -2098,15 +2107,17 @@ static void set_output_area(Display *dpy, XDevice
> *dev,
> TRACE(" [ %f %f %f ]\n", matrix[3], matrix[4], matrix[5]);
> TRACE(" [ %f %f %f ]\n", matrix[6], matrix[7], matrix[8]);
>
> - _set_matrix_prop(dpy, dev, matrix);
> + return _set_matrix_prop(dpy, dev, matrix);
> }
>
> +
> /**
> * Adjust the transformation matrix based on RandR settings. This function
> * will attempt to map the given device to the output with the given RandR
> - * output name.
> + * output name. If this function succeeds in modifying the transformation
> + * matrix, it returns 'true'.
> */
> -static void set_output_xrandr(Display *dpy, XDevice *dev, char *output_name)
> +static Bool set_output_xrandr(Display *dpy, XDevice *dev, char *output_name)
> {
> int i, found = 0;
> int x, y, width, height;
> @@ -2146,33 +2157,38 @@ static void set_output_xrandr(Display *dpy, XDevice
> *dev, char *output_name)
> if (found)
> {
> TRACE("Setting CRTC %s\n", output_name);
> - set_output_area(dpy, dev, x, y, width, height);
> + return set_output_area(dpy, dev, x, y, width, height);
> } else
> + {
> printf("Unable to find output '%s'. "
> "Output may not be connected.\n", output_name);
>
> + return False;
> + }
> }
>
> /**
> * Adjust the transformation matrix based on the Xinerama settings. This
> * function will attempt to map the given device to the specified Xinerama
> - * head number.
> + * head number. If this function succeeds in modifying the transformation
> + * matrix, it returns 'true'.
> *
> * For TwinView This would better be done with libXNVCtrl but until they
> * learn to package it properly, we need to rely on Xinerama. Besides,
> * libXNVCtrl isn't available on RHEL, so we'd have to do it through
> * Xinerama there anyway.
> */
> -static void set_output_xinerama(Display *dpy, XDevice *dev, int head)
> +static Bool set_output_xinerama(Display *dpy, XDevice *dev, int head)
> {
> int event, error;
> XineramaScreenInfo *screens;
> int nscreens;
> + Bool success = False;
>
> if (!XineramaQueryExtension(dpy, &event, &error))
> {
> fprintf(stderr, "Unable to set screen mapping. Xinerama
> extension not found\n");
> - return;
> + return success;
> }
>
> screens = XineramaQueryScreens(dpy, &nscreens);
> @@ -2190,12 +2206,13 @@ static void set_output_xinerama(Display *dpy, XDevice
> *dev, int head)
>
> TRACE("Setting xinerama head %d\n", head);
>
> - set_output_area(dpy, dev,
> + success = set_output_area(dpy, dev,
> screens[head].x_org, screens[head].y_org,
> screens[head].width, screens[head].height);
>
> out:
> XFree(screens);
> + return success;
> }
>
> /**
> @@ -2203,12 +2220,12 @@ out:
> * This function will attempt to map the given device to the entire
> * desktop.
> */
> -static void set_output_desktop(Display *dpy, XDevice *dev)
> +static Bool set_output_desktop(Display *dpy, XDevice *dev)
> {
> int display_width = DisplayWidth(dpy, DefaultScreen(dpy));
> int display_height = DisplayHeight(dpy, DefaultScreen(dpy));
>
> - set_output_area(dpy, dev, 0, 0, display_width, display_height);
> + return set_output_area(dpy, dev, 0, 0, display_width, display_height);
> }
>
> /**
> @@ -2218,7 +2235,7 @@ static void set_output_desktop(Display *dpy, XDevice
> *dev)
> * head, it maps to the first head. If mapped to the last Xinerama
> * head, it maps to the entire desktop.
> */
> -static void set_output_next(Display *dpy, XDevice *dev)
> +static Bool set_output_next(Display *dpy, XDevice *dev)
> {
> XineramaScreenInfo *screens;
> int event, error, nscreens, head;
> @@ -2226,12 +2243,12 @@ static void set_output_next(Display *dpy, XDevice
> *dev)
> Bool success = False;
>
> if (!get_mapped_area(dpy, dev, &width, &height, &x_org, &y_org))
> - return;
> + return success;
>
> if (!XineramaQueryExtension(dpy, &event, &error))
> {
> fprintf(stderr, "Unable to get screen mapping. Xinerama
> extension not found\n");
> - return;
> + return success;
> }
>
> screens = XineramaQueryScreens(dpy, &nscreens);
> @@ -2248,20 +2265,22 @@ static void set_output_next(Display *dpy, XDevice
> *dev)
> if (screens[head].width == width && screens[head].height ==
> height &&
> screens[head].x_org == x_org && screens[head].y_org ==
> y_org)
> {
> - success = True;
> -
> if (head + 1 < nscreens)
> - set_output_xinerama(dpy, dev, head+1);
> + success = set_output_xinerama(dpy, dev, head+1);
> else
> - set_output_desktop(dpy, dev);
> + success = set_output_desktop(dpy, dev);
> +
> + if (!success)
> + goto out;
> }
> }
>
> if (!success)
> - set_output_xinerama(dpy, dev, 0);
> + success = set_output_xinerama(dpy, dev, 0);
>
> out:
> XFree(screens);
> + return success;
> }
>
> static void set_output(Display *dpy, XDevice *dev, param_t *param, int argc,
> char **argv)
> @@ -2270,6 +2289,7 @@ static void set_output(Display *dpy, XDevice *dev,
> param_t *param, int argc, cha
> int x, y;
> unsigned int width, height;
> int flags = XParseGeometry(argv[0], &x, &y, &width, &height);
> + Bool success = False;
>
> if (argc != param->arg_count)
> {
> @@ -2279,17 +2299,20 @@ static void set_output(Display *dpy, XDevice *dev,
> param_t *param, int argc, cha
> }
>
> if (MaskIsSet(flags, XValue|YValue|WidthValue|HeightValue))
> - set_output_area(dpy, dev, x, y, width, height);
> + success = set_output_area(dpy, dev, x, y, width, height);
> else if (strcasecmp(argv[0], "next") == 0)
> - set_output_next(dpy, dev);
> + success = set_output_next(dpy, dev);
> else if (strcasecmp(argv[0], "desktop") == 0)
> - set_output_desktop(dpy, dev);
> + success = set_output_desktop(dpy, dev);
> else if (!need_xinerama(dpy))
> - set_output_xrandr(dpy, dev, argv[0]);
> + success = set_output_xrandr(dpy, dev, argv[0]);
> else if (convert_value_from_user(param, argv[0], &head_no))
> - set_output_xinerama(dpy, dev, head_no);
> + success = set_output_xinerama(dpy, dev, head_no);
> else
> fprintf(stderr, "Unable to find an output '%s'.\n", argv[0]);
> +
> + if (!success)
> + return;
> }
this seems... odd. should have been in the next patch but I don't care
sufficiently now.
Reviewed-by: Peter Hutterer <[email protected]> with the javadoc
changes
Cheers,
Peter
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel