mirror of
https://github.com/X11Libre/xf86-input-synaptics.git
synced 2026-04-14 11:54:16 +00:00
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:
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user