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