examples/cogl-x11-tfp.c: Wait for the window to be mapped

Wait for the main window (and hence the window we create within
the main window to redirect) to be mapped and become viewable
before we try to call XCompositeNameWindowPixmap() -
XComposeNameWindowPixmap() produces a BadMatch error on a
non-viewable window.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
This commit is contained in:
Owen W. Taylor 2014-04-27 00:07:53 -04:00
parent d9afc6dada
commit a4bc66325e

View File

@ -147,7 +147,8 @@ main (int argc, char **argv)
DefaultRootWindow (xdpy),
xvisinfo->visual,
AllocNone);
mask = CWBorderPixel | CWColormap;
xattr.event_mask = StructureNotifyMask;
mask = CWBorderPixel | CWColormap | CWEventMask;
xwin = XCreateWindow (xdpy,
DefaultRootWindow (xdpy),
@ -179,6 +180,14 @@ main (int argc, char **argv)
gc = XCreateGC (xdpy, tfp_xwin, 0, NULL);
while (TRUE)
{
XWindowEvent (xdpy, xwin, StructureNotifyMask, &xev);
if (xev.xany.type == MapNotify)
break;
}
pixmap = XCompositeNameWindowPixmap (xdpy, tfp_xwin);
tfp = cogl_texture_pixmap_x11_new (ctx, pixmap, TRUE, &error);