diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2010-01-15 10:24:46 -0800 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2010-01-15 10:24:46 -0800 |
commit | ba9dd18ef222e79ac30be5d2251f3e4bc40699fd (patch) | |
tree | ae81d54f94379c610d77153966c70ae1beae2b14 /src | |
parent | d9846a0f1a6144e947bdb8780686331dca3af128 (diff) | |
download | mirror-meh-ba9dd18ef222e79ac30be5d2251f3e4bc40699fd.tar.gz mirror-meh-ba9dd18ef222e79ac30be5d2251f3e4bc40699fd.tar.bz2 mirror-meh-ba9dd18ef222e79ac30be5d2251f3e4bc40699fd.zip |
fixed bug with XSHM use due to new caching behaviour
Diffstat (limited to 'src')
-rw-r--r-- | src/xlib.c | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -16,6 +16,7 @@ struct data_t{ XImage *ximg; + XShmSegmentInfo *shminfo; }; /* Globals */ @@ -28,10 +29,10 @@ static int xfd; static int xshm = 0; -static XShmSegmentInfo *shminfo; -static XImage *ximage(struct image *img, unsigned int width, unsigned int height, int fast){ +static void ximage(struct data_t *data, struct image *img, unsigned int width, unsigned int height, int fast){ int depth; XImage *ximg = NULL; + XShmSegmentInfo *shminfo = NULL; Visual *vis; depth = DefaultDepth(display, screen); @@ -63,8 +64,7 @@ static XImage *ximage(struct image *img, unsigned int width, unsigned int height fprintf(stderr, "XShm problems, falling back to to XImage\n"); xshm = 0; } - } - if(!xshm){ + }else{ ximg = XCreateImage(display, CopyFromParent, depth, ZPixmap, 0, @@ -80,18 +80,18 @@ static XImage *ximage(struct image *img, unsigned int width, unsigned int height /* TODO other depths */ fprintf(stderr, "This program does not yet support display depths <24.\n"); exit(1); - return NULL; } - return ximg; + data->ximg = ximg; + data->shminfo = shminfo; } void backend_prepare(struct image *img, unsigned int width, unsigned int height, int fast){ struct data_t *data = img->backend = malloc(sizeof (struct data_t)); if(width * img->bufheight > height * img->bufwidth){ - data->ximg = ximage(img, img->bufwidth * height / img->bufheight, height, fast); + ximage(data, img, img->bufwidth * height / img->bufheight, height, fast); }else{ - data->ximg = ximage(img, width, img->bufheight * width / img->bufwidth, fast); + ximage(data, img, width, img->bufheight * width / img->bufwidth, fast); } img->state |= SCALED; @@ -137,14 +137,15 @@ void backend_draw(struct image *img, unsigned int width, unsigned int height){ void backend_free(struct image *img){ assert(img); if(img->backend){ - XImage *ximg = ((struct data_t *)img->backend)->ximg; + struct data_t *data = (struct data_t *)img->backend; + XImage *ximg = data->ximg; if(ximg){ - if(xshm){ - XShmDetach(display, shminfo); + if(xshm && data->shminfo){ + XShmDetach(display, data->shminfo); XDestroyImage(ximg); - shmdt(shminfo->shmaddr); - shmctl(shminfo->shmid, IPC_RMID, 0); - free(shminfo); + shmdt(data->shminfo->shmaddr); + shmctl(data->shminfo->shmid, IPC_RMID, 0); + free(data->shminfo); }else{ XDestroyImage(ximg); } |