diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-07-22 10:41:08 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-07-27 11:27:27 +1000 |
commit | d7a4a63d1d67bf38a7948722881de8d926319c6c (patch) | |
tree | 7a3caccdfa89b5750a5b137c2f4b39eb91460804 | |
parent | 7179a0eb11a842d9d5a420f5702a411b0dc217a2 (diff) |
Revert "Auto-adjust edges if values fall outside queried min/max ranges. (#21001)"
This reverts commit afb60a0b2497c5d08cbd1739fa8ae6585c428881.
From comment 24 to #21001:
I've been running this code for over a week now and I'm not happy with it.
Once I move over to the right, the scroll-edge becomes so small that it's
hard to trigger.
Source of the problem is the information provided by the kernel. The kernel
hands us a min/max value for the synaptics pads but this value is not
reflective of the actual physical boundaries. The other dimensions are based
on these min/max ranges.
My RightEdge setting by default is 5129, after moving to the right it
becomes 5677. The announced max for x is 5472. We have model-specific edge
settings and in the case of synaptics the width of the scroll area is 7% of
the total width (based on min/max). This works, but obviously only because
the max is wrong. I've tried upping this to 15% and it works fine but unless
the edge is adjusted the scroll bar takes over too much of the pad.
So right now I'm inclined to revert this patch and just ditch any
auto-adjustment of scroll edges whatsoever. This way, the original setting
is maintained even if we reach outside of the min/max area.
Conflicts:
src/synaptics.c
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | man/synaptics.man | 17 | ||||
-rw-r--r-- | src/properties.c | 17 | ||||
-rw-r--r-- | src/synaptics.c | 147 | ||||
-rw-r--r-- | src/synapticsstr.h | 24 |
4 files changed, 42 insertions, 163 deletions
diff --git a/man/synaptics.man b/man/synaptics.man index 9d30a20..86be548 100644 --- a/man/synaptics.man +++ b/man/synaptics.man @@ -99,7 +99,9 @@ option is not needed with synaptics 1.0 or later. See section X coordinate for left edge. Property: "Synaptics Edges" .TP 7 .BI "Option \*qRightEdge\*q \*q" integer \*q -X coordinate for right edge. Property: "Synaptics Edges" +X coordinate for right edge. If this option is set, +.BI SpecialScrollAreaRight +is ignored. Property: "Synaptics Edges" .TP 7 .BI "Option \*qTopEdge\*q \*q" integer \*q Y coordinate for top edge. Property: "Synaptics Edges" @@ -107,6 +109,10 @@ Y coordinate for top edge. Property: "Synaptics Edges" .BI "Option \*qBottomEdge\*q \*q" integer \*q Y coordinate for bottom edge. Property: "Synaptics Edges" .TP 7 +.BI "Option \*qSpecialScrollAreaRight\*q \*q" boolean \*q +Some touchpads have a scroll region on the right edge. Disable this option if +you have one but don't want use it as scroll wheel region. +.TP 7 .BI "Option \*qFingerLow\*q \*q" integer \*q When finger pressure drops below this value, the driver counts it as a release. Property: "Synaptics Finger" @@ -894,11 +900,6 @@ Tapping is disabled by default for touchpads with one or more physical buttons. To enable it you need to map tap actions to buttons. See the "TapButton1", "TapButton2" and "TapButton3" options. .LP -Some devices report min/max values but provide values outside this range. -In this case, the driver auto-adjusts the edge values. Acceleration and -speed values are not affected. User-specified edges are not -auto-adjusted. -.LP Button mapping for physical buttons is handled in the server. If the device is switched to left-handed (an in-server mapping of physical buttons 1, 2, 3 to the logical buttons 3, 2, 1, respectively), both physical @@ -911,10 +912,6 @@ The following options are no longer part of the driver configuration: .BI "Option \*qRepeater\*q \*q" string \*q .TP .BI "Option \*qHistorySize\*q \*q" integer \*q -.TP 7 -.BI "Option \*qSpecialScrollAreaRight\*q \*q" boolean \*q -Some touchpads have a scroll region on the right edge. Disable this option if -you have one but don't want use it as scroll wheel region. .SH "AUTHORS" .LP diff --git a/src/properties.c b/src/properties.c index d03ea6e..4366034 100644 --- a/src/properties.c +++ b/src/properties.c @@ -647,22 +647,5 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, return Success; } -void -SetEdgeProperty(LocalDevicePtr local) -{ - SynapticsPrivate *priv = (SynapticsPrivate*)local->private; - SynapticsParameters *para = &priv->synpara; - uint32_t values[4]; - - values[0] = para->left_edge; - values[1] = para->right_edge; - values[2] = para->top_edge; - values[3] = para->bottom_edge; - - XIChangeDeviceProperty(local->dev, prop_edges, XA_INTEGER, 32, - PropModeReplace, 4, values, FALSE); -} - - #endif diff --git a/src/synaptics.c b/src/synaptics.c index dc833c5..9f67f09 100644 --- a/src/synaptics.c +++ b/src/synaptics.c @@ -82,6 +82,17 @@ #include <xserver-properties.h> #endif +typedef enum { + BOTTOM_EDGE = 1, + TOP_EDGE = 2, + LEFT_EDGE = 4, + RIGHT_EDGE = 8, + LEFT_BOTTOM_EDGE = BOTTOM_EDGE | LEFT_EDGE, + RIGHT_BOTTOM_EDGE = BOTTOM_EDGE | RIGHT_EDGE, + RIGHT_TOP_EDGE = TOP_EDGE | RIGHT_EDGE, + LEFT_TOP_EDGE = TOP_EDGE | LEFT_EDGE +} edge_type; + #define MAX(a, b) (((a)>(b))?(a):(b)) #define MIN(a, b) (((a)<(b))?(a):(b)) #define TIME_DIFF(a, b) ((int)((a)-(b))) @@ -125,7 +136,6 @@ static void CalculateScalingCoeffs(SynapticsPrivate *priv); void InitDeviceProperties(LocalDevicePtr local); int SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, BOOL checkonly); -int SetEdgeProperty(LocalDevicePtr local); #endif InputDriverRec SYNAPTICS = { @@ -450,16 +460,6 @@ static void set_default_parameters(LocalDevicePtr local) } /* set the parameters */ - priv->edges_forced = 0; - if (xf86CheckIfOptionUsedByName(opts, "LeftEdge")) - priv->edges_forced |= LEFT_EDGE; - if (xf86CheckIfOptionUsedByName(opts, "RightEdge")) - priv->edges_forced |= RIGHT_EDGE; - if (xf86CheckIfOptionUsedByName(opts, "TopEdge")) - priv->edges_forced |= TOP_EDGE; - if (xf86CheckIfOptionUsedByName(opts, "BottomEdge")) - priv->edges_forced |= BOTTOM_EDGE; - pars->left_edge = xf86SetIntOption(opts, "LeftEdge", l); pars->right_edge = xf86SetIntOption(opts, "RightEdge", r); pars->top_edge = xf86SetIntOption(opts, "TopEdge", t); @@ -484,6 +484,11 @@ static void set_default_parameters(LocalDevicePtr local) pars->scroll_dist_vert = xf86SetIntOption(opts, "VertScrollDelta", horizScrollDelta); pars->scroll_dist_horiz = xf86SetIntOption(opts, "HorizScrollDelta", vertScrollDelta); pars->scroll_edge_vert = xf86SetBoolOption(opts, "VertEdgeScroll", vertEdgeScroll); + if (xf86CheckIfOptionUsedByName(opts, "RightEdge")) { + pars->special_scroll_area_right = FALSE; + } else { + pars->special_scroll_area_right = xf86SetBoolOption(opts, "SpecialScrollAreaRight", TRUE); + } pars->scroll_edge_horiz = xf86SetBoolOption(opts, "HorizEdgeScroll", horizEdgeScroll); pars->scroll_edge_corner = xf86SetBoolOption(opts, "CornerCoasting", FALSE); pars->scroll_twofinger_vert = xf86SetBoolOption(opts, "VertTwoFingerScroll", vertTwoFingerScroll); @@ -566,12 +571,6 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags) return NULL; } - priv->property_notify_timer = TimerSet(NULL, 0, 0, NULL, NULL); - if (!priv->property_notify_timer) { - xfree(priv); - return NULL; - } - /* Allocate a new InputInfoRec and add it to the head xf86InputDevs. */ local = xf86AllocateInput(drv, 0); if (!local) { @@ -638,6 +637,8 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags) CalculateScalingCoeffs(priv); + priv->largest_valid_x = MIN(priv->synpara.right_edge, XMAX_NOMINAL); + if (!alloc_param_data(local)) goto SetupProc_fail; @@ -798,9 +799,7 @@ DeviceOff(DeviceIntPtr dev) if (local->fd != -1) { TimerFree(priv->timer); - TimerFree(priv->property_notify_timer); priv->timer = NULL; - priv->property_notify_timer = NULL; xf86RemoveEnabledDevice(local); if (priv->proto_ops->DeviceOffHook) priv->proto_ops->DeviceOffHook(local); @@ -1059,31 +1058,6 @@ edge_detection(SynapticsPrivate *priv, int x, int y) return edge; } -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 -/** - * Timer function. Called whenever the edges were auto-adjusted and the - * matching property must be updated to reflect the new state. - */ -static CARD32 -propertyTimerFunc(OsTimerPtr timer, CARD32 now, pointer arg) -{ - LocalDevicePtr local = (LocalDevicePtr)arg; - SynapticsPrivate *priv = (SynapticsPrivate*)local->private; - int sigstate; - - if (!(priv->edges_forced & EDGE_CHANGE_WAITING)) - return 0; - - sigstate = xf86BlockSIGIO(); - - SetEdgeProperty(local); - - priv->edges_forced &= ~(EDGE_CHANGED | EDGE_CHANGE_WAITING); - xf86UnblockSIGIO(sigstate); - return 0; -} -#endif - /* Checks whether coordinates are in the Synaptics Area * or not. If no Synaptics Area is defined (i.e. if * priv->synpara.area_{left|right|top|bottom}_edge are @@ -1179,16 +1153,6 @@ ReadInput(LocalDevicePtr local) if (newDelay) priv->timer = TimerSet(priv->timer, 0, delay, timerFunc, local); - -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 - /* Set a timer to change the edges property ASAP if we auto-adjusted */ - if ((priv->edges_forced & EDGE_CHANGED) && - !(priv->edges_forced & EDGE_CHANGE_WAITING)) { - priv->property_notify_timer = - TimerSet(priv->property_notify_timer, 0, 100, propertyTimerFunc, local); - priv->edges_forced |= EDGE_CHANGE_WAITING; - } -#endif } static int @@ -2202,65 +2166,22 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) hw->multi[2] = hw->multi[3] = FALSE; } - /* The kernel doesn't clip into min/max, so auto-adjust the edges if we - * go beyond min/max */ - if (hw->x > priv->maxx || hw->x < priv->minx || - hw->y > priv->maxy || hw->y < priv->miny) - { - int l, r, t, b; - Bool changed = FALSE; - - if (hw->x > priv->maxx && !(priv->edges_forced & RIGHT_EDGE)) - { - priv->maxx = hw->x; - changed = TRUE; - } else if (hw->x < priv->minx && !(priv->edges_forced & LEFT_EDGE)) - { - priv->minx = hw->x; - changed = TRUE; - } - - if (hw->y > priv->maxy && !(priv->edges_forced & BOTTOM_EDGE)) - { - priv->maxy = hw->y; - changed = TRUE; - } else if (hw->y < priv->miny && !(priv->edges_forced & TOP_EDGE)) - { - priv->miny = hw->y; - changed = TRUE; - } - - if (changed) - { - Bool adjusted = FALSE; - calculate_edge_widths(priv, &l, &r, &t, &b); - if (!(priv->edges_forced & LEFT_EDGE)) - { - para->left_edge = l; - adjusted = TRUE; - } - if (!(priv->edges_forced & RIGHT_EDGE)) - { - para->right_edge = r; - adjusted = TRUE; - } - if (!(priv->edges_forced & TOP_EDGE)) - { - para->top_edge = t; - adjusted = TRUE; - } - if (!(priv->edges_forced & BOTTOM_EDGE)) - { - para->bottom_edge = b; - adjusted = TRUE; - } - - /* We're inside a signal handler, can't change the edges - * property directly. Instead, set a flag and (later) a timer to - * set the property ASAP */ - if (adjusted) - priv->edges_forced |= EDGE_CHANGED; - } + /* + * Some touchpads have a scroll wheel region where a very large X + * coordinate is reported. In this case for eliminate discontinuity, + * we adjust X and simulate new zone which adjacent to right edge. + */ + if (hw->x <= XMAX_VALID) { + if (priv->largest_valid_x < hw->x) + priv->largest_valid_x = hw->x; + } else { + hw->x = priv->largest_valid_x + 1; + /* + * If user didn't set right_edge manualy, auto-adjust to bounds of + * hardware scroll area. + */ + if (para->special_scroll_area_right) + priv->synpara.right_edge = priv->largest_valid_x; } edge = edge_detection(priv, hw->x, hw->y); diff --git a/src/synapticsstr.h b/src/synapticsstr.h index f2bf7d4..ba5405b 100644 --- a/src/synapticsstr.h +++ b/src/synapticsstr.h @@ -86,23 +86,6 @@ enum TouchpadModel { MODEL_APPLETOUCH }; -typedef enum { - BOTTOM_EDGE = 1, - TOP_EDGE = 2, - LEFT_EDGE = 4, - RIGHT_EDGE = 8, - LEFT_BOTTOM_EDGE = BOTTOM_EDGE | LEFT_EDGE, - RIGHT_BOTTOM_EDGE = BOTTOM_EDGE | RIGHT_EDGE, - RIGHT_TOP_EDGE = TOP_EDGE | RIGHT_EDGE, - LEFT_TOP_EDGE = TOP_EDGE | LEFT_EDGE, - - /* EDGE_CHANGED and EDGE_CHANGED_WAITING are flags to signal that there - * at least one edge has changed and that there is a property notify - * event waiting to be sent, respectively. */ - EDGE_CHANGED = 16, - EDGE_CHANGE_WAITING = 32 -} edge_type; - typedef struct _SynapticsParameters { /* Parameter data */ @@ -189,6 +172,7 @@ typedef struct _SynapticsPrivateRec SynapticsMoveHistRec move_hist[SYNAPTICS_MOVE_HISTORY]; /* movement history */ int hist_index; /* Last added entry in move_hist[] */ + int largest_valid_x; /* Largest valid X coordinate seen so far */ int scroll_y; /* last y-scroll position */ int scroll_x; /* last x-scroll position */ double scroll_a; /* last angle-scroll position */ @@ -241,12 +225,6 @@ typedef struct _SynapticsPrivateRec Bool has_pressure; /* device reports pressure */ enum TouchpadModel model; /* The detected model */ - - /* edges_forces is set to RIGHT_EDGE | LEFT_EDGE | ... when the matching - * edge is specified in the xorg.conf. When the edges are auto-adjusted, - * edges_forces may be flagged EDGE_CHANGED and EDGE_CHANGED_WAITING */ - int edges_forced; /* edges set manually? RIGHT_EDGE | LEFT_EDGE | ... */ - OsTimerPtr property_notify_timer; /* For sending off property notify events */ } SynapticsPrivate; #endif /* _SYNAPTICSSTR_H_ */ |