]> Dogcows Code - chaz/openbox/commitdiff
Correct a 64-bit bug in event_time_after
authorMikael Magnusson <mikachu@gmail.com>
Sun, 26 Oct 2008 23:10:57 +0000 (00:10 +0100)
committerMikael Magnusson <mikachu@gmail.com>
Sun, 26 Oct 2008 23:27:57 +0000 (00:27 +0100)
The code assumed the timestamps had the same domain as the type Xlib
uses for them, which is almost never the case with Xlib. Change all
involved variables to guint32.

openbox/event.c
openbox/event.h

index 3abaa675e1428fe54a1e0c64882aea1f2a3680e7..5f1ae255a387a1d2b9b5882ed350f3a730564c0b 100644 (file)
@@ -1999,7 +1999,7 @@ void event_cancel_all_key_grabs(void)
     XSync(ob_display, FALSE);
 }
 
-gboolean event_time_after(Time t1, Time t2)
+gboolean event_time_after(guint32 t1, guint32 t2)
 {
     g_assert(t1 != CurrentTime);
     g_assert(t2 != CurrentTime);
@@ -2012,8 +2012,10 @@ gboolean event_time_after(Time t1, Time t2)
       - http://tronche.com/gui/x/xlib/input/pointer-grabbing.html
     */
 
-    /* TIME_HALF is half of the number space of a Time type variable */
-#define TIME_HALF (Time)(1 << (sizeof(Time)*8-1))
+    /* TIME_HALF is not half of the number space of a Time type variable.
+     * Rather, it is half the number space of a timestamp value, which is
+     * always 32 bits. */
+#define TIME_HALF (guint32)(1 << 31)
 
     if (t2 >= TIME_HALF)
         /* t2 is in the second half so t1 might wrap around and be smaller than
index 93af6b4cf0ee713e95feb0d00e2d6a14b963ec91..a4bd88653f7a6f1c403d0e5225516d0c1c416541 100644 (file)
@@ -65,7 +65,7 @@ void event_halt_focus_delay();
 
 /*! Compare t1 and t2, taking into account wraparound. True if t1
     comes at the same time or later than t2. */
-gboolean event_time_after(Time t1, Time t2);
+gboolean event_time_after(guint32 t1, guint32 t2);
 
 Time event_get_server_time();
 
This page took 0.0264 seconds and 4 git commands to generate.