comparison src/video/Xext/extensions/extutil.h @ 292:eadc0746dfaf

Added SDL_LockRect() and SDL_UnlockRect() Incorporated XFree86 extension libraries into the source
author Sam Lantinga <slouken@libsdl.org>
date Tue, 05 Mar 2002 19:55:32 +0000
parents
children 045f186426e1
comparison
equal deleted inserted replaced
291:68a8a8237c09 292:eadc0746dfaf
1 /*
2 * $Xorg: extutil.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $
3 *
4 Copyright 1989, 1998 The Open Group
5
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
10 documentation.
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of The Open Group shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from The Open Group.
25 *
26 * Author: Jim Fulton, MIT The Open Group
27 *
28 * Xlib Extension-Writing Utilities
29 *
30 * This package contains utilities for writing the client API for various
31 * protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
32 * ARE SUBJECT TO CHANGE!
33 */
34 /* $XFree86: xc/include/extensions/extutil.h,v 1.9 2001/12/14 19:53:28 dawes Exp $ */
35
36 #ifndef _EXTUTIL_H_
37 #define _EXTUTIL_H_
38
39 #include <X11/extensions/Xext.h>
40
41 /*
42 * We need to keep a list of open displays since the Xlib display list isn't
43 * public. We also have to per-display info in a separate block since it isn't
44 * stored directly in the Display structure.
45 */
46 typedef struct _XExtDisplayInfo {
47 struct _XExtDisplayInfo *next; /* keep a linked list */
48 Display *display; /* which display this is */
49 XExtCodes *codes; /* the extension protocol codes */
50 XPointer data; /* extra data for extension to use */
51 } XExtDisplayInfo;
52
53 typedef struct _XExtensionInfo {
54 XExtDisplayInfo *head; /* start of list */
55 XExtDisplayInfo *cur; /* most recently used */
56 int ndisplays; /* number of displays */
57 } XExtensionInfo;
58
59 typedef struct _XExtensionHooks {
60 int (*create_gc)(
61 #if NeedNestedPrototypes
62 Display* /* display */,
63 GC /* gc */,
64 XExtCodes* /* codes */
65 #endif
66 );
67 int (*copy_gc)(
68 #if NeedNestedPrototypes
69 Display* /* display */,
70 GC /* gc */,
71 XExtCodes* /* codes */
72 #endif
73 );
74 int (*flush_gc)(
75 #if NeedNestedPrototypes
76 Display* /* display */,
77 GC /* gc */,
78 XExtCodes* /* codes */
79 #endif
80 );
81 int (*free_gc)(
82 #if NeedNestedPrototypes
83 Display* /* display */,
84 GC /* gc */,
85 XExtCodes* /* codes */
86 #endif
87 );
88 int (*create_font)(
89 #if NeedNestedPrototypes
90 Display* /* display */,
91 XFontStruct* /* fs */,
92 XExtCodes* /* codes */
93 #endif
94 );
95 int (*free_font)(
96 #if NeedNestedPrototypes
97 Display* /* display */,
98 XFontStruct* /* fs */,
99 XExtCodes* /* codes */
100 #endif
101 );
102 int (*close_display)(
103 #if NeedNestedPrototypes
104 Display* /* display */,
105 XExtCodes* /* codes */
106 #endif
107 );
108 Bool (*wire_to_event)(
109 #if NeedNestedPrototypes
110 Display* /* display */,
111 XEvent* /* re */,
112 xEvent* /* event */
113 #endif
114 );
115 Status (*event_to_wire)(
116 #if NeedNestedPrototypes
117 Display* /* display */,
118 XEvent* /* re */,
119 xEvent* /* event */
120 #endif
121 );
122 int (*error)(
123 #if NeedNestedPrototypes
124 Display* /* display */,
125 xError* /* err */,
126 XExtCodes* /* codes */,
127 int* /* ret_code */
128 #endif
129 );
130 char *(*error_string)(
131 #if NeedNestedPrototypes
132 Display* /* display */,
133 int /* code */,
134 XExtCodes* /* codes */,
135 char* /* buffer */,
136 int /* nbytes */
137 #endif
138 );
139 } XExtensionHooks;
140
141 extern XExtensionInfo *XextCreateExtension(
142 #if NeedFunctionPrototypes
143 void
144 #endif
145 );
146 extern void XextDestroyExtension(
147 #if NeedFunctionPrototypes
148 XExtensionInfo* /* info */
149 #endif
150 );
151 extern XExtDisplayInfo *XextAddDisplay(
152 #if NeedFunctionPrototypes
153 XExtensionInfo* /* extinfo */,
154 Display* /* dpy */,
155 char* /* ext_name */,
156 XExtensionHooks* /* hooks */,
157 int /* nevents */,
158 XPointer /* data */
159 #endif
160 );
161 extern int XextRemoveDisplay(
162 #if NeedFunctionPrototypes
163 XExtensionInfo* /* extinfo */,
164 Display* /* dpy */
165 #endif
166 );
167 extern XExtDisplayInfo *XextFindDisplay(
168 #if NeedFunctionPrototypes
169 XExtensionInfo* /* extinfo */,
170 Display* /* dpy */
171 #endif
172 );
173
174 #define XextHasExtension(i) ((i) && ((i)->codes))
175 #define XextCheckExtension(dpy,i,name,val) \
176 if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
177 #define XextSimpleCheckExtension(dpy,i,name) \
178 if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
179
180
181 /*
182 * helper macros to generate code that is common to all extensions; caller
183 * should prefix it with static if extension source is in one file; this
184 * could be a utility function, but have to stack 6 unused arguments for
185 * something that is called many, many times would be bad.
186 */
187 #define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
188 XExtDisplayInfo *proc (Display *dpy) \
189 { \
190 XExtDisplayInfo *dpyinfo; \
191 if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
192 if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
193 dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
194 return dpyinfo; \
195 }
196
197 #define XEXT_FIND_DISPLAY_PROTO(proc) \
198 XExtDisplayInfo *proc(Display *dpy)
199
200 #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
201 int proc (Display *dpy, XExtCodes *codes) \
202 { \
203 return XextRemoveDisplay (extinfo, dpy); \
204 }
205
206 #define XEXT_CLOSE_DISPLAY_PROTO(proc) \
207 int proc(Display *dpy, XExtCodes *codes)
208
209 #define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
210 char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
211 { \
212 code -= codes->first_error; \
213 if (code >= 0 && code < nerr) { \
214 char tmp[256]; \
215 sprintf (tmp, "%s.%d", extname, code); \
216 XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
217 return buf; \
218 } \
219 return (char *)0; \
220 }
221
222 #define XEXT_ERROR_STRING_PROTO(proc) \
223 char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
224 #endif