Signed-off-by: Peter Hutterer <[email protected]>
---
man/synaptics.man | 2 ++
src/synaptics.c | 30 ++++++++++++++++++++++++++++--
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/man/synaptics.man b/man/synaptics.man
index 23862e3..864a95f 100644
--- a/man/synaptics.man
+++ b/man/synaptics.man
@@ -526,6 +526,8 @@ parameters define the area of the right button, and the
second four parameters
define the area of the middle button. The areas are defined by the left, right,
top, and bottom edges as sequential values of the property. If any edge is set
to 0, the button is assumed to extend to infinity in the given direction.
+Any of the values may be given as percentage of the touchpad width or
+height, whichever applies.
.
When the user performs a click within the defined soft button areas, the right
or middle click action is performed.
diff --git a/src/synaptics.c b/src/synaptics.c
index 09afb7c..ef9d396 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -511,10 +511,12 @@ static void set_softbutton_areas_option(InputInfoPtr
pInfo)
SynapticsPrivate *priv = pInfo->private;
SynapticsParameters *pars = &priv->synpara;
int values[8];
+ int in_percent = 0; /* bitmask for which ones are in % */
char *option_string;
char *next_num;
char *end_str;
int i;
+ int width, height;
if (!pars->clickpad)
return;
@@ -534,12 +536,36 @@ static void set_softbutton_areas_option(InputInfoPtr
pInfo)
values[i] = value;
if (next_num != end_str)
+ {
+ if (end_str && *end_str == '%')
+ {
+ in_percent |= 1 << i;
+ end_str++;
+ }
next_num = end_str;
- else
+ } else
goto fail;
}
- if (i < 8 || *next_num != '\0' || !SynapticsIsSoftButtonAreasValid(values))
+ if (i < 8 || *next_num != '\0')
+ goto fail;
+
+ width = priv->maxx - priv->minx;
+ height = priv->maxy - priv->miny;
+
+ for (i = 0; in_percent && i < 8; i++)
+ {
+ int base, size;
+
+ if ((in_percent & (1 << i)) == 0 || values[i] == 0)
+ continue;
+
+ size = ((i % 4) < 2) ? width : height;
+ base = ((i % 4) < 2) ? priv->minx : priv->miny;
+ values[i] = base + size * values[i]/100.0;
+ }
+
+ if (!SynapticsIsSoftButtonAreasValid(values))
goto fail;
memcpy(pars->softbutton_areas[0], values, 4 * sizeof(int));
--
1.7.7.6
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel