| 1 | /* xscreensaver, Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 2001 |
| 2 | * by Jamie Zawinski <jwz@jwz.org> |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and its |
| 5 | * documentation for any purpose is hereby granted without fee, provided that |
| 6 | * the above copyright notice appear in all copies and that both that |
| 7 | * copyright notice and this permission notice appear in supporting |
| 8 | * documentation. No representations are made about the suitability of this |
| 9 | * software for any purpose. It is provided "as is" without express or |
| 10 | * implied warranty. |
| 11 | */ |
| 12 | |
| 13 | /* The MIT-SHM (Shared Memory) extension is pretty tricky to use. |
| 14 | This file contains the common boiler-plate for creating a shared |
| 15 | XImage structure, and for making sure that the shared memory segments |
| 16 | get allocated and shut down cleanly. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __XSCREENSAVER_XSHM_H__ |
| 20 | #define __XSCREENSAVER_XSHM_H__ |
| 21 | |
| 22 | #ifdef HAVE_XSHM_EXTENSION |
| 23 | |
| 24 | # include <sys/ipc.h> |
| 25 | # include <sys/shm.h> |
| 26 | # include <X11/extensions/XShm.h> |
| 27 | |
| 28 | #else /* !HAVE_XSHM_EXTENSION */ |
| 29 | |
| 30 | typedef struct { |
| 31 | int shmid; /* Always -1. */ |
| 32 | } dummy_segment_info; |
| 33 | |
| 34 | /* In case XShmSegmentInfo */ |
| 35 | #undef XShmSegmentInfo |
| 36 | #define XShmSegmentInfo dummy_segment_info |
| 37 | |
| 38 | #endif |
| 39 | |
| 40 | extern XImage *create_xshm_image (Display *dpy, Visual *visual, |
| 41 | unsigned int depth, |
| 42 | int format, XShmSegmentInfo *shm_info, |
| 43 | unsigned int width, unsigned int height); |
| 44 | extern Bool put_xshm_image (Display *dpy, Drawable d, GC gc, XImage *image, |
| 45 | int src_x, int src_y, int dest_x, int dest_y, |
| 46 | unsigned int width, unsigned int height, |
| 47 | XShmSegmentInfo *shm_info); |
| 48 | extern Bool get_xshm_image (Display *dpy, Drawable d, XImage *image, |
| 49 | int x, int y, unsigned long plane_mask, |
| 50 | XShmSegmentInfo *shm_info); |
| 51 | extern void destroy_xshm_image (Display *dpy, XImage *image, |
| 52 | XShmSegmentInfo *shm_info); |
| 53 | |
| 54 | #endif /* __XSCREENSAVER_XSHM_H__ */ |