[PATCH synaptics] Circular exclusion areas

Peter Hutterer peter.hutterer at who-t.net
Wed Oct 30 01:09:21 CET 2013


On Mon, Oct 28, 2013 at 12:54:58AM -0700, Daniel Colascione wrote:
> The attached patch adds support for defining circular dead areas
> around corners.  At least in my use case, it doesn't make sense to
> make large areas of the trackpad dead when only the corners are
> problematic.
 
I need more info here. what exactly is  the "problematic" bit about the
corners?

> Index: include/synaptics-properties.h
> ===================================================================
> --- include/synaptics-properties.h	2013-10-28 00:28:54.231827661 -0700
> +++ xserver-xorg-input-synaptics-1.7.1/include/synaptics-properties.h	2013-10-28 00:28:54.219827661 -0700
> @@ -149,6 +149,9 @@
>  /* 32 bit, 4 values, left, right, top, bottom */
>  #define SYNAPTICS_PROP_AREA "Synaptics Area"
>  
> +/* 32 bit, 4 values, top-left, top-right, bottom-right, bottom-left */
> +#define SYNAPTICS_PROP_CORNERS "Synaptics Corners"
> +
>  /* 32 bit, 4 values, left, right, top, buttom */
>  #define SYNAPTICS_PROP_SOFTBUTTON_AREAS "Synaptics Soft Button Areas"
>  
> Index: xserver-xorg-input-synaptics-1.7.1/man/synaptics.man
> ===================================================================
> --- man/synaptics.man	2013-10-28 00:28:54.231827661 -0700
> +++ xserver-xorg-input-synaptics-1.7.1/man/synaptics.man	2013-10-28 00:28:54.223827661 -0700
> @@ -446,6 +446,47 @@
>  the total height of the touchpad. Property: "Synaptics Area"
>  .
>  .TP
> +.BI "Option \*qCornerTopLeft\*q \*q" integer \*q
> +Ignore movements, scrolling and tapping which take place near
> +the top-left corner.
> +.
> +The option is disabled by default and can be enabled by setting the
> +CornerTopLeft option to any integer value other than zero. If supported by the
> +server (version 1.9 and later), the distance may be specified in percent of
> +the total width of the touchpad.
> +.
> +.TP
> +.BI "Option \*qCornerTopRight\*q \*q" integer \*q
> +Ignore movements, scrolling and tapping which take place near
> +the top-right corner.
> +.
> +The option is disabled by default and can be enabled by setting the
> +CornerTopRight option to any integer value other than zero. If supported by the
> +server (version 1.9 and later), the distance may be specified in percent of
> +the total width of the touchpad.

fwiw we depend on server 1.12 or later anyway

> +.
> +.TP
> +.BI "Option \*qCornerBottomLeft\*q \*q" integer \*q
> +Ignore movements, scrolling and tapping which take place near
> +the bottom-left corner.
> +.
> +The option is disabled by default and can be enabled by setting the
> +CornerBottomLeft option to any integer value other than zero. If supported by the
> +server (version 1.9 and later), the distance may be specified in percent of
> +the total width of the touchpad.
> +.
> +.TP
> +.BI "Option \*qCornerBottomRight\*q \*q" integer \*q
> +Ignore movements, scrolling and tapping which take place near
> +the bottom-right corner.
> +.
> +The option is disabled by default and can be enabled by setting the
> +CornerBottomRight option to any integer value other than zero. If
> +supported by the
> +server (version 1.9 and later), the distance may be specified in percent of
> +the total width of the touchpad.
> +.
> +.TP
>  .BI "Option \*qSoftButtonAreas\*q \*q" "RBL RBR RBT RBB MBL MBR MBT MBB" \*q
>  This option is only available on ClickPad devices. 
>  Enable soft button click area support on ClickPad devices. 
> Index: xserver-xorg-input-synaptics-1.7.1/src/properties.c
> ===================================================================
> --- src/properties.c	2013-10-28 00:28:54.231827661 -0700
> +++ xserver-xorg-input-synaptics-1.7.1/src/properties.c	2013-10-28 00:28:54.223827661 -0700
> @@ -88,6 +88,7 @@
>  Atom prop_capabilities = 0;
>  Atom prop_resolution = 0;
>  Atom prop_area = 0;
> +Atom prop_corners = 0;
>  Atom prop_softbutton_areas = 0;
>  Atom prop_noise_cancellation = 0;
>  Atom prop_product_id = 0;
> @@ -337,6 +338,12 @@
>      values[3] = para->area_bottom_edge;
>      prop_area = InitAtom(pInfo->dev, SYNAPTICS_PROP_AREA, 32, 4, values);
>  
> +    values[0] = para->corner_top_left;
> +    values[1] = para->corner_top_right;
> +    values[2] = para->corner_bottom_right;
> +    values[3] = para->corner_bottom_left;
> +    prop_corners = InitAtom(pInfo->dev, SYNAPTICS_PROP_CORNERS, 32, 4, values);
> +
>      if (para->clickpad)
>          InitSoftButtonProperty(pInfo);
>  
> @@ -691,6 +698,18 @@
>          para->area_top_edge = area[2];
>          para->area_bottom_edge = area[3];
>      }
> +    else if (property == prop_corners) {
> +        INT32 *corners;
> +
> +        if (prop->size != 4 || prop->format != 32 || prop->type != XA_INTEGER)
> +            return BadMatch;
> +
> +        corners = (INT32 *) prop->data;
> +        para->corner_top_left = corners[0];
> +        para->corner_top_right = corners[1];
> +        para->corner_bottom_right = corners[2];
> +        para->corner_bottom_left = corners[3];
> +    }
>      else if (property == prop_softbutton_areas) {
>          int *areas;
>  
> Index: xserver-xorg-input-synaptics-1.7.1/src/synaptics.c
> ===================================================================
> --- src/synaptics.c	2013-10-28 00:28:54.231827661 -0700
> +++ xserver-xorg-input-synaptics-1.7.1/src/synaptics.c	2013-10-28 00:44:09.687798973 -0700
> @@ -633,6 +633,15 @@
>      pars->area_right_edge =
>          set_percent_option(opts, "AreaRightEdge", width, priv->minx, 0);
>  
> +    pars->corner_top_left =
> +        set_percent_option(opts, "CornerTopLeft", width, priv->minx, 0);
> +    pars->corner_top_right =
> +        set_percent_option(opts, "CornerTopRight", width, priv->minx, 0);
> +    pars->corner_bottom_right =
> +        set_percent_option(opts, "CornerBottomRight", width, priv->minx, 0);
> +    pars->corner_bottom_left =
> +        set_percent_option(opts, "CornerBottomLeft", width, priv->minx, 0);
> +
>      pars->hyst_x =
>          set_percent_option(opts, "HorizHysteresis", width, 0, horizHyst);
>      pars->hyst_y =
> @@ -1357,6 +1366,7 @@
>  is_inside_active_area(SynapticsPrivate * priv, int x, int y)
>  {
>      Bool inside_area = TRUE;
> +    int limit2, distx2, disty2;
>  
>      if ((priv->synpara.area_left_edge != 0) &&
>          (x < priv->synpara.area_left_edge))
> @@ -1371,6 +1381,58 @@
>               (y > priv->synpara.area_bottom_edge))
>          inside_area = FALSE;
>  
> +    if (inside_area != FALSE &&
> +        priv->synpara.corner_top_left != 0)
> +    {
> +        limit2 = priv->synpara.corner_top_left;
> +        limit2 = limit2 * limit2;
> +        distx2 = x - priv->minx;
> +        distx2 = distx2 * distx2;
> +        disty2 = y - priv->miny;
> +        disty2 = disty2 * disty2;
> +        if (distx2 + disty2 < limit2)
> +            inside_area = FALSE;
> +    }
> +
> +    if (inside_area != FALSE &&
> +        priv->synpara.corner_top_right != 0)
> +    {
> +        limit2 = priv->synpara.corner_top_right;
> +        limit2 = limit2 * limit2;
> +        distx2 = x - priv->maxx;
> +        distx2 = distx2 * distx2;
> +        disty2 = y - priv->miny;
> +        disty2 = disty2 * disty2;
> +        if (distx2 + disty2 < limit2)
> +            inside_area = FALSE;
> +    }
> +
> +    if (inside_area != FALSE &&
> +        priv->synpara.corner_bottom_right != 0)
> +    {
> +        limit2 = priv->synpara.corner_bottom_right;
> +        limit2 = limit2 * limit2;
> +        distx2 = x - priv->maxx;
> +        distx2 = distx2 * distx2;
> +        disty2 = y - priv->maxy;
> +        disty2 = disty2 * disty2;
> +        if (distx2 + disty2 < limit2)
> +            inside_area = FALSE;
> +    }
> +
> +    if (inside_area != FALSE &&
> +        priv->synpara.corner_bottom_left != 0)
> +    {
> +        limit2 = priv->synpara.corner_bottom_left;
> +        limit2 = limit2 * limit2;
> +        distx2 = x - priv->minx;
> +        distx2 = distx2 * distx2;
> +        disty2 = y - priv->maxy;
> +        disty2 = disty2 * disty2;
> +        if (distx2 + disty2 < limit2)
> +            inside_area = FALSE;
> +    }
> +

this would need to be compressed into a helper function or macro.



>      return inside_area;
>  }
>  
> Index: xserver-xorg-input-synaptics-1.7.1/src/synapticsstr.h
> ===================================================================
> --- src/synapticsstr.h	2013-10-28 00:28:54.231827661 -0700
> +++ xserver-xorg-input-synaptics-1.7.1/src/synapticsstr.h	2013-10-28 00:28:54.223827661 -0700
> @@ -187,6 +187,7 @@
>      unsigned int resolution_horiz;      /* horizontal resolution of touchpad in units/mm */
>      unsigned int resolution_vert;       /* vertical resolution of touchpad in units/mm */
>      int area_left_edge, area_right_edge, area_top_edge, area_bottom_edge;       /* area coordinates absolute */
> +    int corner_top_left, corner_top_right, corner_bottom_right, corner_bottom_left;       /* distances */

make this an array instead.

Cheers,
   Peter

>      int softbutton_areas[2][4]; /* soft button area coordinates, 0 => right, 1 => middle button */
>      int hyst_x, hyst_y;         /* x and y width of hysteresis box */
>  } SynapticsParameters;
> Index: xserver-xorg-input-synaptics-1.7.1/tools/synclient.c
> ===================================================================
> --- tools/synclient.c	2013-10-28 00:28:54.231827661 -0700
> +++ xserver-xorg-input-synaptics-1.7.1/tools/synclient.c	2013-10-28 00:28:54.223827661 -0700
> @@ -130,6 +130,10 @@
>      {"AreaRightEdge",         PT_INT,    0, 10000, SYNAPTICS_PROP_AREA,	32,	1},
>      {"AreaTopEdge",           PT_INT,    0, 10000, SYNAPTICS_PROP_AREA,	32,	2},
>      {"AreaBottomEdge",        PT_INT,    0, 10000, SYNAPTICS_PROP_AREA,	32,	3},
> +    {"CornerTopLeft",         PT_INT,    0, 10000, SYNAPTICS_PROP_CORNERS,	32,	0},
> +    {"CornerTopRight",        PT_INT,    0, 10000, SYNAPTICS_PROP_CORNERS,	32,	1},
> +    {"CornerBottomRight",     PT_INT,    0, 10000, SYNAPTICS_PROP_CORNERS,	32,	2},
> +    {"CornerBottomLeft",      PT_INT,    0, 10000, SYNAPTICS_PROP_CORNERS,	32,	3},
>      {"HorizHysteresis",       PT_INT,    0, 10000, SYNAPTICS_PROP_NOISE_CANCELLATION, 32,	0},
>      {"VertHysteresis",        PT_INT,    0, 10000, SYNAPTICS_PROP_NOISE_CANCELLATION, 32,	1},
>      {"ClickPad",              PT_BOOL,   0, 1,     SYNAPTICS_PROP_CLICKPAD,	8,	0},

> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel



More information about the xorg-devel mailing list