summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-03-14 16:47:26 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-03-22 14:51:10 +1000
commitcea97dd5e09b165c2a4b2bbbb5741a03f152ed37 (patch)
treeb39106bdeaa6216376c1d6c6a57bb5cd84835521 /src
parentb3348eb7e4e2187e11aa3c1cec2a58512759e6aa (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/synaptics.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/synaptics.c b/src/synaptics.c
index 3c5b12d..789de81 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));