~jderose/ubuntu/raring/xserver-xorg-input-synaptics/clickpad

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
Index: xserver-xorg-input-synaptics/include/synaptics-properties.h
===================================================================
--- xserver-xorg-input-synaptics.orig/include/synaptics-properties.h	2011-01-25 22:30:40.936826002 +1100
+++ xserver-xorg-input-synaptics/include/synaptics-properties.h	2011-01-25 22:30:48.686826002 +1100
@@ -155,4 +155,7 @@
 /* 32 bit, 4 values, left, right, top, bottom */
 #define SYNAPTICS_PROP_AREA "Synaptics Area"
 
+/* 32 bit */
+#define SYNAPTICS_PROP_JUMPYCURSOR_THRESHOLD "Synaptics Jumpy Cursor Threshold"
+
 #endif /* _SYNAPTICS_PROPERTIES_H_ */
Index: xserver-xorg-input-synaptics/man/synaptics.man
===================================================================
--- xserver-xorg-input-synaptics.orig/man/synaptics.man	2011-01-25 22:30:48.636826002 +1100
+++ xserver-xorg-input-synaptics/man/synaptics.man	2011-01-25 22:30:48.696826002 +1100
@@ -553,6 +553,14 @@
 A "touch" event happens when the Z value goes above FingerHigh, and an
 "untouch" event happens when the Z value goes below FingerLow.
 .
+.TP
+.BI "Option \*qJumpyCursorThreshold\*q \*q" integer \*q
+Set the threshold above which movement events are ignored on single-touch touchpads.
+.
+The option is disabled by default and can be enabled by setting the
+JumpyCursorThreshold option to any integer value other than zero. Property: "Synaptics 
+Jumpy Cursor Threshold"
+.
 .LP
 The MaxDoubleTapTime parameter has the same function as the MaxTapTime
 parameter, but for the second, third, etc tap in a tap sequence.
@@ -900,6 +908,14 @@
 .BI "Synaptics Pad Resolution"
 32 bit unsigned, 2 values (read-only), vertical, horizontal in units/millimeter.
 
+.TP 7
+.BI "Synaptics Jumpy Cursor Threshold"
+The Synaptics Jumpy Cursor Threshold parameter is used to suppress movements (which
+take place in 20 milliseconds or less) whose covered distance is greater than or
+equal to the threshold on single-touch touchpads. This property is disabled by default.
+
+32 bit, 1 value. 0 disables the property.
+
 .SH "NOTES"
 If either of
 .BI "Protocol \*q" auto-dev \*q
Index: xserver-xorg-input-synaptics/src/properties.c
===================================================================
--- xserver-xorg-input-synaptics.orig/src/properties.c	2011-01-25 22:30:40.926826002 +1100
+++ xserver-xorg-input-synaptics/src/properties.c	2011-01-25 22:31:42.536826002 +1100
@@ -82,6 +82,7 @@
 Atom prop_capabilities          = 0;
 Atom prop_resolution            = 0;
 Atom prop_area                  = 0;
+Atom prop_jumpycursor_threshold = 0;
 
 static Atom
 InitAtom(DeviceIntPtr dev, char *name, int format, int nvalues, int *values)
@@ -278,6 +279,8 @@
     values[2] = para->area_top_edge;
     values[3] = para->area_bottom_edge;
     prop_area = InitAtom(pInfo->dev, SYNAPTICS_PROP_AREA, 32, 4, values);
+
+    prop_jumpycursor_threshold = InitAtom(pInfo->dev, SYNAPTICS_PROP_JUMPYCURSOR_THRESHOLD, 32, 1, &para->jumpycursor_threshold);
 }
 
 int
@@ -649,6 +652,12 @@
         para->area_right_edge  = area[1];
         para->area_top_edge    = area[2];
         para->area_bottom_edge = area[3];
+    } else if (property == prop_jumpycursor_threshold)
+    {
+        if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
+            return BadMatch;
+
+        para->jumpycursor_threshold = *(INT32*)prop->data;
     }
 
     return Success;
Index: xserver-xorg-input-synaptics/src/synaptics.c
===================================================================
--- xserver-xorg-input-synaptics.orig/src/synaptics.c	2011-01-25 22:30:48.676826002 +1100
+++ xserver-xorg-input-synaptics/src/synaptics.c	2011-01-25 22:30:48.696826002 +1100
@@ -131,6 +131,9 @@
 static void ScaleCoordinates(SynapticsPrivate *priv, struct SynapticsHwState *hw);
 static void CalculateScalingCoeffs(SynapticsPrivate *priv);
 
+int old_time_millis = 0;
+Bool was_time_skipped = FALSE;
+
 void InitDeviceProperties(InputInfoPtr pInfo);
 int SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
                 BOOL checkonly);
@@ -584,6 +587,7 @@
     pars->tap_and_drag_gesture = xf86SetBoolOption(opts, "TapAndDragGesture", TRUE);
     pars->resolution_horiz = xf86SetIntOption(opts, "HorizResolution", horizResolution);
     pars->resolution_vert = xf86SetIntOption(opts, "VertResolution", vertResolution);
+    pars->jumpycursor_threshold = xf86SetIntOption(opts, "JumpyCursorThreshold", 0);
 
     /* Warn about (and fix) incorrectly configured TopEdge/BottomEdge parameters */
     if (pars->top_edge > pars->bottom_edge) {
@@ -1696,11 +1700,12 @@
 #define HIST(a) (priv->move_hist[((priv->hist_index - (a) + SYNAPTICS_MOVE_HISTORY) % SYNAPTICS_MOVE_HISTORY)])
 
 static void
-store_history(SynapticsPrivate *priv, int x, int y, unsigned int millis)
+store_history(SynapticsPrivate *priv, int x, int y, int num_fingers, unsigned int millis)
 {
     int idx = (priv->hist_index + 1) % SYNAPTICS_MOVE_HISTORY;
     priv->move_hist[idx].x = x;
     priv->move_hist[idx].y = y;
+    priv->move_hist[idx].num_fingers = num_fingers;
     priv->move_hist[idx].millis = millis;
     priv->hist_index = idx;
 }
@@ -1818,6 +1823,55 @@
     } else {				    /* reset packet counter */
 	priv->count_packet_finger = 0;
     }
+
+    /* Handle quirks here */
+    if (dx || dy) {
+        /* Work around issues caused by two fingers on single-touch
+         * models
+         */
+        if (!priv->has_double) {
+            /* If para->jumpycursor_threshold <= 0, quirks are not
+             * available
+             */
+            if (para->jumpycursor_threshold <= 0)
+                goto post_quirks;
+
+            int elapsed_time = hw->millis - HIST(0).millis;
+
+            /* Ignore deltas as they couldn't possibly happen in so little time */
+            if (elapsed_time <= 20 && (abs(dx) >= para->jumpycursor_threshold || abs(dy) >= para->jumpycursor_threshold)) {
+                dx = dy = 0.0;
+                was_time_skipped = FALSE;
+            }
+            /* A comparison between the timestamp in priv->move_hist and hw->millis shows
+             * that something went wrong and that an event was skipped, hence the deltas
+             * are wrong.
+             * Let's ignore the deltas and append the skipped event to priv->move_hist
+             * otherwise the next deltas will be wrong too.
+             */
+            else if (old_time_millis > 0 && (HIST(0).millis != old_time_millis)) {
+                dx = dy = 0.0;
+                was_time_skipped = TRUE;
+            }
+            /* Something went wrong and an event was previously skipped, hence these deltas
+             * are wrong.
+             * Let's ignore the deltas and set was_time_skipped to FALSE as the next deltas
+             * should be good.
+             */
+            else {
+                if (was_time_skipped) {
+                    dx = 0.0;
+                    dy = 0.0;
+                }
+                was_time_skipped = FALSE;
+            }
+
+            old_time_millis = hw->millis;
+        }
+
+    }
+post_quirks:
+
     priv->prevFingers = hw->numFingers;
 
     *dxP = dx;
@@ -2496,7 +2550,7 @@
 
     /* generate a history of the absolute positions */
     if (inside_active_area)
-	store_history(priv, hw->x, hw->y, hw->millis);
+	store_history(priv, hw->x, hw->y, hw->numFingers, hw->millis);
 
     return delay;
 }
Index: xserver-xorg-input-synaptics/src/synapticsstr.h
===================================================================
--- xserver-xorg-input-synaptics.orig/src/synapticsstr.h	2011-01-25 22:30:40.906826002 +1100
+++ xserver-xorg-input-synaptics/src/synapticsstr.h	2011-01-25 22:30:48.696826002 +1100
@@ -44,6 +44,7 @@
 typedef struct _SynapticsMoveHist
 {
     int x, y;
+    int num_fingers;
     int millis;
 } SynapticsMoveHistRec;
 
@@ -160,6 +161,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 jumpycursor_threshold;      /* jumpy cursor threshold */
 } SynapticsParameters;
 
 
Index: xserver-xorg-input-synaptics/tools/synclient.c
===================================================================
--- xserver-xorg-input-synaptics.orig/tools/synclient.c	2011-01-25 22:30:40.956826002 +1100
+++ xserver-xorg-input-synaptics/tools/synclient.c	2011-01-25 22:30:48.696826002 +1100
@@ -143,6 +143,7 @@
     {"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},
+    {"JumpyCursorThreshold",  PT_INT,    0, 1000,  SYNAPTICS_PROP_JUMPYCURSOR_THRESHOLD,	32,	0},
     { NULL, 0, 0, 0, 0 }
 };