Allow soft button areas to be specified in % of the touchpad

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
Peter Hutterer
2012-03-14 16:47:26 +10:00
parent b3348eb7e4
commit cea97dd5e0
2 changed files with 30 additions and 2 deletions

View File

@@ -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.

View File

@@ -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));