diff --git a/tools/gnome-session-check-accelerated.c b/tools/gnome-session-check-accelerated.c
index bd113df..743fbef 100644
--- a/tools/gnome-session-check-accelerated.c
+++ b/tools/gnome-session-check-accelerated.c
@@ -29,6 +29,8 @@
 #include <gdk/gdkx.h>
 #include <X11/Xatom.h>
 
+static Atom is_accelerated_atom;
+
 static void
 exit_1_message (const char *msg) G_GNUC_NORETURN;
 
@@ -39,12 +41,47 @@ exit_1_message (const char *msg)
   exit (1);
 }
 
+static gboolean
+timeout (gpointer data)
+{
+        gtk_main_quit ();
+        return FALSE;
+}
+
+static GdkFilterReturn
+filter (GdkXEvent *xevent,
+        GdkEvent  *event,
+        gpointer   data)
+{
+        XPropertyEvent *ev = xevent;
+
+        if (ev->type == PropertyNotify && ev->atom == is_accelerated_atom) {
+                gtk_main_quit ();
+        }
+
+        return GDK_FILTER_CONTINUE;
+}
+
+static void
+wait_for_property_notify (void)
+{
+        GdkDisplay *display = NULL;
+        Window rootwin;
+
+        display = gdk_display_get_default ();
+
+        rootwin = gdk_x11_get_default_root_xwindow ();
+        XSelectInput (GDK_DISPLAY_XDISPLAY (display), rootwin, PropertyChangeMask);
+        gdk_window_add_filter (root, filter, NULL);
+        g_timeout_add (5000, timeout, NULL);
+        gtk_main ();
+}
+
 int
 main (int argc, char **argv)
 {
         GdkDisplay *display = NULL;
         int estatus;
-        Atom is_accelerated_atom;
         char *child_argv[] = { LIBEXECDIR "/gnome-session-check-accelerated-helper", NULL };
         Window rootwin;
         glong is_accelerated;
@@ -64,6 +101,7 @@ main (int argc, char **argv)
                 gulong bytes_after;
                 guchar *data;
 
+ read:
                 gdk_x11_display_error_trap_push (display);
                 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), rootwin,
                                     is_accelerated_atom,
@@ -73,12 +111,29 @@ main (int argc, char **argv)
 
                 if (type == XA_CARDINAL) {
                         glong *is_accelerated_ptr = (glong*) data;
-                        /* Exit 1 if the property is 0 (false) */
-                        return (*is_accelerated_ptr == 0) ? 1 : 0;
+
+                        if (*is_accelerated_ptr == 2) {
+                                /* Test in progress, wait */
+                                wait_for_property_notify ();
+                                goto read;
+                        }
+
+                        return (*is_accelerated_ptr == 0 ? 1 : 0);
                 }
         }
 
-        /* We don't have the property or it's the wrong type.  Try to compute it now. */
+        /* We don't have the property or it's the wrong type.
+         * Try to compute it now.
+         */
+
+        /* First indicate that a test is in progress */
+        is_accelerated = 2;
+        XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+                         rootwin,
+                         is_accelerated_atom,
+                         XA_CARDINAL, 32, PropModeReplace, (guchar *) &is_accelerated, 1);
+
+        gdk_display_sync (display);
 
         estatus = 1;
         if (!g_spawn_sync (NULL, (char**)child_argv, NULL, 0,
