| 1 |
/* |
| 2 |
* Copyright 1992 Network Computing Devices |
| 3 |
* |
| 4 |
* Permission to use, copy, modify, distribute, and sell this software and its |
| 5 |
* documentation for any purpose is hereby granted without fee, provided that |
| 6 |
* the above copyright notice appear in all copies and that both that |
| 7 |
* copyright notice and this permission notice appear in supporting |
| 8 |
* documentation, and that the name of NCD. not be used in advertising or |
| 9 |
* publicity pertaining to distribution of the software without specific, |
| 10 |
* written prior permission. NCD. makes no representations about the |
| 11 |
* suitability of this software for any purpose. It is provided "as is" |
| 12 |
* without express or implied warranty. |
| 13 |
* |
| 14 |
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL |
| 15 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD. |
| 16 |
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 17 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 18 |
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 19 |
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 20 |
* |
| 21 |
* Author: Keith Packard, Network Computing Devices |
| 22 |
*/ |
| 23 |
|
| 24 |
#ifdef HAVE_CONFIG_H |
| 25 |
#include <config.h> |
| 26 |
#endif |
| 27 |
#include <stdio.h> |
| 28 |
#include <X11/Xlibint.h> |
| 29 |
#include <X11/extensions/XLbx.h> |
| 30 |
#include <X11/extensions/lbxproto.h> |
| 31 |
#include <X11/extensions/Xext.h> |
| 32 |
#include <X11/extensions/extutil.h> |
| 33 |
|
| 34 |
static XExtensionInfo _lbx_info_data; |
| 35 |
static XExtensionInfo *lbx_info = &_lbx_info_data; |
| 36 |
static const char *lbx_extension_name = LBXNAME; |
| 37 |
|
| 38 |
#define LbxCheckExtension(dpy,i,val) \ |
| 39 |
XextCheckExtension (dpy, i, lbx_extension_name, val) |
| 40 |
|
| 41 |
static int close_display(Display *dpy, XExtCodes *codes); |
| 42 |
static char *error_string(Display *dpy, int code, XExtCodes *codes, |
| 43 |
char *buf, int n); |
| 44 |
static /* const */ XExtensionHooks lbx_extension_hooks = { |
| 45 |
NULL, /* create_gc */ |
| 46 |
NULL, /* copy_gc */ |
| 47 |
NULL, /* flush_gc */ |
| 48 |
NULL, /* free_gc */ |
| 49 |
NULL, /* create_font */ |
| 50 |
NULL, /* free_font */ |
| 51 |
close_display, /* close_display */ |
| 52 |
NULL, /* wire_to_event */ |
| 53 |
NULL, /* event_to_wire */ |
| 54 |
NULL, /* error */ |
| 55 |
error_string, /* error_string */ |
| 56 |
}; |
| 57 |
|
| 58 |
static const char *lbx_error_list[] = { |
| 59 |
"BadLbxClient", /* BadLbxClient */ |
| 60 |
}; |
| 61 |
|
| 62 |
static XEXT_GENERATE_FIND_DISPLAY (find_display, lbx_info, lbx_extension_name, |
| 63 |
&lbx_extension_hooks, LbxNumberEvents, NULL) |
| 64 |
|
| 65 |
static XEXT_GENERATE_CLOSE_DISPLAY (close_display, lbx_info) |
| 66 |
|
| 67 |
static XEXT_GENERATE_ERROR_STRING (error_string, lbx_extension_name, |
| 68 |
LbxNumberErrors, lbx_error_list) |
| 69 |
|
| 70 |
|
| 71 |
Bool XLbxQueryExtension ( |
| 72 |
Display *dpy, |
| 73 |
int *requestp, int *event_basep, int *error_basep) |
| 74 |
{ |
| 75 |
XExtDisplayInfo *info = find_display (dpy); |
| 76 |
|
| 77 |
if (XextHasExtension(info)) { |
| 78 |
*requestp = info->codes->major_opcode; |
| 79 |
*event_basep = info->codes->first_event; |
| 80 |
*error_basep = info->codes->first_error; |
| 81 |
return True; |
| 82 |
} else { |
| 83 |
return False; |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
int XLbxGetEventBase(Display *dpy) |
| 89 |
{ |
| 90 |
XExtDisplayInfo *info = find_display (dpy); |
| 91 |
|
| 92 |
if (XextHasExtension(info)) { |
| 93 |
return info->codes->first_event; |
| 94 |
} else { |
| 95 |
return -1; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
Bool XLbxQueryVersion(Display *dpy, int *majorVersion, int *minorVersion) |
| 101 |
{ |
| 102 |
XExtDisplayInfo *info = find_display (dpy); |
| 103 |
xLbxQueryVersionReply rep; |
| 104 |
register xLbxQueryVersionReq *req; |
| 105 |
|
| 106 |
LbxCheckExtension (dpy, info, False); |
| 107 |
|
| 108 |
LockDisplay(dpy); |
| 109 |
GetReq(LbxQueryVersion, req); |
| 110 |
req->reqType = info->codes->major_opcode; |
| 111 |
req->lbxReqType = X_LbxQueryVersion; |
| 112 |
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
| 113 |
UnlockDisplay(dpy); |
| 114 |
SyncHandle(); |
| 115 |
return False; |
| 116 |
} |
| 117 |
*majorVersion = rep.majorVersion; |
| 118 |
*minorVersion = rep.minorVersion; |
| 119 |
UnlockDisplay(dpy); |
| 120 |
SyncHandle(); |
| 121 |
return True; |
| 122 |
} |
| 123 |
|
| 124 |
/* all other requests will run after Xlib has lost the wire ... */ |