[PATCH synaptics 07/11] Support percent values for area.
Peter Hutterer
peter.hutterer at who-t.net
Tue Jun 15 17:21:24 PDT 2010
AreaTopEdge and the other three can be specified as either an absolute
value, or as a percent of the matching dimension.
Option "AreaBottomEdge" "80%" will thus set the bottom edge of the input
area to 80% of the height of the touchpad, with the lower 20% being the dead
area.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
man/synaptics.man | 16 ++++++++++++----
src/synaptics.c | 35 +++++++++++++++++++++++++++++++----
2 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/man/synaptics.man b/man/synaptics.man
index f201230..328d853 100644
--- a/man/synaptics.man
+++ b/man/synaptics.man
@@ -458,28 +458,36 @@ Property: "Synaptics Pad Resolution"
Ignore movements, scrolling and tapping which take place left of this edge.
.
The option is disabled by default and can be enabled by setting the
-AreaLeftEdge option to any integer value other than zero. Property: "Synaptics Area"
+AreaLeftEdge option to any integer value other than zero. If supported by the
+server (version 1.9 and later), the edge may be specified in percent of
+the total width of the touchpad. Property: "Synaptics Area"
.
.TP
.BI "Option \*qAreaRightEdge\*q \*q" integer \*q
Ignore movements, scrolling and tapping which take place right of this edge.
.
The option is disabled by default and can be enabled by setting the
-AreaRightEdge option to any integer value other than zero. Property: "Synaptics Area"
+AreaRightEdge option to any integer value other than zero. If supported by the
+server (version 1.9 and later), the edge may be specified in percent of
+the total width of the touchpad. Property: "Synaptics Area"
.
.TP
.BI "Option \*qAreaTopEdge\*q \*q" integer \*q
Ignore movements, scrolling and tapping which take place above this edge.
.
The option is disabled by default and can be enabled by setting the
-AreaTopEdge option to any integer value other than zero. Property: "Synaptics Area"
+AreaTopEdge option to any integer value other than zero. If supported by the
+server (version 1.9 and later), the edge may be specified in percent of
+the total width of the touchpad. Property: "Synaptics Area"
.
.TP
.BI "Option \*qAreaBottomEdge\*q \*q" integer \*q
Ignore movements, scrolling and tapping which take place below this edge.
.
The option is disabled by default and can be enabled by setting the
-AreaBottomEdge option to any integer value other than zero. Property: "Synaptics Area"
+AreaBottomEdge option to any integer value other than zero. If supported by the
+server (version 1.9 and later), the edge may be specified in percent of
+the total width of the touchpad. Property: "Synaptics Area"
.
.SH CONFIGURATION DETAILS
diff --git a/src/synaptics.c b/src/synaptics.c
index fae071d..46faf1d 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -329,6 +329,28 @@ calculate_edge_widths(SynapticsPrivate *priv, int *l, int *r, int *t, int *b)
*b = priv->maxy - eheight;
}
+/* Area options support both percent values and absolute values. This is
+ * awkward. The xf86Set* calls will print to the log, but they'll
+ * also print an error if we request a percent value but only have an
+ * int. So - check first for percent, then call xf86Set* again to get
+ * the log message.
+ */
+static int set_percent_option(pointer options, const char* optname,
+ const int range, const int offset)
+{
+ int result;
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 11
+ int percent = xf86CheckPercentOption(options, optname, -1);
+
+ if (percent != -1) {
+ percent = xf86SetPercentOption(options, optname, -1);
+ result = percent/100.0 * range + offset;
+ } else
+#endif
+ result = xf86SetIntOption(options, optname, 0);
+
+ return result;
+}
static void set_default_parameters(LocalDevicePtr local)
{
@@ -466,10 +488,15 @@ static void set_default_parameters(LocalDevicePtr local)
pars->top_edge = xf86SetIntOption(opts, "TopEdge", t);
pars->bottom_edge = xf86SetIntOption(opts, "BottomEdge", b);
- pars->area_top_edge = xf86SetIntOption(opts, "AreaTopEdge", 0);
- pars->area_bottom_edge = xf86SetIntOption(opts, "AreaBottomEdge", 0);
- pars->area_left_edge = xf86SetIntOption(opts, "AreaLeftEdge", 0);
- pars->area_right_edge = xf86SetIntOption(opts, "AreaRightEdge", 0);
+ pars->area_top_edge = set_percent_option(opts, "AreaTopEdge",
+ priv->maxy - priv->miny, priv->miny);
+ pars->area_bottom_edge = set_percent_option(opts, "AreaBottomEdge",
+ priv->maxy - priv->miny, priv->miny);
+
+ pars->area_left_edge = set_percent_option(opts, "AreaLeftEdge",
+ priv->maxx - priv->minx, priv->minx);
+ pars->area_right_edge = set_percent_option(opts, "AreaRightEdge",
+ priv->maxx - priv->minx, priv->minx);
pars->finger_low = xf86SetIntOption(opts, "FingerLow", fingerLow);
pars->finger_high = xf86SetIntOption(opts, "FingerHigh", fingerHigh);
--
1.7.0.1
More information about the xorg-devel
mailing list