DisplayQue.c File Reference

#include <stdio.h>
#include <X11/Xlib.h>
#include <stdlib.h>
#include <X11/Xmu/DisplayQue.h>

Include dependency graph for DisplayQue.c:

Go to the source code of this file.

Defines

#define CallCloseCallback(q, e)   (void) (*((q)->closefunc)) ((q), (e))
#define CallFreeCallback(q)   (void) (*((q)->freefunc)) ((q))

Functions

static int _DQCloseDisplay (Display *, XPointer)
XmuDisplayQueueXmuDQCreate (XmuCloseDisplayQueueProc closefunc, XmuFreeDisplayQueueProc freefunc, XPointer data)
Bool XmuDQDestroy (XmuDisplayQueue *q, Bool docallbacks)
XmuDisplayQueueEntryXmuDQLookupDisplay (XmuDisplayQueue *q, Display *dpy)
XmuDisplayQueueEntryXmuDQAddDisplay (XmuDisplayQueue *q, Display *dpy, XPointer data)
Bool XmuDQRemoveDisplay (XmuDisplayQueue *q, Display *dpy)


Define Documentation

#define CallCloseCallback ( q,
 )     (void) (*((q)->closefunc)) ((q), (e))

Definition at line 44 of file DisplayQue.c.

Referenced by _DQCloseDisplay(), and XmuDQDestroy().

#define CallFreeCallback (  )     (void) (*((q)->freefunc)) ((q))

Definition at line 45 of file DisplayQue.c.

Referenced by _DQCloseDisplay().


Function Documentation

static int _DQCloseDisplay ( Display *  ,
XPointer   
) [static]

Definition at line 176 of file DisplayQue.c.

References CallCloseCallback, CallFreeCallback, _XmuDisplayQueue::closefunc, _XmuDisplayQueueEntry::display, _XmuDisplayQueue::head, _XmuDisplayQueueEntry::next, void(), and XmuDQRemoveDisplay().

Referenced by XmuDQAddDisplay(), and XmuDQRemoveDisplay().

00177 {
00178     XmuDisplayQueue *q = (XmuDisplayQueue *) arg;
00179     XmuDisplayQueueEntry *e;
00180 
00181     for (e = q->head; e; e = e->next) {
00182         if (e->display == dpy) {
00183             if (q->closefunc) CallCloseCallback (q, e);
00184             (void) XmuDQRemoveDisplay (q, dpy);
00185             if (q->nentries == 0 && q->freefunc) CallFreeCallback (q);
00186             return 1;
00187         }
00188     }
00189 
00190     return 0;
00191 }

Here is the call graph for this function:

Here is the caller graph for this function:

XmuDisplayQueueEntry* XmuDQAddDisplay ( XmuDisplayQueue q,
Display *  dpy,
XPointer  data 
)

Definition at line 108 of file DisplayQue.c.

References _DQCloseDisplay(), _XmuDisplayQueueEntry::closehook, _XmuDisplayQueueEntry::data, _XmuDisplayQueueEntry::display, free(), malloc(), _XmuDisplayQueueEntry::next, NULL, _XmuDisplayQueueEntry::prev, and XmuAddCloseDisplayHook().

Referenced by _XmuCCLookupDisplay().

00109 {
00110     XmuDisplayQueueEntry *e;
00111 
00112     if (!(e = (XmuDisplayQueueEntry *) malloc (sizeof (XmuDisplayQueueEntry)))) {
00113         return NULL;
00114     }
00115     if (!(e->closehook = XmuAddCloseDisplayHook (dpy, _DQCloseDisplay,
00116                                                  (XPointer) q))) {
00117         free ((char *) e);
00118         return NULL;
00119     }
00120 
00121     e->display = dpy;
00122     e->next = NULL;
00123     e->data = data;
00124 
00125     if (q->tail) {
00126         q->tail->next = e;
00127         e->prev = q->tail;
00128     } else {
00129         q->head = e;
00130         e->prev = NULL;
00131     }
00132     q->tail = e;
00133     q->nentries++;
00134     return e;
00135 }

Here is the call graph for this function:

Here is the caller graph for this function:

XmuDisplayQueue* XmuDQCreate ( XmuCloseDisplayQueueProc  closefunc,
XmuFreeDisplayQueueProc  freefunc,
XPointer  data 
)

Definition at line 51 of file DisplayQue.c.

References _XmuDisplayQueue::closefunc, _XmuDisplayQueue::data, _XmuDisplayQueue::freefunc, _XmuDisplayQueue::head, malloc(), _XmuDisplayQueue::nentries, NULL, and _XmuDisplayQueue::tail.

Referenced by _XmuCCLookupDisplay().

00054 {
00055     XmuDisplayQueue *q = (XmuDisplayQueue *) malloc (sizeof (XmuDisplayQueue));
00056     if (q) {
00057         q->nentries = 0;
00058         q->head = q->tail = NULL;
00059         q->closefunc = closefunc;
00060         q->freefunc = freefunc;
00061         q->data = data;
00062     }
00063     return q;
00064 }

Here is the call graph for this function:

Here is the caller graph for this function:

Bool XmuDQDestroy ( XmuDisplayQueue q,
Bool  docallbacks 
)

Definition at line 73 of file DisplayQue.c.

References CallCloseCallback, _XmuDisplayQueue::closefunc, free(), _XmuDisplayQueue::head, and _XmuDisplayQueueEntry::next.

Referenced by _FreeCCDQ().

00074 {
00075     XmuDisplayQueueEntry *e = q->head;
00076 
00077     while (e) {
00078         XmuDisplayQueueEntry *nexte = e->next;
00079         if (docallbacks && q->closefunc) CallCloseCallback (q, e);
00080         free ((char *) e);
00081         e = nexte;
00082     }
00083     free ((char *) q);
00084     return True;
00085 }

Here is the call graph for this function:

Here is the caller graph for this function:

XmuDisplayQueueEntry* XmuDQLookupDisplay ( XmuDisplayQueue q,
Display *  dpy 
)

Definition at line 92 of file DisplayQue.c.

References _XmuDisplayQueueEntry::display, _XmuDisplayQueue::head, _XmuDisplayQueueEntry::next, and NULL.

Referenced by _XmuCCLookupDisplay().

00093 {
00094     XmuDisplayQueueEntry *e;
00095 
00096     for (e = q->head; e; e = e->next) {
00097         if (e->display == dpy) return e;
00098     }
00099     return NULL;
00100 }

Here is the caller graph for this function:

Bool XmuDQRemoveDisplay ( XmuDisplayQueue q,
Display *  dpy 
)

Definition at line 142 of file DisplayQue.c.

References _DQCloseDisplay(), _XmuDisplayQueueEntry::closehook, _XmuDisplayQueueEntry::display, free(), _XmuDisplayQueue::head, _XmuDisplayQueueEntry::next, _XmuDisplayQueueEntry::prev, _XmuDisplayQueue::tail, void(), and XmuRemoveCloseDisplayHook().

Referenced by _DQCloseDisplay().

00143 {
00144     XmuDisplayQueueEntry *e;
00145 
00146     for (e = q->head; e; e = e->next) {
00147         if (e->display == dpy) {
00148             if (q->head == e)
00149               q->head = e->next;        /* if at head, then bump head */
00150             else
00151               e->prev->next = e->next;  /* else splice out */
00152             if (q->tail == e)
00153               q->tail = e->prev;        /* if at tail, then bump tail */
00154             else
00155               e->next->prev = e->prev;  /* else splice out */
00156             (void) XmuRemoveCloseDisplayHook (dpy, e->closehook,
00157                                               _DQCloseDisplay, (XPointer) q);
00158             free ((char *) e);
00159             q->nentries--;
00160             return True;
00161         }
00162     }
00163     return False;
00164 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Mar 4 16:03:45 2007 for Scilab [trunk] by  doxygen 1.5.1