[PATCH 1/3] Xext: Fix edge case with {Positive, Negative}Transition triggers.

Christopher James Halse Rogers christopher.halse.rogers at canonical.com
Sun Dec 5 16:24:00 PST 2010


The {Positive,Negative}Transition triggers only fire when the counter
goes from strictly {below,above} the threshold.  If
SyncComputeBracketValues gets called exactly at this threshold we may update
the bracket values so that the counter is not updated past the threshold.

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
---
 Xext/sync.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index f23df6c..fc7c462 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -929,6 +929,17 @@ SyncComputeBracketValues(SyncCounter *pCounter)
 	    {
 		psci->bracket_less = pTrigger->test_value;
 		pnewltval = &psci->bracket_less;
+	    } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) &&
+		       XSyncValueLessThan(pTrigger->test_value,
+					  psci->bracket_greater))
+	    {
+	        /*
+		 * The value is exactly equal to our threshold.  We want one
+		 * more event in the positive direction to ensure we pick up
+		 * when the value *exceeds* this threshold.
+		 */
+	        psci->bracket_greater = pTrigger->test_value;
+		pnewgtval = &psci->bracket_greater;
 	    }
 	}
         else if (pTrigger->test_type == XSyncPositiveTransition &&
@@ -939,6 +950,17 @@ SyncComputeBracketValues(SyncCounter *pCounter)
 	    {
 		psci->bracket_greater = pTrigger->test_value;
 		pnewgtval = &psci->bracket_greater;
+	    } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) &&
+		       XSyncValueGreaterThan(pTrigger->test_value,
+					     psci->bracket_less))
+	    {
+	        /*
+		 * The value is exactly equal to our threshold.  We want one
+		 * more event in the negative direction to ensure we pick up
+		 * when the value is less than this threshold.
+		 */
+	        psci->bracket_less = pTrigger->test_value;
+		pnewltval = &psci->bracket_less;
 	    }
 	}
     } /* end for each trigger */
-- 
1.7.2.3



More information about the xorg-devel mailing list