diff --git a/tests/xim_live_test.c b/tests/xim_live_test.c index f1a008d..4656b79 100644 --- a/tests/xim_live_test.c +++ b/tests/xim_live_test.c @@ -405,6 +405,9 @@ testcallbacks(Display *dpy, XIM im, Window win) /* * The popup is the one viewable override-redirect window on the private * display; created before the client window, it must still stack above it. + * The order and the map states have to be one observation: the daemon + * raises and maps between two ungrabbed round trips, and a stale order read + * against a fresh map state says the popup is below when it is not. */ static int popupabove(Display *dpy, Window client) @@ -419,8 +422,11 @@ popupabove(Display *dpy, Window client) for(;;){ above = 0; root = DefaultRootWindow(dpy); - if(!XQueryTree(dpy, root, &root, &parent, &kids, &n)) + XGrabServer(dpy); + if(!XQueryTree(dpy, root, &root, &parent, &kids, &n)){ + XUngrabServer(dpy); return fail("query the window tree"); + } for(i = 0; i < n; i++){ if(kids[i] == client) above = 1; @@ -429,6 +435,7 @@ popupabove(Display *dpy, Window client) break; } XFree(kids); + XUngrabServer(dpy); if(i < n) return above || fail("popup is stacked below the client"); if(leftms(deadline) == 0)