summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-02-06 17:33:11 -0800
committerChase Douglas <chase.douglas@canonical.com>2012-02-11 23:01:10 +0100
commit5ede3ad0a2b020b1848adcc2b4ccfc499bfad1f1 (patch)
tree8c9d44f9fe8537b08e6b4e12f1dcfa5f23877691
parent4d66afc7344f46a748a2c068063155b982bfd5cb (diff)
Add right button area property
Some clickpad devices have a right button area painted on them. Set this property to the area of the right button to enable right click actions when tapping or clicking in this area. Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r--include/synaptics-properties.h3
-rw-r--r--man/synaptics.man45
-rw-r--r--src/properties.c21
-rw-r--r--src/synaptics.c32
-rw-r--r--src/synapticsstr.h1
5 files changed, 102 insertions, 0 deletions
diff --git a/include/synaptics-properties.h b/include/synaptics-properties.h
index 712a10b..0a253b2 100644
--- a/include/synaptics-properties.h
+++ b/include/synaptics-properties.h
@@ -161,6 +161,9 @@
/* 32 bit, 4 values, left, right, top, bottom */
#define SYNAPTICS_PROP_AREA "Synaptics Area"
+/* 32 bit, 4 values, left, right, top, buttom */
+#define SYNAPTICS_PROP_RIGHTBUTTON_AREA "Synaptics Right Button Area"
+
/* 32 Bit Integer, 2 values, horizontal hysteresis, vertical hysteresis */
#define SYNAPTICS_PROP_NOISE_CANCELLATION "Synaptics Noise Cancellation"
diff --git a/man/synaptics.man b/man/synaptics.man
index 1233f18..9f3fdf0 100644
--- a/man/synaptics.man
+++ b/man/synaptics.man
@@ -530,6 +530,42 @@ 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"
.
+.TP
+.BI "Option \*qRightbuttonLeftEdge\*q \*q" integer \*q
+Treat taps and clickpad presses which take place left of this position as right
+button actions.
+.
+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 Right Button
+Area".
+.
+.TP
+.BI "Option \*qRightbuttonRightEdge\*q \*q" integer \*q
+Treat taps and clickpad presses which take place right of this position as right
+button actions.
+.
+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 Right Button
+Area".
+.
+.TP
+.BI "Option \*qRightbuttonTopEdge\*q \*q" integer \*q
+Treat taps and clickpad presses which take place above this position as right
+button actions.
+.
+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 Right Button
+Area".
+.
+.TP
+.BI "Option \*qRightbuttonBottomEdge\*q \*q" integer \*q
+Treat taps and clickpad presses which take place below this position as right
+button actions.
+.
+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 Right Button
+Area".
+.
.SH CONFIGURATION DETAILS
.SS Area handling
@@ -943,6 +979,15 @@ default.
32 bit, 4 values, left, right, top, bottom. 0 disables an element.
.TP 7
+.BI "Synaptics Right Button Area"
+The RightbuttonLeftEdge, RightbuttonRightEdge, RightbuttonTopEdge and
+RightbuttonBottomEdge parameters are used to define the area of the right button
+of a clickpad. Taps and presses in this area are treated as right button
+actions. Taps and presses anywhere else are treated as left button actions.
+
+32 bit, 4 values, left, right, top, bottom. 0 disables an element.
+
+.TP 7
.BI "Synaptics Capabilities"
This read-only property expresses the physical capability of the touchpad,
most notably whether the touchpad hardware supports multi-finger tapping and
diff --git a/src/properties.c b/src/properties.c
index f1bda8e..37d23ab 100644
--- a/src/properties.c
+++ b/src/properties.c
@@ -93,6 +93,7 @@ Atom prop_gestures = 0;
Atom prop_capabilities = 0;
Atom prop_resolution = 0;
Atom prop_area = 0;
+Atom prop_rightbutton_area = 0;
Atom prop_noise_cancellation = 0;
Atom prop_product_id = 0;
Atom prop_device_node = 0;
@@ -304,6 +305,12 @@ InitDeviceProperties(InputInfoPtr pInfo)
values[3] = para->area_bottom_edge;
prop_area = InitAtom(pInfo->dev, SYNAPTICS_PROP_AREA, 32, 4, values);
+ values[0] = para->rightbutton_left_edge;
+ values[1] = para->rightbutton_right_edge;
+ values[2] = para->rightbutton_top_edge;
+ values[3] = para->rightbutton_bottom_edge;
+ prop_rightbutton_area = InitAtom(pInfo->dev, SYNAPTICS_PROP_RIGHTBUTTON_AREA, 32, 4, values);
+
values[0] = para->hyst_x;
values[1] = para->hyst_y;
prop_noise_cancellation = InitAtom(pInfo->dev,
@@ -720,6 +727,20 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
para->area_right_edge = area[1];
para->area_top_edge = area[2];
para->area_bottom_edge = area[3];
+ } else if (property == prop_rightbutton_area)
+ {
+ INT32 *area;
+ if (prop->size != 4 || prop->format != 32 || prop->type != XA_INTEGER)
+ return BadMatch;
+
+ area = (INT32*)prop->data;
+ if ((((area[0] != 0) && (area[1] != 0)) && (area[0] > area[1]) ) || (((area[2] != 0) && (area[3] != 0)) && (area[2] > area[3])))
+ return BadValue;
+
+ para->rightbutton_left_edge = area[0];
+ para->rightbutton_right_edge = area[1];
+ para->rightbutton_top_edge = area[2];
+ para->rightbutton_bottom_edge = area[3];
} else if (property == prop_noise_cancellation) {
INT32 *hyst;
if (prop->size != 2 || prop->format != 32 || prop->type != XA_INTEGER)
diff --git a/src/synaptics.c b/src/synaptics.c
index 2e12a8f..980bc31 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -524,6 +524,11 @@ static void set_default_parameters(InputInfoPtr pInfo)
pars->area_left_edge = set_percent_option(opts, "AreaLeftEdge", width, priv->minx, 0);
pars->area_right_edge = set_percent_option(opts, "AreaRightEdge", width, priv->minx, 0);
+ pars->rightbutton_top_edge = set_percent_option(opts, "RightbuttonTopEdge", height, priv->miny, 0);
+ pars->rightbutton_bottom_edge = set_percent_option(opts, "RightbuttonBottomEdge", height, priv->miny, 0);
+ pars->rightbutton_left_edge = set_percent_option(opts, "RightbuttonLeftEdge", width, priv->minx, 0);
+ pars->rightbutton_right_edge = set_percent_option(opts, "RightbuttonRightEdge", width, priv->minx, 0);
+
pars->hyst_x = set_percent_option(opts, "HorizHysteresis", width, 0, horizHyst);
pars->hyst_y = set_percent_option(opts, "VertHysteresis", height, 0, vertHyst);
@@ -1356,6 +1361,24 @@ is_inside_active_area(SynapticsPrivate *priv, int x, int y)
return inside_area;
}
+static Bool
+is_inside_rightbutton_area(SynapticsParameters *para, int x, int y)
+{
+ Bool inside_area = TRUE;
+
+ if (x < para->rightbutton_left_edge)
+ inside_area = FALSE;
+ else if (x > para->rightbutton_right_edge)
+ inside_area = FALSE;
+
+ if (y < para->rightbutton_top_edge)
+ inside_area = FALSE;
+ else if (y > para->rightbutton_bottom_edge)
+ inside_area = FALSE;
+
+ return inside_area;
+}
+
static CARD32
timerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
{
@@ -2513,6 +2536,15 @@ update_hw_button_state(const InputInfoPtr pInfo, struct SynapticsHwState *hw,
/* 3rd button emulation */
hw->middle |= HandleMidButtonEmulation(priv, hw, now, delay);
+ /* If this is a clickpad and the user clicks in the right button area, press
+ * the right button instead. */
+ if (para->clickpad && hw->left && !hw->right &&
+ is_inside_rightbutton_area(para, hw->x, hw->y))
+ {
+ hw->left = 0;
+ hw->right = 1;
+ }
+
/* Fingers emulate other buttons */
if(!para->clickpad && hw->left && hw->numFingers >= 1){
handle_clickfinger(para, hw);
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index 3ea30fe..1f19880 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -182,6 +182,7 @@ typedef struct _SynapticsParameters
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 rightbutton_left_edge, rightbutton_right_edge, rightbutton_top_edge, rightbutton_bottom_edge; /* right button area coordinates absolute */
int hyst_x, hyst_y; /* x and y width of hysteresis box */
} SynapticsParameters;