1/* 2 3Copyright 1994, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25*/ 26 27#ifndef _XMU_DISPLAYQUE_H_ 28#define _XMU_DISPLAYQUE_H_ 29 30#include <X11/Xmu/CloseHook.h> 31#include <X11/Xfuncproto.h> 32 33/* 34 * Public Entry Points 35 * 36 * 37 * XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data) 38 * XmuCloseDisplayQueueProc closefunc; 39 * XmuFreeDisplayQueueProc freefunc; 40 * XPointer data; 41 * 42 * Creates and returns a queue into which displays may be placed. When 43 * the display is closed, the closefunc (if non-NULL) is upcalled with 44 * as follows: 45 * 46 * (*closefunc) (queue, entry) 47 * 48 * The freeproc, if non-NULL, is called whenever the last display is 49 * closed, notifying the creator that display queue may be released 50 * using XmuDQDestroy. 51 * 52 * 53 * Bool XmuDQDestroy (q, docallbacks) 54 * XmuDisplayQueue *q; 55 * Bool docallbacks; 56 * 57 * Releases all memory for the indicated display queue. If docallbacks 58 * is true, then the closefunc (if non-NULL) is called for each 59 * display. 60 * 61 * 62 * XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy) 63 * XmuDisplayQueue *q; 64 * Display *dpy; 65 * 66 * Returns the queue entry for the specified display or NULL if the 67 * display is not in the queue. 68 * 69 * 70 * XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data) 71 * XmuDisplayQueue *q; 72 * Display *dpy; 73 * XPointer data; 74 * 75 * Adds the indicated display to the end of the queue or NULL if it 76 * is unable to allocate memory. The data field may be used by the 77 * caller to attach arbitrary data to this display in this queue. The 78 * caller should use XmuDQLookupDisplay to make sure that the display 79 * hasn't already been added. 80 * 81 * 82 * Bool XmuDQRemoveDisplay (q, dpy) 83 * XmuDisplayQueue *q; 84 * Display *dpy; 85 * 86 * Removes the specified display from the given queue. If the 87 * indicated display is not found on this queue, False is returned, 88 * otherwise True is returned. 89 */ 90 91typedef struct _XmuDisplayQueue XmuDisplayQueue; 92typedef struct _XmuDisplayQueueEntry XmuDisplayQueueEntry; 93 94typedef int (*XmuCloseDisplayQueueProc)(XmuDisplayQueue *queue, 95 XmuDisplayQueueEntry *entry); 96 97typedef int (*XmuFreeDisplayQueueProc)(XmuDisplayQueue *queue); 98 99struct _XmuDisplayQueueEntry { 100 struct _XmuDisplayQueueEntry *prev, *next; 101 Display *display; 102 CloseHook closehook; 103 XPointer data; 104}; 105 106struct _XmuDisplayQueue { 107 int nentries; 108 XmuDisplayQueueEntry *head, *tail; 109 XmuCloseDisplayQueueProc closefunc; 110 XmuFreeDisplayQueueProc freefunc; 111 XPointer data; 112}; 113 114_XFUNCPROTOBEGIN 115 116XmuDisplayQueue *XmuDQCreate 117( 118 XmuCloseDisplayQueueProc closefunc, 119 XmuFreeDisplayQueueProc freefunc, 120 XPointer data 121 ); 122 123Bool XmuDQDestroy 124( 125 XmuDisplayQueue *q, 126 Bool docallbacks 127 ); 128 129XmuDisplayQueueEntry *XmuDQLookupDisplay 130( 131 XmuDisplayQueue *q, 132 Display *dpy 133 ); 134 135XmuDisplayQueueEntry *XmuDQAddDisplay 136( 137 XmuDisplayQueue *q, 138 Display *dpy, 139 XPointer data 140 ); 141 142Bool XmuDQRemoveDisplay 143( 144 XmuDisplayQueue *q, 145 Display *dpy 146 ); 147 148_XFUNCPROTOEND 149 150#define XmuDQNDisplays(q) ((q)->nentries) 151 152#endif /* _XMU_DISPLAYQUE_H_ */ 153