This patch allows the MapToOutput command to accept fully-
specified X geometry strings as valid output names. The
XParseGeometry function describes these strings as having
the folowing format:
[=][<width>{xX}<height>][{+-}<xoffset>{+-}<yoffset>]
Strings with width, height, xoffset, and yoffset defined
will be accepted and the device mapped to the rectangle
it describes.
This patch also renames the function '_set_matrix' to bring
its naming in line with the other set_output_XXXX functions.
Signed-off-by: Jason Gerecke <[email protected]>
---
Changes from v3:
* Corresponds to patch v3 3/7
* Updated man page to describe RandR requirements
* 'MaskIsSet' macro taken care of by patch 1/8
* 'tmp_int' and 'tmp_uint' renamed for more semantic meaning
* Call to 'XParseGeometry' moved outside of if statement condition
* Remove unnesscary braces
man/xsetwacom.man | 18 ++++++++++--------
tools/xsetwacom.c | 27 ++++++++++++++++++---------
2 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/man/xsetwacom.man b/man/xsetwacom.man
index 539f405..9375e5b 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 X11 geometry string of
+the from WIDTHxHEIGHT+X+Y. Users of the NVIDIA binary driver should use the
+output names "HEAD-0" and "HEAD-1" until the driver supports XRandr 1.2 or
+later.
+
+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 2afc106..dea6e99 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1994,12 +1994,13 @@ static void _set_matrix_prop(Display *dpy, XDevice
*dev, const float fmatrix[9])
}
/**
- * Set the matrix for the given device for the screen defined by offset and
- * dimensions.
+ * 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.
*/
-static void _set_matrix(Display *dpy, XDevice *dev,
+static void set_output_area(Display *dpy, XDevice *dev,
int offset_x, int offset_y,
- int screen_width, int screen_height)
+ int output_width, int output_height)
{
int width = DisplayWidth(dpy, DefaultScreen(dpy));
int height = DisplayHeight(dpy, DefaultScreen(dpy));
@@ -2009,8 +2010,8 @@ static void _set_matrix(Display *dpy, XDevice *dev,
float y = 1.0 * offset_y/height;
/* mapping */
- float w = 1.0 * screen_width/width;
- float h = 1.0 * screen_height/height;
+ float w = 1.0 * output_width/width;
+ float h = 1.0 * output_height/height;
float matrix[9] = { 1, 0, 0,
0, 1, 0,
@@ -2020,6 +2021,9 @@ static void _set_matrix(Display *dpy, XDevice *dev,
matrix[0] = w;
matrix[4] = h;
+ TRACE("Remapping to output area %dx%d @ %d,%d.\n", output_width,
+ output_height, offset_x, offset_y);
+
TRACE("Transformation matrix:\n");
TRACE(" [ %f %f %f ]\n", matrix[0], matrix[1], matrix[2]);
TRACE(" [ %f %f %f ]\n", matrix[3], matrix[4], matrix[5]);
@@ -2073,7 +2077,7 @@ static void set_output_xrandr(Display *dpy, XDevice *dev,
char *output_name)
if (found)
{
TRACE("Setting CRTC %s\n", output_name);
- _set_matrix(dpy, dev, x, y, width, height);
+ set_output_area(dpy, dev, x, y, width, height);
} else
printf("Unable to find output '%s'. "
"Output may not be connected.\n", output_name);
@@ -2117,7 +2121,7 @@ static void set_output_xinerama(Display *dpy, XDevice
*dev, int head)
TRACE("Setting xinerama head %d\n", head);
- _set_matrix(dpy, dev,
+ set_output_area(dpy, dev,
screens[head].x_org, screens[head].y_org,
screens[head].width, screens[head].height);
@@ -2128,6 +2132,9 @@ out:
static void set_output(Display *dpy, XDevice *dev, param_t *param, int argc,
char **argv)
{
int head_no;
+ int x, y;
+ unsigned int width, height;
+ int flags = XParseGeometry(argv[0], &x, &y, &width, &height);
if (argc == 0)
{
@@ -2144,7 +2151,9 @@ static void set_output(Display *dpy, XDevice *dev,
param_t *param, int argc, cha
return;
}
- if (!need_xinerama(dpy))
+ if (MaskIsSet(flags, XValue|YValue|WidthValue|HeightValue))
+ set_output_area(dpy, dev, x, y, width, height);
+ else if (!need_xinerama(dpy))
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);
--
1.7.6
------------------------------------------------------------------------------
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