1caade7ccSmrg/* 2caade7ccSmrg * 3caade7ccSmrgCopyright 1989, 1998 The Open Group 4caade7ccSmrg 5caade7ccSmrgPermission to use, copy, modify, distribute, and sell this software and its 6caade7ccSmrgdocumentation for any purpose is hereby granted without fee, provided that 7caade7ccSmrgthe above copyright notice appear in all copies and that both that 8caade7ccSmrgcopyright notice and this permission notice appear in supporting 9caade7ccSmrgdocumentation. 10caade7ccSmrg 11caade7ccSmrgThe above copyright notice and this permission notice shall be included in 12caade7ccSmrgall copies or substantial portions of the Software. 13caade7ccSmrg 14caade7ccSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15caade7ccSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16caade7ccSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17caade7ccSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18caade7ccSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19caade7ccSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20caade7ccSmrg 21caade7ccSmrgExcept as contained in this notice, the name of The Open Group shall not be 22caade7ccSmrgused in advertising or otherwise to promote the sale, use or other dealings 23caade7ccSmrgin this Software without prior written authorization from The Open Group. 24caade7ccSmrg * 25caade7ccSmrg */ 26caade7ccSmrg 27caade7ccSmrg/* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM BLESSING */ 28caade7ccSmrg 29caade7ccSmrg#ifdef HAVE_CONFIG_H 30caade7ccSmrg#include <config.h> 31caade7ccSmrg#endif 32caade7ccSmrg#include <X11/Xlibint.h> 33caade7ccSmrg#include <X11/extensions/MITMisc.h> 34485f0483Smrg#include <X11/extensions/mitmiscproto.h> 35caade7ccSmrg#include <X11/extensions/Xext.h> 36caade7ccSmrg#include <X11/extensions/extutil.h> 37caade7ccSmrg 38caade7ccSmrgstatic XExtensionInfo _mit_info_data; 39caade7ccSmrgstatic XExtensionInfo *mit_info = &_mit_info_data; 40af9a7ee5Smrgstatic const char *mit_extension_name = MITMISCNAME; 41caade7ccSmrg 42caade7ccSmrg#define MITCheckExtension(dpy,i,val) \ 43caade7ccSmrg XextCheckExtension (dpy, i, mit_extension_name, val) 44caade7ccSmrg 45caade7ccSmrg/***************************************************************************** 46caade7ccSmrg * * 47caade7ccSmrg * private utility routines * 48caade7ccSmrg * * 49caade7ccSmrg *****************************************************************************/ 50caade7ccSmrg 51caade7ccSmrgstatic int close_display(Display *dpy, XExtCodes *codes); 52caade7ccSmrgstatic /* const */ XExtensionHooks mit_extension_hooks = { 53caade7ccSmrg NULL, /* create_gc */ 54caade7ccSmrg NULL, /* copy_gc */ 55caade7ccSmrg NULL, /* flush_gc */ 56caade7ccSmrg NULL, /* free_gc */ 57caade7ccSmrg NULL, /* create_font */ 58caade7ccSmrg NULL, /* free_font */ 59caade7ccSmrg close_display, /* close_display */ 60caade7ccSmrg NULL, /* wire_to_event */ 61caade7ccSmrg NULL, /* event_to_wire */ 62caade7ccSmrg NULL, /* error */ 63caade7ccSmrg NULL /* error_string */ 64caade7ccSmrg}; 65caade7ccSmrg 66af9a7ee5Smrgstatic XEXT_GENERATE_FIND_DISPLAY (find_display, mit_info, mit_extension_name, 67caade7ccSmrg &mit_extension_hooks, MITMiscNumberEvents, 68caade7ccSmrg NULL) 69caade7ccSmrg 70caade7ccSmrgstatic XEXT_GENERATE_CLOSE_DISPLAY (close_display, mit_info) 71caade7ccSmrg 72caade7ccSmrg 73caade7ccSmrg/***************************************************************************** 74caade7ccSmrg * * 75caade7ccSmrg * public routines * 76caade7ccSmrg * * 77caade7ccSmrg *****************************************************************************/ 78caade7ccSmrg 79caade7ccSmrgBool XMITMiscQueryExtension (Display *dpy, int *event_basep, int *error_basep) 80caade7ccSmrg{ 81caade7ccSmrg XExtDisplayInfo *info = find_display (dpy); 82caade7ccSmrg 83caade7ccSmrg if (XextHasExtension(info)) { 84caade7ccSmrg *event_basep = info->codes->first_event; 85caade7ccSmrg *error_basep = info->codes->first_error; 86caade7ccSmrg return True; 87caade7ccSmrg } else { 88caade7ccSmrg return False; 89caade7ccSmrg } 90caade7ccSmrg} 91caade7ccSmrg 92caade7ccSmrg 93caade7ccSmrgStatus XMITMiscSetBugMode(Display *dpy, Bool onOff) 94caade7ccSmrg{ 95caade7ccSmrg XExtDisplayInfo *info = find_display (dpy); 96caade7ccSmrg register xMITSetBugModeReq *req; 97caade7ccSmrg 98caade7ccSmrg MITCheckExtension (dpy, info, 0); 99caade7ccSmrg 100caade7ccSmrg LockDisplay(dpy); 101caade7ccSmrg GetReq(MITSetBugMode, req); 102caade7ccSmrg req->reqType = info->codes->major_opcode; 103caade7ccSmrg req->mitReqType = X_MITSetBugMode; 104caade7ccSmrg req->onOff = onOff; 105caade7ccSmrg UnlockDisplay(dpy); 106caade7ccSmrg SyncHandle(); 107caade7ccSmrg return 1; 108caade7ccSmrg} 109caade7ccSmrg 110caade7ccSmrgBool XMITMiscGetBugMode(Display *dpy) 111caade7ccSmrg{ 112caade7ccSmrg XExtDisplayInfo *info = find_display (dpy); 113caade7ccSmrg register xMITGetBugModeReq *req; 114caade7ccSmrg xMITGetBugModeReply rep; 115caade7ccSmrg 116caade7ccSmrg MITCheckExtension (dpy, info, 0); 117caade7ccSmrg 118caade7ccSmrg LockDisplay(dpy); 119caade7ccSmrg GetReq(MITGetBugMode, req); 120caade7ccSmrg req->reqType = info->codes->major_opcode; 121caade7ccSmrg req->mitReqType = X_MITGetBugMode; 122caade7ccSmrg if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { 123caade7ccSmrg UnlockDisplay(dpy); 124caade7ccSmrg SyncHandle(); 125caade7ccSmrg return False; 126caade7ccSmrg } 127caade7ccSmrg UnlockDisplay(dpy); 128caade7ccSmrg SyncHandle(); 129caade7ccSmrg return rep.onOff; 130caade7ccSmrg} 131