16c321187Smrg/*
26c321187Smrg
36c321187SmrgCopyright 1994, 1998  The Open Group
46c321187Smrg
56c321187SmrgPermission to use, copy, modify, distribute, and sell this software and its
66c321187Smrgdocumentation for any purpose is hereby granted without fee, provided that
76c321187Smrgthe above copyright notice appear in all copies and that both that
86c321187Smrgcopyright notice and this permission notice appear in supporting
96c321187Smrgdocumentation.
106c321187Smrg
116c321187SmrgThe above copyright notice and this permission notice shall be included in
126c321187Smrgall copies or substantial portions of the Software.
136c321187Smrg
146c321187SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
156c321187SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
166c321187SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
176c321187SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
186c321187SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
196c321187SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
206c321187Smrg
216c321187SmrgExcept as contained in this notice, the name of The Open Group shall not be
226c321187Smrgused in advertising or otherwise to promote the sale, use or other dealings
236c321187Smrgin this Software without prior written authorization from The Open Group.
246c321187Smrg
256c321187Smrg*/
266c321187Smrg
276c321187Smrg#ifndef _XMU_DISPLAYQUE_H_
286c321187Smrg#define _XMU_DISPLAYQUE_H_
296c321187Smrg
306c321187Smrg#include <X11/Xmu/CloseHook.h>
316c321187Smrg#include <X11/Xfuncproto.h>
326c321187Smrg
336c321187Smrg/*
346c321187Smrg *			      Public Entry Points
350cc2eac3Smrg *
360cc2eac3Smrg *
376c321187Smrg * XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data)
386c321187Smrg *     XmuCloseDisplayQueueProc closefunc;
396c321187Smrg *     XmuFreeDisplayQueueProc freefunc;
406c321187Smrg *     XPointer data;
410cc2eac3Smrg *
426c321187Smrg *         Creates and returns a queue into which displays may be placed.  When
436c321187Smrg *         the display is closed, the closefunc (if non-NULL) is upcalled with
446c321187Smrg *         as follows:
456c321187Smrg *
466c321187Smrg *                 (*closefunc) (queue, entry)
476c321187Smrg *
486c321187Smrg *         The freeproc, if non-NULL, is called whenever the last display is
496c321187Smrg *         closed, notifying the creator that display queue may be released
506c321187Smrg *         using XmuDQDestroy.
516c321187Smrg *
526c321187Smrg *
536c321187Smrg * Bool XmuDQDestroy (q, docallbacks)
546c321187Smrg *     XmuDisplayQueue *q;
556c321187Smrg *     Bool docallbacks;
560cc2eac3Smrg *
576c321187Smrg *         Releases all memory for the indicated display queue.  If docallbacks
580cc2eac3Smrg *         is true, then the closefunc (if non-NULL) is called for each
596c321187Smrg *         display.
600cc2eac3Smrg *
610cc2eac3Smrg *
626c321187Smrg * XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy)
636c321187Smrg *     XmuDisplayQueue *q;
646c321187Smrg *     Display *dpy;
656c321187Smrg *
666c321187Smrg *         Returns the queue entry for the specified display or NULL if the
676c321187Smrg *         display is not in the queue.
686c321187Smrg *
690cc2eac3Smrg *
706c321187Smrg * XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data)
716c321187Smrg *     XmuDisplayQueue *q;
726c321187Smrg *     Display *dpy;
736c321187Smrg *     XPointer data;
746c321187Smrg *
756c321187Smrg *         Adds the indicated display to the end of the queue or NULL if it
766c321187Smrg *         is unable to allocate memory.  The data field may be used by the
776c321187Smrg *         caller to attach arbitrary data to this display in this queue.  The
786c321187Smrg *         caller should use XmuDQLookupDisplay to make sure that the display
796c321187Smrg *         hasn't already been added.
800cc2eac3Smrg *
810cc2eac3Smrg *
826c321187Smrg * Bool XmuDQRemoveDisplay (q, dpy)
836c321187Smrg *     XmuDisplayQueue *q;
846c321187Smrg *     Display *dpy;
856c321187Smrg *
860cc2eac3Smrg *         Removes the specified display from the given queue.  If the
876c321187Smrg *         indicated display is not found on this queue, False is returned,
886c321187Smrg *         otherwise True is returned.
896c321187Smrg */
906c321187Smrg
916c321187Smrgtypedef struct _XmuDisplayQueue XmuDisplayQueue;
926c321187Smrgtypedef struct _XmuDisplayQueueEntry XmuDisplayQueueEntry;
936c321187Smrg
946c321187Smrgtypedef int (*XmuCloseDisplayQueueProc)(XmuDisplayQueue *queue,
956c321187Smrg					XmuDisplayQueueEntry *entry);
966c321187Smrg
976c321187Smrgtypedef int (*XmuFreeDisplayQueueProc)(XmuDisplayQueue *queue);
986c321187Smrg
996c321187Smrgstruct _XmuDisplayQueueEntry {
1006c321187Smrg    struct _XmuDisplayQueueEntry *prev, *next;
1016c321187Smrg    Display *display;
1026c321187Smrg    CloseHook closehook;
1036c321187Smrg    XPointer data;
1046c321187Smrg};
1056c321187Smrg
1066c321187Smrgstruct _XmuDisplayQueue {
1076c321187Smrg    int nentries;
1086c321187Smrg    XmuDisplayQueueEntry *head, *tail;
1096c321187Smrg    XmuCloseDisplayQueueProc closefunc;
1106c321187Smrg    XmuFreeDisplayQueueProc freefunc;
1116c321187Smrg    XPointer data;
1126c321187Smrg};
1136c321187Smrg
1146c321187Smrg_XFUNCPROTOBEGIN
1156c321187Smrg
1166c321187SmrgXmuDisplayQueue *XmuDQCreate
1176c321187Smrg(
1186c321187Smrg XmuCloseDisplayQueueProc	closefunc,
1196c321187Smrg XmuFreeDisplayQueueProc	freefunc,
1206c321187Smrg XPointer			data
1216c321187Smrg );
1226c321187Smrg
1236c321187SmrgBool XmuDQDestroy
1246c321187Smrg(
1256c321187Smrg XmuDisplayQueue		*q,
1266c321187Smrg Bool				docallbacks
1276c321187Smrg );
1286c321187Smrg
1296c321187SmrgXmuDisplayQueueEntry *XmuDQLookupDisplay
1306c321187Smrg(
1316c321187Smrg XmuDisplayQueue		*q,
1326c321187Smrg Display			*dpy
1336c321187Smrg );
1346c321187Smrg
1356c321187SmrgXmuDisplayQueueEntry *XmuDQAddDisplay
1366c321187Smrg(
1376c321187Smrg XmuDisplayQueue		*q,
1386c321187Smrg Display			*dpy,
1396c321187Smrg XPointer			data
1406c321187Smrg );
1416c321187Smrg
1426c321187SmrgBool XmuDQRemoveDisplay
1436c321187Smrg(
1446c321187Smrg XmuDisplayQueue		*q,
1456c321187Smrg Display			*dpy
1466c321187Smrg );
1476c321187Smrg
1486c321187Smrg_XFUNCPROTOEND
1496c321187Smrg
1506c321187Smrg#define XmuDQNDisplays(q) ((q)->nentries)
1516c321187Smrg
1526c321187Smrg#endif /* _XMU_DISPLAYQUE_H_ */
153