2003-11-14 15:54:30 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
|
in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
|
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall
|
|
|
|
|
not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
|
other dealings in this Software without prior written authorization
|
|
|
|
|
from The Open Group.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2005-05-13 22:53:36 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
2003-11-14 15:54:30 +00:00
|
|
|
#include <X11/Xlibint.h>
|
|
|
|
|
#include <X11/Xos.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This routine is used to link a extension in so it will be called
|
|
|
|
|
* at appropriate times.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
XExtCodes *XInitExtension (
|
|
|
|
|
Display *dpy,
|
|
|
|
|
_Xconst char *name)
|
|
|
|
|
{
|
|
|
|
|
XExtCodes codes; /* temp. place for extension information. */
|
|
|
|
|
register _XExtension *ext;/* need a place to build it all */
|
2008-06-17 14:41:17 -07:00
|
|
|
if (!XQueryExtension(dpy, name,
|
2003-11-14 15:54:30 +00:00
|
|
|
&codes.major_opcode, &codes.first_event,
|
|
|
|
|
&codes.first_error)) return (NULL);
|
|
|
|
|
|
|
|
|
|
LockDisplay (dpy);
|
2013-03-07 23:46:05 -08:00
|
|
|
if (! (ext = Xcalloc (1, sizeof (_XExtension))) ||
|
2011-04-12 22:30:45 -07:00
|
|
|
! (ext->name = strdup(name))) {
|
2014-06-05 18:37:40 +02:00
|
|
|
Xfree(ext);
|
2003-11-14 15:54:30 +00:00
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (XExtCodes *) NULL;
|
|
|
|
|
}
|
|
|
|
|
codes.extension = dpy->ext_number++;
|
|
|
|
|
ext->codes = codes;
|
|
|
|
|
|
2008-06-17 14:41:17 -07:00
|
|
|
/* chain it onto the display list */
|
2003-11-14 15:54:30 +00:00
|
|
|
ext->next = dpy->ext_procs;
|
|
|
|
|
dpy->ext_procs = ext;
|
|
|
|
|
UnlockDisplay (dpy);
|
|
|
|
|
|
|
|
|
|
return (&ext->codes); /* tell him which extension */
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
XExtCodes *XAddExtension (Display *dpy)
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *ext;
|
|
|
|
|
|
|
|
|
|
LockDisplay (dpy);
|
2013-03-07 23:46:05 -08:00
|
|
|
if (! (ext = Xcalloc (1, sizeof (_XExtension)))) {
|
2003-11-14 15:54:30 +00:00
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (XExtCodes *) NULL;
|
|
|
|
|
}
|
|
|
|
|
ext->codes.extension = dpy->ext_number++;
|
|
|
|
|
|
|
|
|
|
/* chain it onto the display list */
|
|
|
|
|
ext->next = dpy->ext_procs;
|
|
|
|
|
dpy->ext_procs = ext;
|
|
|
|
|
UnlockDisplay (dpy);
|
|
|
|
|
|
|
|
|
|
return (&ext->codes); /* tell him which extension */
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-23 18:42:09 +00:00
|
|
|
static _XExtension *XLookupExtension (
|
|
|
|
|
register Display *dpy, /* display */
|
|
|
|
|
register int extension) /* extension number */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *ext;
|
|
|
|
|
for (ext = dpy->ext_procs; ext; ext = ext->next)
|
|
|
|
|
if (ext->codes.extension == extension) return (ext);
|
|
|
|
|
return (NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
XExtData **XEHeadOfExtensionList(XEDataObject object)
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
return *(XExtData ***)&object;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-23 18:42:09 +00:00
|
|
|
int
|
2007-05-01 15:20:08 +02:00
|
|
|
XAddToExtensionList(
|
|
|
|
|
XExtData **structure,
|
|
|
|
|
XExtData *ext_data)
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
ext_data->next = *structure;
|
|
|
|
|
*structure = ext_data;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
XExtData *XFindOnExtensionList(
|
|
|
|
|
XExtData **structure,
|
|
|
|
|
int number)
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
XExtData *ext;
|
|
|
|
|
|
|
|
|
|
ext = *structure;
|
|
|
|
|
while (ext && (ext->number != number))
|
|
|
|
|
ext = ext->next;
|
|
|
|
|
return ext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Routines to hang procs on the extension structure.
|
|
|
|
|
*/
|
2007-05-01 15:20:08 +02:00
|
|
|
CreateGCType XESetCreateGC(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
CreateGCType proc) /* routine to call when GC created */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register CreateGCType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->create_GC;
|
|
|
|
|
e->create_GC = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (CreateGCType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
CopyGCType XESetCopyGC(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
CopyGCType proc) /* routine to call when GC copied */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register CopyGCType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->copy_GC;
|
|
|
|
|
e->copy_GC = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (CopyGCType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
FlushGCType XESetFlushGC(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
FlushGCType proc) /* routine to call when GC copied */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register FlushGCType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->flush_GC;
|
|
|
|
|
e->flush_GC = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (FlushGCType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
FreeGCType XESetFreeGC(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
FreeGCType proc) /* routine to call when GC freed */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register FreeGCType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->free_GC;
|
|
|
|
|
e->free_GC = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (FreeGCType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
CreateFontType XESetCreateFont(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
CreateFontType proc) /* routine to call when font created */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register CreateFontType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->create_Font;
|
|
|
|
|
e->create_Font = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (CreateFontType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
FreeFontType XESetFreeFont(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
FreeFontType proc) /* routine to call when font freed */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register FreeFontType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->free_Font;
|
|
|
|
|
e->free_Font = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (FreeFontType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
CloseDisplayType XESetCloseDisplay(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
CloseDisplayType proc) /* routine to call when display closed */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register CloseDisplayType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->close_display;
|
|
|
|
|
e->close_display = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (CloseDisplayType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef Bool (*WireToEventType) (
|
|
|
|
|
Display* /* display */,
|
|
|
|
|
XEvent* /* re */,
|
|
|
|
|
xEvent* /* event */
|
|
|
|
|
);
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
WireToEventType XESetWireToEvent(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int event_number, /* event routine to replace */
|
|
|
|
|
WireToEventType proc) /* routine to call when converting event */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
2004-04-23 18:42:09 +00:00
|
|
|
register WireToEventType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if (proc == NULL) proc = (WireToEventType)_XUnknownWireEvent;
|
|
|
|
|
LockDisplay (dpy);
|
|
|
|
|
oldproc = dpy->event_vec[event_number];
|
|
|
|
|
dpy->event_vec[event_number] = proc;
|
|
|
|
|
UnlockDisplay (dpy);
|
|
|
|
|
return (WireToEventType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
Add generic event cookie handling to libX11.
Generic events require more bytes than Xlib provides in the standard XEvent.
Memory allocated by the extension and stored as pointers inside the event is
prone to leak by simple 'while (1) { XNextEvent(...); }' loops.
This patch adds cookie handling for generic events. Extensions may register
a cookie handler in addition to the normal event vectors. If an extension
has registered a cookie handler, _all_ generic events for this extensions
must be handled through cookies. Otherwise, the default event handler is
used.
The cookie handler must return an XGenericEventCookie with a pointer to the
data.The rest of the event (type, serialNumber, etc.) are to be filled as
normal. When a client retrieves such a cookie event, the data is stored in
an internal queue (the 'cookiejar'). This data is freed on the next call to
XNextEvent().
New extension interfaces:
XESetWireToEventCookie(display, extension_number, cookie_handler)
Where cookie_handler must set cookie->data. The data pointer is of arbitray
size and type but must be a single memory block. This memory block
represents the actual extension's event.
New client interfaces:
XGetEventData(display, *cookie);
XFreeEventData(display, *cookie);
If the client needs the actual event data, it must call XGetEventData() with
the cookie. This returns the data pointer (and removes it from the cookie
jar) and the client is then responsible for freeing the event with
XFreeEventData(). It is safe to call either function with a non-cookie
event. Events unclaimed or not handled by the XGetEventData() are cleaned up
automatically.
Example client code:
XEvent event;
XGenericEventCookie *cookie = &ev;
XNextEvent(display, &event);
if (XGetEventData(display, cookie)) {
XIEvent *xievent = cookie->data;
...
} else if (cookie->type == GenericEvent) {
/* handle generic event */
} else {
/* handle extension/core event */
}
XFreeEventData(display, cookie);
Cookies are not multi-threading safe. Clients that use XGetEventData() must
lock between XNextEvent and XGetEventData to avoid other threads freeing
cookies.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-26 11:27:43 +10:00
|
|
|
typedef Bool (*WireToEventCookieType) (
|
|
|
|
|
Display* /* display */,
|
|
|
|
|
XGenericEventCookie* /* re */,
|
|
|
|
|
xEvent* /* event */
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
WireToEventCookieType XESetWireToEventCookie(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension major opcode */
|
|
|
|
|
WireToEventCookieType proc /* routine to call for generic events */
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
WireToEventCookieType oldproc;
|
|
|
|
|
if (proc == NULL) proc = (WireToEventCookieType)_XUnknownWireEventCookie;
|
|
|
|
|
LockDisplay (dpy);
|
|
|
|
|
oldproc = dpy->generic_event_vec[extension & 0x7F];
|
|
|
|
|
dpy->generic_event_vec[extension & 0x7F] = proc;
|
|
|
|
|
UnlockDisplay (dpy);
|
|
|
|
|
return (WireToEventCookieType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef Bool (*CopyEventCookieType) (
|
|
|
|
|
Display* /* display */,
|
|
|
|
|
XGenericEventCookie* /* in */,
|
|
|
|
|
XGenericEventCookie* /* out */
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CopyEventCookieType XESetCopyEventCookie(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension major opcode */
|
|
|
|
|
CopyEventCookieType proc /* routine to copy generic events */
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
CopyEventCookieType oldproc;
|
|
|
|
|
if (proc == NULL) proc = (CopyEventCookieType)_XUnknownCopyEventCookie;
|
|
|
|
|
LockDisplay (dpy);
|
|
|
|
|
oldproc = dpy->generic_event_copy_vec[extension & 0x7F];
|
|
|
|
|
dpy->generic_event_copy_vec[extension & 0x7F] = proc;
|
|
|
|
|
UnlockDisplay (dpy);
|
|
|
|
|
return (CopyEventCookieType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-14 15:54:30 +00:00
|
|
|
typedef Status (*EventToWireType) (
|
|
|
|
|
Display* /* display */,
|
|
|
|
|
XEvent* /* re */,
|
|
|
|
|
xEvent* /* event */
|
|
|
|
|
);
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
EventToWireType XESetEventToWire(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int event_number, /* event routine to replace */
|
|
|
|
|
EventToWireType proc) /* routine to call when converting event */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
2004-04-23 18:42:09 +00:00
|
|
|
register EventToWireType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if (proc == NULL) proc = (EventToWireType) _XUnknownNativeEvent;
|
|
|
|
|
LockDisplay (dpy);
|
|
|
|
|
oldproc = dpy->wire_vec[event_number];
|
|
|
|
|
dpy->wire_vec[event_number] = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (EventToWireType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef Bool (*WireToErrorType) (
|
|
|
|
|
Display* /* display */,
|
|
|
|
|
XErrorEvent* /* he */,
|
|
|
|
|
xError* /* we */
|
|
|
|
|
);
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
WireToErrorType XESetWireToError(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int error_number, /* error routine to replace */
|
|
|
|
|
WireToErrorType proc) /* routine to call when converting error */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
2004-04-23 18:42:09 +00:00
|
|
|
register WireToErrorType oldproc = NULL;
|
2003-11-14 15:54:30 +00:00
|
|
|
if (proc == NULL) proc = (WireToErrorType)_XDefaultWireError;
|
|
|
|
|
LockDisplay (dpy);
|
|
|
|
|
if (!dpy->error_vec) {
|
|
|
|
|
int i;
|
2004-04-23 18:42:09 +00:00
|
|
|
dpy->error_vec = Xmalloc(256 * sizeof(oldproc));
|
2003-11-14 15:54:30 +00:00
|
|
|
for (i = 1; i < 256; i++)
|
|
|
|
|
dpy->error_vec[i] = _XDefaultWireError;
|
|
|
|
|
}
|
|
|
|
|
if (dpy->error_vec) {
|
|
|
|
|
oldproc = dpy->error_vec[error_number];
|
|
|
|
|
dpy->error_vec[error_number] = proc;
|
|
|
|
|
}
|
|
|
|
|
UnlockDisplay (dpy);
|
|
|
|
|
return (WireToErrorType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
ErrorType XESetError(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
ErrorType proc) /* routine to call when X error happens */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register ErrorType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->error;
|
|
|
|
|
e->error = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (ErrorType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
ErrorStringType XESetErrorString(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
ErrorStringType proc) /* routine to call when I/O error happens */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register ErrorStringType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->error_string;
|
|
|
|
|
e->error_string = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (ErrorStringType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
PrintErrorType XESetPrintErrorValues(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
PrintErrorType proc) /* routine to call to print */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register PrintErrorType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->error_values;
|
|
|
|
|
e->error_values = proc;
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (PrintErrorType)oldproc;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-01 15:20:08 +02:00
|
|
|
BeforeFlushType XESetBeforeFlush(
|
|
|
|
|
Display *dpy, /* display */
|
|
|
|
|
int extension, /* extension number */
|
|
|
|
|
BeforeFlushType proc) /* routine to call on flush */
|
2003-11-14 15:54:30 +00:00
|
|
|
{
|
|
|
|
|
register _XExtension *e; /* for lookup of extension */
|
2004-04-23 18:42:09 +00:00
|
|
|
register BeforeFlushType oldproc;
|
2003-11-14 15:54:30 +00:00
|
|
|
register _XExtension *ext;
|
|
|
|
|
if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
|
oldproc = e->before_flush;
|
|
|
|
|
e->before_flush = proc;
|
|
|
|
|
for (ext = dpy->flushes; ext && ext != e; ext = ext->next)
|
|
|
|
|
;
|
|
|
|
|
if (!ext) {
|
|
|
|
|
e->next_flush = dpy->flushes;
|
|
|
|
|
dpy->flushes = e;
|
2008-06-17 14:41:17 -07:00
|
|
|
}
|
2003-11-14 15:54:30 +00:00
|
|
|
UnlockDisplay(dpy);
|
|
|
|
|
return (BeforeFlushType)oldproc;
|
|
|
|
|
}
|