diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-06-15 14:24:05 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-06-16 14:04:19 +1000 |
commit | 7b97f9869983a47678188d0df1a209ffc35150db (patch) | |
tree | 5844e41b30df9025d73be9e9d82690b5674be1ea | |
parent | 8b3717055ab5c8d52bf5aae13e996ab4e86c2794 (diff) |
Support percent values for area.
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@who-t.net>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
-rw-r--r-- | man/synaptics.man | 16 | ||||
-rw-r--r-- | src/synaptics.c | 35 |
2 files changed, 43 insertions, 8 deletions
diff --git a/man/synaptics.man b/man/synaptics.man index f201230..1b398fd 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 height 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 height 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); |