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