CloseHook.h File Reference

#include <X11/Xlib.h>
#include <X11/Xfuncproto.h>
#include <X11/Xlibint.h>

Include dependency graph for CloseHook.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef XPointer CloseHook
typedef int(*) XmuCloseHookProc (Display *dpy, XPointer data)

Functions

_XFUNCPROTOBEGIN CloseHook XmuAddCloseDisplayHook (Display *dpy, XmuCloseHookProc proc, XPointer arg)
Bool XmuLookupCloseDisplayHook (Display *dpy, CloseHook handle, XmuCloseHookProc proc, XPointer arg)
Bool XmuRemoveCloseDisplayHook (Display *dpy, CloseHook handle, XmuCloseHookProc proc, XPointer arg)


Typedef Documentation

typedef XPointer CloseHook

Definition at line 42 of file CloseHook.h.

typedef int(*) XmuCloseHookProc(Display *dpy, XPointer data)

Definition at line 44 of file CloseHook.h.


Function Documentation

_XFUNCPROTOBEGIN CloseHook XmuAddCloseDisplayHook ( Display *  dpy,
XmuCloseHookProc  proc,
XPointer  arg 
)

Definition at line 114 of file CloseHook.c.

References _FindDisplayEntry(), _MakeExtension(), _CallbackRec::arg, _DisplayEntry::calling, _DisplayEntry::dpy, elist, _DisplayEntry::end, _DisplayEntry::extension, free(), _CallbackRec::func, malloc(), _CallbackRec::next, _DisplayEntry::next, NULL, and _DisplayEntry::start.

Referenced by XmuDQAddDisplay().

00115 {
00116     DisplayEntry *de;
00117     CallbackRec *cb;
00118 
00119     /* allocate ahead of time so that we can fail atomically */
00120     cb = (CallbackRec *) malloc (sizeof (CallbackRec));
00121     if (!cb) return ((XPointer) NULL);
00122 
00123     de = _FindDisplayEntry (dpy, NULL);
00124     if (!de) {
00125         if ((de = (DisplayEntry *) malloc (sizeof (DisplayEntry))) == NULL ||
00126             !_MakeExtension (dpy, &de->extension)) {
00127             free ((char *) cb);
00128             if (de) free ((char *) de);
00129             return ((CloseHook) NULL);
00130         }
00131         de->dpy = dpy;
00132         de->start = de->end = NULL;
00133         de->calling = NULL;
00134         de->next = elist;
00135         elist = de;
00136     }
00137 
00138     /* add to end of list of callback recordss */
00139     cb->func = func;
00140     cb->arg = arg;
00141     cb->next = NULL;
00142     if (de->end) {
00143         de->end->next = cb;
00144     } else {
00145         de->start = cb;
00146     }
00147     de->end = cb;
00148 
00149     return ((CloseHook) cb);
00150 }

Here is the call graph for this function:

Here is the caller graph for this function:

Bool XmuLookupCloseDisplayHook ( Display *  dpy,
CloseHook  handle,
XmuCloseHookProc  proc,
XPointer  arg 
)

Definition at line 196 of file CloseHook.c.

References _FindDisplayEntry(), h, NULL, and _DisplayEntry::start.

00198 {
00199     DisplayEntry *de = _FindDisplayEntry (dpy, NULL);
00200     register CallbackRec *h;
00201 
00202     if (!de) return False;
00203 
00204     for (h = de->start; h; h = h->next) {
00205         if (handle) {
00206             if (h == (CallbackRec *) handle) break;
00207         } else {
00208             if (h->func == func && h->arg == arg) break;
00209         }
00210     }
00211     return (h ? True : False);
00212 }

Here is the call graph for this function:

Bool XmuRemoveCloseDisplayHook ( Display *  dpy,
CloseHook  handle,
XmuCloseHookProc  proc,
XPointer  arg 
)

Definition at line 158 of file CloseHook.c.

References _FindDisplayEntry(), _DisplayEntry::calling, _DisplayEntry::end, free(), h, _CallbackRec::next, NULL, and _DisplayEntry::start.

Referenced by XmuDQRemoveDisplay().

00160 {
00161     DisplayEntry *de = _FindDisplayEntry (dpy, NULL);
00162     register CallbackRec *h, *prev;
00163 
00164     if (!de) return False;
00165 
00166     /* look for handle or function/argument pair */
00167     for (h = de->start, prev = NULL; h; h = h->next) {
00168         if (handle) {
00169             if (h == (CallbackRec *) handle) break;
00170         } else {
00171             if (h->func == func && h->arg == arg) break;
00172         }
00173         prev = h;
00174     }
00175     if (!h) return False;
00176 
00177 
00178     /* remove from list, watch head and tail */
00179     if (de->start == h) {
00180         de->start = h->next;
00181     } else {
00182         prev->next = h->next;
00183     }
00184     if (de->end == h) de->end = prev;
00185     if (de->calling != h) free ((char *) h);
00186     return True;
00187 }

Here is the call graph for this function:

Here is the caller graph for this function:


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