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]);
+       }
+
+       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


------------------------------------------------------------------------------
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-d2d-2
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to