- c->ximage = XShmCreateImage(dpy, xgwa.visual, xgwa.depth,
- ZPixmap, 0, &c->shm_info,
- xgwa.width, c->grid_size);
- c->shm_info.shmid = shmget(IPC_PRIVATE,
- c->ximage->height * c->ximage->bytes_per_line,
- IPC_CREAT | 0777);
- if (c->shm_info.shmid == -1)
- printf ("shmget failed!");
- c->shm_info.readOnly = False;
- c->ximage->data = shmat(c->shm_info.shmid, 0, 0);
- printf("data=0x%X %d %d\n", c->ximage->data,
- c->ximage->height, c->ximage->bytes_per_line);
- XShmAttach(dpy, &c->shm_info);
- XSync(dpy, False);
+ c->ximage = create_xshm_image(dpy, xgwa.visual, xgwa.depth,
+ ZPixmap, 0, &c->shm_info,
+ xgwa.width, c->grid_size);
+ if (!c->ximage)
+ c->use_shm = False;