summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-03-28 04:07:27 +0000
committerDana Jansens <danakj@orodu.net>2007-03-28 04:07:27 +0000
commit3ad050f7d8050a46ad03f8233f1c61ad40be9551 (patch)
treeb7b72c1ab776d2a030770962994c4a5e33f1f383
parentbd272698508dd511266bc6a38d2f04b4b6e3d788 (diff)
proper logic for event_time_after, and wraparounds and such
-rw-r--r--openbox/event.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/openbox/event.c b/openbox/event.c
index 96fe6275..3aa91c61 100644
--- a/openbox/event.c
+++ b/openbox/event.c
@@ -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);
}