]> Dogcows Code - chaz/openbox/commitdiff
proper logic for event_time_after, and wraparounds and such
authorDana Jansens <danakj@orodu.net>
Wed, 28 Mar 2007 04:07:27 +0000 (04:07 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 28 Mar 2007 04:07:27 +0000 (04:07 +0000)
openbox/event.c

index 96fe627505600f6587efc9391d2d4258ca0e89b0..3aa91c618ffbb14cb667a6434c3ea4b459f55e94 100644 (file)
@@ -1383,5 +1383,15 @@ gboolean event_time_after(Time t1, Time t2)
       later in time than T.
       - http://tronche.com/gui/x/xlib/input/pointer-grabbing.html
     */
-    return t1 >= t2 && t1 <= t2 + (1 << (sizeof(Time)*8-1));
+
+    /* TIME_HALF is half of the number space of a Time type variable */
+#define TIME_HALF (Time)(1 << (sizeof(Time)*8-1))
+
+    if (t2 >= TIME_HALF)
+        /* t2 is in the second half so t1 might wrap around and be smaller than
+           t2 */
+        return t1 >= t2 || t1 < (t2 + TIME_HALF);
+    else
+        /* t2 is in the first half so t1 has to come after it */
+        return t1 >= t2 && t1 < (t2 + TIME_HALF);
 }
This page took 0.028593 seconds and 4 git commands to generate.